diff options
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; |