From 5ef6a71e935e2c3d1e5f9828e8cdbd78403a06a0 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 7 May 2023 09:46:39 +1000 Subject: Add some frames where the skulls are red after being damaged. --- enemy.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'enemy.c') diff --git a/enemy.c b/enemy.c index 710a280..04baec4 100644 --- a/enemy.c +++ b/enemy.c @@ -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; -- cgit v1.2.3-54-g00ecf