chore: struct reorg

This commit is contained in:
2025-10-05 15:21:23 +01:00
parent 1d70f3ae20
commit 7306c8fba4
2 changed files with 38 additions and 26 deletions

View File

@@ -61,6 +61,39 @@ int main(int argc, char **argv) {
camera->farp = 1000.0f; camera->farp = 1000.0f;
game->draw.camera = camera; game->draw.camera = camera;
World *world = M_ArenaPush(arena, World);
game->world = world;
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;
NPC *npc2 = &world->npcs[0];
npc2->collision.pos.x = 15;
npc2->collision.pos.y = 15;
npc2->collision.size.x = 10;
npc2->collision.size.y = 10;
npc2->name = S("James");
npc2->mode = NPC_ACTION_WAITING;
npc2->waitTime = 0;
npc2->maxWaitTime = 10;
npc2->currentNavNode = 0;
world->navMesh = &TestNavMesh;
world->npcPOI[0] = 100;
world->player.pos.x = 0;
world->player.pos.y = 0;
} }
Vk_Buffer rbo = { 0 }; Vk_Buffer rbo = { 0 };
@@ -71,29 +104,6 @@ int main(int argc, char **argv) {
Vk_BufferCreate(&rbo); Vk_BufferCreate(&rbo);
bool running = true; bool running = true;
World world = {
.npcCount = 2,
.npcs = {
{
.collision = {{10, 10}, {10, 10}},
.name = S("Matt"),
.mode = NPC_ACTION_WAITING,
.waitTime = 0,
.maxWaitTime = 5,
.currentNavNode = 87
},{
.collision = {{15, 15}, {10, 10}},
.name = S("James"),
.mode = NPC_ACTION_WAITING,
.waitTime = 0,
.maxWaitTime = 10,
.currentNavNode = 0
}
},
.navMesh = &TestNavMesh,
.npcPOI = {100},
.player = {.pos = {0,0}}
};
printf("%zu size in bytes\n", sizeof(TestNavMesh)); printf("%zu size in bytes\n", sizeof(TestNavMesh));
@@ -106,9 +116,9 @@ int main(int argc, char **argv) {
{ {
running = false; running = false;
} }
ProcessEvents(&e, &world); ProcessEvents(&e, game->world);
} }
UpdateWorld(1.0/60.0, &world); UpdateWorld(1.0/60.0, game->world);
int w, h; int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h); SDL_GetWindowSizeInPixels(window, &w, &h);

View File

@@ -1,5 +1,6 @@
#if !defined(LD_GAME_CORE_H_) #if !defined(LD_GAME_CORE_H_)
#define LD_GAME_CORE_H_ #define LD_GAME_CORE_H_
#include "world.h"
typedef struct G_Camera G_Camera; typedef struct G_Camera G_Camera;
struct G_Camera { struct G_Camera {
@@ -18,6 +19,8 @@ struct G_State {
D_Context draw; D_Context draw;
G_Camera camera; G_Camera camera;
World *world;
}; };
function void G_ImagesLoad(G_State *game); function void G_ImagesLoad(G_State *game);
@@ -29,6 +32,5 @@ function void G_CalulateCamera(G_Camera *camera, F32 aspect);
#include "player.h" #include "player.h"
#include "nav.h" #include "nav.h"
#include "npc.h" #include "npc.h"
#include "world.h"
#endif // LD_GAME_CORE_H_ #endif // LD_GAME_CORE_H_