diff options
author | quou <quou@disroot.org> | 2024-10-02 21:25:09 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-10-02 21:25:09 +1000 |
commit | 3d12118b3a2447b3e1a9e87b81d702f13ad5c7ab (patch) | |
tree | 423f16ea0823c08efea071affa3040ad2e9441ed | |
parent | 5da85053f4d4116c3190a8f45194040ac10baf92 (diff) |
Spawn a particle effect when an enemy takes damage
-rw-r--r-- | enemy.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -82,7 +82,7 @@ void update_enemy_phys(Enemy* e, const Map* map) { void update_enemy_hurt(Enemy* e, World* w) { Rect a; - int i; + int i, cx, cy; if (e->inv) { e->inv--; return; @@ -90,6 +90,8 @@ void update_enemy_hurt(Enemy* e, World* w) { get_enemy_rect(e->t, &a); a.x += e->x >> fbits; a.y += e->y >> fbits; + cx = (a.x << fbits) + ((a.w >> 1) << fbits); + cy = (a.y << fbits) + ((a.h >> 1) << fbits); for (i = 0; i < w->deathzone_count; i++) { const Deathzone* dz = &w->deathzones[i]; if (dz->friendly && rects_overlap(&a, &dz->r)) { @@ -99,6 +101,7 @@ void update_enemy_hurt(Enemy* e, World* w) { e->inv = enemy_inv_frames; w->player.charge++; w->freeze += enemy_hurt_freeze; + inst_effect(w, cx, cy, -dz->vx, -dz->vy, 32); } } } |