diff options
author | quou <quou@disroot.org> | 2024-09-30 22:28:50 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-09-30 22:28:50 +1000 |
commit | d2837633da48e3cc0530d718de5e0bbfcd4fcc34 (patch) | |
tree | 3cac6b4b49b93e199ed5b14e9438a0c026fc8b26 | |
parent | ee655819d44307d974fb27e1fa04d079a3810d63 (diff) |
enemy invulnerable frames
-rw-r--r-- | config.h | 1 | ||||
-rw-r--r-- | enemy.c | 6 | ||||
-rw-r--r-- | obj.h | 2 |
3 files changed, 8 insertions, 1 deletions
@@ -40,6 +40,7 @@ #define player_lunge_force (f1) #define player_slash_damage 1 +#define enemy_inv_frames 8 #define enemy_demon_move_force 32 #define enemy_demon_attack_dist f1 #define enemy_demon_jump_force (5 << fbits) @@ -44,6 +44,7 @@ void init_enemy(Enemy* e, Enemy_Type t, int x, int y) { e->anim = asset_id_demon_idle_left_anm; e->face = face_left; e->state = enemy_state_patrol; + e->inv = 0; } void update_enemy_anim(Enemy* e) { @@ -82,6 +83,10 @@ void update_enemy_phys(Enemy* e, const Map* map) { void update_enemy_hurt(Enemy* e, const World* w) { Rect a; int i; + if (e->inv) { + e->inv--; + return; + } get_enemy_rect(e->t, &a); a.x += e->x >> fbits; a.y += e->y >> fbits; @@ -91,6 +96,7 @@ void update_enemy_hurt(Enemy* e, const World* w) { e->hp -= dz->hp; e->vx -= dz->vx; e->vy -= dz->vy; + e->inv = enemy_inv_frames; } } } @@ -52,7 +52,7 @@ typedef struct { int x, y, vx, vy; int hp, frame, anim; int grounded, headbutted, on_ramp; - int state; + int state, inv; Face face; Rect rect; } Enemy; |