Compare commits

..

2 Commits

Author SHA1 Message Date
8f148b6894 Merge remote-tracking branch 'origin' 2025-10-05 15:22:09 +01:00
7306c8fba4 chore: struct reorg 2025-10-05 15:21:23 +01:00
2 changed files with 38 additions and 27 deletions

View File

@@ -61,32 +61,42 @@ int main(int argc, char **argv) {
camera->farp = 1000.0f;
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;
}
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));
@@ -99,10 +109,9 @@ int main(int argc, char **argv) {
{
running = false;
}
ProcessEvents(&e, &world);
ProcessEvents(&e, game->world);
}
UpdateWorld(1.0f / 60.0f, &world);
UpdateWorld(1.0/60.0, game->world);
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);

View File

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