aboutsummaryrefslogtreecommitdiff
path: root/enemy.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-10-01 18:59:53 +1000
committerquou <quou@disroot.org>2024-10-01 19:00:04 +1000
commita5f6618cd6a692eda3acd934b71355959b388518 (patch)
tree6f5d4813be49ccf9bab8740a14546e6ec3b6dd72 /enemy.c
parent626a3850ebc4859cecb9b3a003c96b69c2fdf7f9 (diff)
the enemy can hurt the player now
Diffstat (limited to 'enemy.c')
-rw-r--r--enemy.c24
1 files changed, 21 insertions, 3 deletions
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);