Files
ld58/code/game/world.h

89 lines
1.8 KiB
C
Raw Permalink Normal View History

2025-10-04 21:08:52 +01:00
#if !defined(LD_GAME_WORLD_H_)
#define LD_GAME_WORLD_H_
2025-10-05 15:32:57 +01:00
#include "../core/math.h"
2025-10-05 00:25:37 +01:00
2025-10-06 16:35:22 +01:00
#define WORLD_HITBOX_MAX 4096
#define WORLD_PROP_MAX 2048
#define WORLD_PROP_TYPE_MAX 64
#define WORLD_TILE_TYPE_MAX 64
#define WORLD_MAP_MAX 4800
// Areas are which
typedef U32 World_Area;
2025-10-06 00:38:10 +01:00
enum World_Area
{
WORLD_AREA_OUTSIDE = (1 << 0),
2025-10-06 00:38:10 +01:00
WORLD_AREA_SALOON = (1 << 1),
};
typedef struct World_Tile World_Tile;
2025-10-06 14:26:00 +01:00
struct World_Tile {
2025-10-06 16:35:22 +01:00
Str8 tag;
F32 rotation;
2025-10-05 00:25:37 +01:00
};
2025-10-04 21:08:52 +01:00
2025-10-06 14:26:00 +01:00
typedef struct World_PropType World_PropType;
struct World_PropType {
2025-10-06 16:35:22 +01:00
Str8 tag;
2025-10-06 14:26:00 +01:00
F32 scale;
};
typedef struct World_Prop World_Prop;
struct World_Prop
{
U32 propType;
World_Area area;
V2f pos;
};
2025-10-04 21:08:52 +01:00
typedef struct World World;
2025-10-05 22:35:34 +01:00
#include "player.h"
#include "npc.h"
#include "bandit.h"
2025-10-05 22:35:34 +01:00
2025-10-04 21:08:52 +01:00
struct World {
2025-10-06 01:10:44 +01:00
//// Utils
M_Arena *arena;
//// Static stuff
2025-10-05 14:46:04 +01:00
NavMesh *navMesh;
2025-10-05 15:32:57 +01:00
Random random;
2025-10-05 22:35:34 +01:00
V2f mouseProjected;
2025-10-06 16:35:22 +01:00
//// Loaded from world file
World_Tile *tileTypes;
World_PropType *propTypes;
World_Prop *props;
AABB *hitboxes;
U32 *map;
2025-10-06 14:26:00 +01:00
U32 propCount;
2025-10-06 14:50:32 +01:00
U32 hitboxCount;
//// Player
2025-10-06 00:38:10 +01:00
Player player;
//// NPCs
2025-10-05 00:25:37 +01:00
U32 npcCount;
2025-10-05 18:28:58 +01:00
NPC npcs[128];
////Bandit
// The bandit the player is after.
Bandit bandit;
2025-10-05 00:25:37 +01:00
// NPC points of interest, places to walk to.
U32 npcPOI[256];
2025-10-04 21:08:52 +01:00
};
function void UpdateWorld(F32 delta, World *world);
2025-10-06 00:38:10 +01:00
function void RenderWorld(World *world, D_Context *drawContext);
function void ProcessEvents(SDL_Event *event, World *world);
2025-10-05 00:25:37 +01:00
function void UpdateNPCs(F32 delta, World *world);
2025-10-05 21:05:29 +01:00
function void UpdateNPC(F32 delta, NPC *npc, World *world);
function void UpdateBandit(F32 delta, Bandit *bandit, World *world);
2025-10-05 00:25:37 +01:00
2025-10-06 16:35:22 +01:00
function void LoadWorld(M_Arena *arena, World *world);
2025-10-06 01:10:44 +01:00
function void SaveWorld(M_Arena *arena, World *world);
2025-10-06 18:23:47 +01:00
function void GenerateNavMesh(M_Arena *arena, World *world);
2025-10-06 01:10:44 +01:00
2025-10-04 21:08:52 +01:00
#endif // LD_GAME_WORLD_H_