diff options
author | quou <quou@disroot.org> | 2023-05-07 09:46:39 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-07 09:46:39 +1000 |
commit | 5ef6a71e935e2c3d1e5f9828e8cdbd78403a06a0 (patch) | |
tree | 128326b3234ec3b168f85b7a6749ff0fa4635a09 /enemy.c | |
parent | 40eb179043b77f011fb1048c386ee187f64569d0 (diff) |
Add some frames where the skulls are red after being damaged.
Diffstat (limited to 'enemy.c')
-rw-r--r-- | enemy.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -37,7 +37,7 @@ Entity new_skull(World* world, int x, int y) { col->w = 14 << fbits; col->h = 14 << fbits; - init_csprite(sprite, sprite_skull_right); + init_csprite(sprite, sprite_skull); enemy->hp = skull_hp; enemy->shoot_timer = 0; @@ -91,6 +91,7 @@ void enemy_system(World* world) { unsigned bits; CPosition* pos; CEnemy* enemy; + CSprite* sprite; Player* player; CPosition* ppos; int dpx, dpy, tpx, tpy, d; @@ -118,10 +119,12 @@ void enemy_system(World* world) { if ( (bits & ctype_position) && (bits & ctype_enemy) && - (bits & ctype_skull) + (bits & ctype_skull) && + (bits & ctype_sprite) ) { - pos = &world->positions[i]; - enemy = &world->enemies[i]; + pos = &world->positions[i]; + enemy = &world->enemies[i]; + sprite = &world->sprites[i]; dpx = ((ppos->x - pos->x) >> 4) + 256; dpy = ((ppos->y - pos->y) >> 4) + 256; @@ -129,6 +132,13 @@ void enemy_system(World* world) { tpy = dpy; d = ((dpx * dpx) >> fbits) + ((dpy * dpy) >> fbits); + if (enemy->being_damaged) { + enemy->being_damaged--; + init_csprite(sprite, sprite_skull_damaged); + } else { + init_csprite(sprite, sprite_skull); + } + if (d < 10 << fbits) { dpx = -dpx; dpy = -dpy; |