This commit is contained in:
2025-10-26 08:06:39 -05:00
parent d74226dab1
commit 3feb43fdad
34 changed files with 112 additions and 1141 deletions

View File

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

19
src/rpg/world/chunk.h Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "rpg/world/tile.h"
#define CHUNK_WIDTH 16
#define CHUNK_HEIGHT 16
#define CHUNK_DEPTH 16
#define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH)
typedef struct chunk_s {
int16_t x, y, z;
tile_t tiles[CHUNK_TILE_COUNT];
} chunk_t;

14
src/rpg/world/region.h Normal file
View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef struct {
vec2 min;
vec2 max;
} region_t;

15
src/rpg/world/tile.h Normal file
View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
#pragma pack(push, 1)
typedef struct tile_s {
uint8_t id;
} tile_t;
#pragma pack(pop)

23
src/rpg/world/world.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 "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() {
}

32
src/rpg/world/world.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 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();