Compare commits
2 Commits
5cabf845b6
...
8f148b6894
| Author | SHA1 | Date | |
|---|---|---|---|
|
8f148b6894
|
|||
|
7306c8fba4
|
61
code/first.c
61
code/first.c
@@ -61,32 +61,42 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
@@ -99,10 +109,9 @@ int main(int argc, char **argv) {
|
|||||||
{
|
{
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
ProcessEvents(&e, &world);
|
ProcessEvents(&e, game->world);
|
||||||
}
|
}
|
||||||
|
UpdateWorld(1.0/60.0, game->world);
|
||||||
UpdateWorld(1.0f / 60.0f, &world);
|
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
|||||||
@@ -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_CalculateCamera(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_
|
||||||
|
|||||||
Reference in New Issue
Block a user