feat: Initial bandit roaming

This commit is contained in:
2025-10-05 21:05:29 +01:00
parent b8f47b8f61
commit 635e7b1c1e
8 changed files with 104 additions and 23 deletions

View File

@@ -5,6 +5,7 @@
void UpdateWorld(F32 delta, World *world)
{
UpdateBandit(delta, &world->bandit, world);
UpdateNPCs(delta, world);
PlayerUpdate(delta, &world->player);
}
@@ -13,7 +14,11 @@ void UpdateNPCs(F32 delta, World *world)
{
for (U32 i = 0; i < world->npcCount; i++)
{
updateNPC(delta, &world->npcs[i], world);
UpdateNPC(delta, &world->npcs[i], world);
if(world->player.controls.shot && AABB_Point(world->npcs[i].collision, world->player.shotPos)) {
// TODO we need to unproject the mouse location !!!
printf("You shot %.*s\n", Sv(world->npcs[i].name));
}
}
}
@@ -24,7 +29,10 @@ void ProcessEvents(SDL_Event *event, World *world)
void RenderWorld(World *world, D_Context *draw) {
for(int i = 0; i < world->npcCount; i++) {
D_Rect(draw, world->npcs[i].collision.pos.x, world->npcs[i].collision.pos.y, .texture = 1);
NPC npc = world->npcs[i];
D_Rect(draw, npc.collision.pos.x, npc.collision.pos.y, .texture = 1);
D_Rect(draw, npc.collision.pos.x, npc.collision.pos.y, .texture = 0, .dim = npc.collision.size);
}
D_Rect(draw, world->bandit.collision.pos.x, world->bandit.collision.pos.y, .texture = 9);
D_Rect(draw, world->player.pos.x, world->player.pos.y, .texture = 1);
}