diff options
author | quou <quou@disroot.org> | 2023-05-06 09:02:04 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-06 09:02:04 +1000 |
commit | 2ab411c4b8855d11d48454a93262e8eae3ba7fc7 (patch) | |
tree | e608ebd0bea71570be0a3619f9848f975669e5ef /player.c | |
parent | fb104368dd33b66e0575dcc0327cbae7046a4e1e (diff) |
Menus, game over, dying, etc.
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; +} |