This commit is contained in:
2025-11-09 09:52:47 -06:00
parent db589b7d91
commit 5a3004f1d1
8 changed files with 65 additions and 69 deletions

View File

@@ -7,7 +7,7 @@
#include "rpg.h"
#include "entity/entity.h"
#include "rpg/world/world.h"
#include "rpg/world/map.h"
#include "rpg/cutscene/cutscenesystem.h"
#include "time/time.h"
#include "rpgcamera.h"
@@ -20,8 +20,7 @@ errorret_t rpgInit(void) {
// Init cutscene subsystem
cutsceneSystemInit();
// Init the world.
worldInit();
mapInit();
rpgCameraInit();
rpgTextboxInit();
@@ -47,9 +46,8 @@ void rpgUpdate(void) {
// TODO: Do not update if the scene is not the map scene?
// Update the world.
worldUpdate();
mapUpdate();
// Update overworld ents.
entity_t *ent = &ENTITIES[0];
do {

View File

@@ -6,5 +6,5 @@
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
world.c
map.c
)

23
src/rpg/world/map.c Normal file
View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "map.h"
#include "util/memory.h"
map_t MAP;
void mapInit() {
memoryZero(&MAP, sizeof(map_t));
for(uint32_t i = 0; i < MAP_CHUNK_COUNT; i++) {
MAP.chunkOrder[i] = &MAP.chunks[i];
}
}
void mapUpdate() {
}

32
src/rpg/world/map.h Normal file
View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "rpg/world/chunk.h"
#define MAP_CHUNK_WIDTH 4
#define MAP_CHUNK_HEIGHT 4
#define MAP_CHUNK_DEPTH 4
#define MAP_CHUNK_COUNT (MAP_CHUNK_WIDTH * MAP_CHUNK_HEIGHT * MAP_CHUNK_DEPTH)
typedef struct map_s {
chunk_t chunks[MAP_CHUNK_COUNT];
chunk_t *chunkOrder[MAP_CHUNK_COUNT];
int16_t x, y, z;
} map_t;
extern map_t MAP;
/**
* Initializes the map.
*/
void mapInit();
/**
* Updates the map.
*/
void mapUpdate();

View File

@@ -1,23 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "world.h"
#include "util/memory.h"
world_t WORLD;
void worldInit() {
memoryZero(&WORLD, sizeof(world_t));
for(uint32_t i = 0; i < WORLD_CHUNK_COUNT; i++) {
WORLD.chunkOrder[i] = &WORLD.chunks[i];
}
}
void worldUpdate() {
}

View File

@@ -1,32 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "rpg/world/chunk.h"
#define WORLD_WIDTH 4
#define WORLD_HEIGHT 4
#define WORLD_DEPTH 4
#define WORLD_CHUNK_COUNT (WORLD_WIDTH * WORLD_HEIGHT * WORLD_DEPTH)
typedef struct world_s {
chunk_t chunks[WORLD_CHUNK_COUNT];
chunk_t *chunkOrder[WORLD_CHUNK_COUNT];
int16_t x, y, z;
} world_t;
extern world_t WORLD;
/**
* Initializes the world.
*/
void worldInit();
/**
* Updates the world.
*/
void worldUpdate();