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

@@ -5,9 +5,9 @@
}, },
"activeFile": "map/untitled.tmx", "activeFile": "map/untitled.tmx",
"expandedProjectPaths": [ "expandedProjectPaths": [
"map", "tileset",
".", ".",
"tileset" "map"
], ],
"file.lastUsedOpenFilter": "All Files (*)", "file.lastUsedOpenFilter": "All Files (*)",
"fileStates": { "fileStates": {
@@ -20,11 +20,11 @@
"scaleInEditor": 11 "scaleInEditor": 11
}, },
"map/untitled.tmx": { "map/untitled.tmx": {
"scale": 3.8326562499999994, "scale": 2,
"selectedLayer": 0, "selectedLayer": 0,
"viewCenter": { "viewCenter": {
"x": 169.5951730604591, "x": 285.5,
"y": 108.41045293326268 "y": 162.75
} }
}, },
"tileset/prarie.tsx": { "tileset/prarie.tsx": {

View File

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

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE 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();

View File

@@ -8,12 +8,10 @@
#pragma once #pragma once
#include "scene/scene.h" #include "scene/scene.h"
#include "rpg/entity/entity.h" #include "rpg/entity/entity.h"
#include "rpg/world/world.h"
#include "display/camera.h" #include "display/camera.h"
typedef struct { typedef struct {
camera_t camera; camera_t camera;
world_t world;
} scenemap_t; } scenemap_t;
errorret_t sceneMapInit(scenedata_t *data); errorret_t sceneMapInit(scenedata_t *data);