feat: People go walkies

This commit is contained in:
2025-10-05 16:49:18 +01:00
parent 394366480b
commit 222575b318
7 changed files with 58 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_keycode.h>
#define STB_IMAGE_IMPLEMENTATION 1
#include <stb_image.h>
@@ -61,24 +62,27 @@ int main(int argc, char **argv) {
camera->farp = 1000.0f;
game->draw.camera = camera;
game->camera.p.z = 200;
World *world = M_ArenaPush(arena, World);
game->world = world;
world->random = Random_Seed(29237489723847);
world->npcCount = 2;
NPC *npc1 = &world->npcs[0];
npc1->collision.pos.x = 15;
npc1->collision.pos.y = 15;
npc1->collision.size.x = 10;
npc1->collision.size.y = 10;
npc1->name = S("Matt");
npc1->mode = NPC_ACTION_WAITING;
npc1->waitTime = 0;
npc1->maxWaitTime = 5;
npc1->currentNavNode = 87;
npc1->collision.pos.x = 15;
npc1->collision.pos.y = 15;
npc1->collision.size.x = 10;
npc1->collision.size.y = 10;
world->npcCount = 100;
for(int i = 0; i < 100; i++) {
NPC *npc1 = &world->npcs[i];
npc1->collision.pos.x = 15;
npc1->collision.pos.y = 15;
npc1->collision.size.x = 10;
npc1->collision.size.y = 10;
npc1->name = S("Matt");
npc1->mode = NPC_ACTION_WAITING;
npc1->waitTime = 0;
npc1->maxWaitTime = 5;
npc1->currentNavNode = 0;
npc1->collision.pos.x = 15;
npc1->collision.pos.y = 15;
npc1->collision.size.x = 10;
npc1->collision.size.y = 10;
}
NPC *npc2 = &world->npcs[1];
npc2->collision.pos.x = 15;
@@ -110,6 +114,20 @@ int main(int argc, char **argv) {
{
running = false;
}
if (e.type == SDL_EVENT_KEY_DOWN) {
if(e.key.key == SDLK_DOWN) {
game->camera.p.y += 5;
}
if(e.key.key == SDLK_UP) {
game->camera.p.y -= 5;
}
if(e.key.key == SDLK_RIGHT) {
game->camera.p.x += 5;
}
if(e.key.key == SDLK_LEFT) {
game->camera.p.x -= 5;
}
}
ProcessEvents(&e, game->world);
}
UpdateWorld(1.0/60.0, game->world);
@@ -150,6 +168,7 @@ int main(int argc, char **argv) {
D_Begin(&game->draw, frame, D_MAX_RECTS);
RenderWorld(game->world, &game->draw);
D_Rect(&game->draw, 0.0f, 0.0f, .texture = 1);
D_Rect(&game->draw, -8.0f, 0.0f, .texture = 2, .scale = 2.0f);
D_Rect(&game->draw, 6.0f, 0.0f, .texture = 3);