diff options
Diffstat (limited to 'player.c')
-rw-r--r-- | player.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -1,11 +1,14 @@ #include "animation.h" +#include "bullet.h" #include "components.h" +#include "game.h" #include "game_config.h" #include "input.h" #include "player.h" #include "standard.h" #include "world.h" -#include "bullet.h" + +extern Game game; void init_player(Player* player, World* world) { CSprite* sprite; @@ -48,6 +51,7 @@ void init_player(Player* player, World* world) { player->face = 0; player->shoot_cooldown = 15; player->shoot_countdown = 0; + player->hp = player_max_hp; } void update_player(Player* player, World* world) { @@ -124,5 +128,13 @@ void update_player(Player* player, World* world) { player->shoot_countdown = player->shoot_cooldown; } + if (player->hp <= 0) { + game_change_state(&game, game_state_dead); + } + player->shoot_countdown--; } + +void player_take_damage(Player* player, int dmg) { + player->hp -= dmg; +} |