A retro platform game
git clone git://soophie.de/freezo
7
#define PLAYER_HEIGHT 12 *SCALE8
#define ENEMY_WIDTH 8 * SCALE9
#define ENEMY_HEIGHT 12 * SCALE10
#define PLAYER_HEALTH 610
#define PLAYER_SHOOTING_RANGE 2 * TILE_WIDTH11
#define PLAYER_GRAVITY 1012
#define FONT_WIDTH 5 * (SCALE - 1)
7
#include "game.h"8
#include "entity.h"10
#define PLAYER_MAX_HEALTH 612
struct Player {13
pos_t pos;14
int health;15
int max_health;16
bool on_ground;17
float velocity;18
float gravity;
94
}95
if (game->sceen_timer == GAME_SCEEN_TIMER) {96
level_e level = game->level->type;97
int max_health = game->player->max_health;98
max_health -= 2;99
if (max_health <= 0) {100
level = LEVEL_1;101
max_health = PLAYER_MAX_HEALTH;102
}103
level_unload(game);104
level_load(game, level);105
game->player->max_health = max_health;106
game->player->health = max_health;107
game->defeat = false;108
game->xp = 0;109
game->sceen_timer = 0;
123
if (game->sceen_timer == GAME_SCEEN_TIMER) {124
if (game->level->type < LEVELS) {125
level_e level = game->level->type;126
int max_health = game->player->max_health;127
level++;128
level_unload(game);129
level_load(game, level);130
game->player->max_health = max_health;131
game->player->health = max_health;132
}133
game->victory = false;134
game->sceen_timer = 0;
237
DrawTextureRec(game->assets.tiles, texture_rect(1, 1, TILE_WIDTH, TILE_HEIGHT), (pos_t) { TILE_WIDTH / 2.0 + i * (TILE_WIDTH + TILE_WIDTH / 4.0), TILE_WIDTH / 2.0 }, WHITE);238
i++;239
}229
for (; i < PLAYER_HEALTH / 2; i++) {240
for (; i < game->player->max_health / 2; i++) {241
DrawTextureRec(game->assets.tiles, texture_rect(2, 1, TILE_WIDTH, TILE_HEIGHT), (pos_t) { TILE_WIDTH / 2.0 + i * (TILE_WIDTH + TILE_WIDTH / 4.0), TILE_WIDTH / 2.0 }, WHITE);242
}243
if (game->is_muted) {
12
player_t *player = malloc(sizeof(player_t));13
*player = (player_t) {14
.pos = pos,15
.health = 6,15
.health = PLAYER_MAX_HEALTH,16
.max_health = PLAYER_MAX_HEALTH,17
.on_ground = false,18
.velocity = 0.0,19
.gravity = 0.0,