aboutsummaryrefslogtreecommitdiff
path: root/player.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-07 09:37:45 +1000
committerquou <quou@disroot.org>2023-05-07 09:37:45 +1000
commit40eb179043b77f011fb1048c386ee187f64569d0 (patch)
treeebae794ec0b3b8851b8c29119ada06555f49d4b6 /player.c
parent47e7976922f5c17505c7c5a3377c3735649e3dcc (diff)
Add waves and some more polish.
Diffstat (limited to 'player.c')
-rw-r--r--player.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/player.c b/player.c
index 7135557..ff3f53b 100644
--- a/player.c
+++ b/player.c
@@ -1,6 +1,7 @@
#include "animation.h"
#include "bullet.h"
#include "components.h"
+#include "fx.h"
#include "game.h"
#include "game_config.h"
#include "input.h"
@@ -129,6 +130,22 @@ void update_player(Player* player, World* world) {
player->shoot_countdown = player->shoot_cooldown;
}
+ if (player->invul) {
+ player->invul--;
+ player->invul_counter++;
+
+ if (player->invul_counter > 3) {
+ if (world->bitmask[e] & ctype_sprite) {
+ world->bitmask[e] &= ~ctype_sprite;
+ } else {
+ world->bitmask[e] |= ctype_sprite;
+ }
+ player->invul_counter = 0;
+ }
+ } else {
+ world->bitmask[e] |= ctype_sprite;
+ }
+
if (player->hp <= 0) {
world->oom = 0;
game_change_state(&game, game_state_dead);
@@ -137,8 +154,25 @@ void update_player(Player* player, World* world) {
player->shoot_countdown--;
}
-void player_take_damage(Player* player, int dmg) {
+void player_take_damage(
+ World* world,
+ Player* player,
+ int dmg
+) {
+ const CPosition* pos;
+
+ pos = &world->positions[player->entity];
+
+ if (player->invul) { return; }
+
player->hp -= dmg;
+ player->invul = player_invul_frames;
+ player->invul_counter = 0;
+ new_heart_break(
+ world,
+ pos->x + (4 << fbits),
+ pos->y - (8 << fbits)
+ );
}
void update_camera(Player* player, World* world) {