From a5f6618cd6a692eda3acd934b71355959b388518 Mon Sep 17 00:00:00 2001 From: quou Date: Tue, 1 Oct 2024 18:59:53 +1000 Subject: the enemy can hurt the player now --- enemy.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'enemy.c') diff --git a/enemy.c b/enemy.c index bc97030..2ec6a16 100644 --- a/enemy.c +++ b/enemy.c @@ -92,7 +92,7 @@ void update_enemy_hurt(Enemy* e, const World* w) { a.y += e->y >> fbits; for (i = 0; i < w->deathzone_count; i++) { const Deathzone* dz = &w->deathzones[i]; - if (rects_overlap(&a, &dz->r)) { + if (dz->friendly && rects_overlap(&a, &dz->r)) { e->hp -= dz->hp; e->vx -= dz->vx; e->vy -= dz->vy; @@ -110,7 +110,7 @@ int tile_at(const Map* m, int x, int y) { m->collision[x + y * map_w] == 1; } -void update_demon_move(Enemy* e, const World* w) { +void update_demon_move(Enemy* e, World* w) { int nanim = e->anim; const Player* p = &w->player; if (e->state == enemy_state_patrol) { @@ -164,6 +164,24 @@ void update_demon_move(Enemy* e, const World* w) { } } else if (e->state == enemy_state_attack) { if (e->grounded < 3) { + Asset_ID sl; + Rect dz; + int sx, sy = e->y >> fbits, vx; + if (e->face == face_left) { + sl = asset_id_smol_slash_left_anm; + sx = (e->x >> fbits) - 16; + vx = enemy_knockback; + } else { + sl = asset_id_smol_slash_right_anm; + sx = (e->x >> fbits) + 16; + vx = -enemy_knockback; + } + dz.x = sx; + dz.y = sy; + dz.w = 16; + dz.h = 12; + inst_particle(w, sx, sy, sl, asset_id_arms_img); + inst_deathzone(w, &dz, vx, 0, enemy_slash_damage, 4, 0); e->state = enemy_state_patrol; } } @@ -191,7 +209,7 @@ void update_demon_move(Enemy* e, const World* w) { } } -void update_enemy_move(Enemy* e, const World* w) { +void update_enemy_move(Enemy* e, World* w) { switch (e->t) { case enemy_demon: update_demon_move(e, w); -- cgit v1.2.3-54-g00ecf