diff options
author | quou <quou@disroot.org> | 2023-05-07 09:37:45 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-07 09:37:45 +1000 |
commit | 40eb179043b77f011fb1048c386ee187f64569d0 (patch) | |
tree | ebae794ec0b3b8851b8c29119ada06555f49d4b6 /player.c | |
parent | 47e7976922f5c17505c7c5a3377c3735649e3dcc (diff) |
Add waves and some more polish.
Diffstat (limited to 'player.c')
-rw-r--r-- | player.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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) { |