aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'player.c')
-rw-r--r--player.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/player.c b/player.c
index b2dbf29..592ef4a 100644
--- a/player.c
+++ b/player.c
@@ -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;
+}