aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-06 09:02:04 +1000
committerquou <quou@disroot.org>2023-05-06 09:02:04 +1000
commit2ab411c4b8855d11d48454a93262e8eae3ba7fc7 (patch)
treee608ebd0bea71570be0a3619f9848f975669e5ef /player.c
parentfb104368dd33b66e0575dcc0327cbae7046a4e1e (diff)
Menus, game over, dying, etc.
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;
+}