Enemies are shootable

This commit is contained in:
Bill Rossi 2025-03-01 11:40:23 -05:00
parent 62bb35a311
commit 5207df1c30

13
game.c
View File

@ -67,6 +67,18 @@ void handle_input(Game *g) {
} }
} }
void process_bullet_collisions(Game *g, Entity *bullet) {
FOREACH_ENEMY {
INIT_ENEMY;
Rectangle bullet_rec = ((BulletProperties*)bullet->properties)->position;
Rectangle enemy_rec = ((EnemyProperties*)e->properties)->position;
if (CheckCollisionRecs(bullet_rec, enemy_rec)) {
remove_entity(g->bullets, bullet);
remove_entity(g->enemies, e);
}
}
}
void run_frame(Game *g) { void run_frame(Game *g) {
handle_input(g); handle_input(g);
move_player(g->player); move_player(g->player);
@ -86,6 +98,7 @@ void run_frame(Game *g) {
continue; continue;
} }
e->tick(e, GetFrameTime()); e->tick(e, GetFrameTime());
process_bullet_collisions(g, e);
} }
} }