diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2023-04-06 21:35:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 21:35:17 +0200 |
commit | b2c58b8d52717f8b5bf04d87b9799c7467e4eeb6 (patch) | |
tree | 344243247b21a93311a9cc2173fbddb2d126c040 /src/engine/enemy_ai.c | |
parent | 8be7919774250cca23151bf1505cbb48d1dd45ee (diff) | |
parent | e88c48ae60dd48542e44b0cc244b191c91782681 (diff) |
Merge pull request #60 from UnavailableDev/dev
random shop items + animation (slimes)
Diffstat (limited to 'src/engine/enemy_ai.c')
-rw-r--r-- | src/engine/enemy_ai.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/engine/enemy_ai.c b/src/engine/enemy_ai.c index 81d04d9..974de9e 100644 --- a/src/engine/enemy_ai.c +++ b/src/engine/enemy_ai.c @@ -34,9 +34,15 @@ void hh_slime_ai(hh_entity* enemy, hh_entity player){ hh_gravity_entity(enemy); hh_update_enemy_movement(enemy); + hh_animate(&enemy->render, + HH_TM_SLIME_JUMPABLE_OFFSET , + HH_TM_SLIME_JUMPABLE_OFFSET + 3,1 + ); + } void hh_jump_slime_ai(hh_entity* enemy, hh_entity player){ + bool jumped = false; int8_t direction = hh_get_direction(player.pos.x, enemy->pos.x); hh_gravity_entity(enemy); if((player.pos.x - enemy->pos.x) >= -hunt_player && (player.pos.x - enemy->pos.x) <= hunt_player){ @@ -44,11 +50,16 @@ void hh_jump_slime_ai(hh_entity* enemy, hh_entity player){ // TODO: fix this if statement and make it cleaner. this makes the enemy jump when the player mets the condition if((player.pos.y - enemy->pos.y) < -16 && (player.pos.y - enemy->pos.y) >= -100 && (player.pos.x - enemy->pos.x) >= -10 && (player.pos.x - enemy->pos.x) <= 10){ hh_jump_entity(enemy); + jumped = true; } } - + hh_animate(&enemy->render, + HH_TM_SLIME_JUMPABLE_OFFSET + (jumped?4:0), + HH_TM_SLIME_JUMPABLE_OFFSET + (enemy->render.fam.tilemap_index>=HH_TM_SLIME_JUMPABLE_OFFSET+5 ? 7 : 3),1 + ); hh_update_enemy_movement(enemy); + } #define terror_owl_attack_timer 100 #define terror_owl_follow_player_delay 5 |