aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-10-02 21:25:09 +1000
committerquou <quou@disroot.org>2024-10-02 21:25:09 +1000
commit3d12118b3a2447b3e1a9e87b81d702f13ad5c7ab (patch)
tree423f16ea0823c08efea071affa3040ad2e9441ed
parent5da85053f4d4116c3190a8f45194040ac10baf92 (diff)
Spawn a particle effect when an enemy takes damage
-rw-r--r--enemy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/enemy.c b/enemy.c
index 1e5a4d2..5901445 100644
--- a/enemy.c
+++ b/enemy.c
@@ -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);
}
}
}