This commit is contained in:
2025-11-11 15:50:57 -06:00
parent 5adf8a0773
commit 9953d7d388
11 changed files with 135 additions and 86 deletions

View File

@@ -8,6 +8,7 @@
#include "map.h"
#include "util/memory.h"
#include "assert/assert.h"
#include "scene/scene/scenemap.h"
map_t MAP;
@@ -111,6 +112,7 @@ void mapPositionSet(const chunkpos_t newPos) {
void mapUpdate() {
}
void mapChunkUnload(chunk_t* chunk) {
printf("Unloading chunk at (%d, %d, %d)\n",
chunk->position.x,
@@ -120,33 +122,20 @@ void mapChunkUnload(chunk_t* chunk) {
}
void mapChunkLoad(chunk_t* chunk) {
printf("Loading chunk at (%d, %d, %d)\n",
chunk->position.x,
chunk->position.y,
chunk->position.z
);
// printf("Loading chunk at (%d, %d, %d)\n",
// chunk->position.x,
// chunk->position.y,
// chunk->position.z
// );
memoryZero(chunk->tiles, sizeof(tile_t) * CHUNK_TILE_COUNT);
// 3x3 test walkable area
chunktileindex_t x, y, z;
z = 0;
for(y = 0; y <= 3; y++) {
for(x = 0; x <= 3; x++) {
chunktileindex_t tileIndex = (y * CHUNK_WIDTH) + x;
chunk->tiles[tileIndex] = TILE_WALKABLE;
if(chunk->position.x == 0 && chunk->position.y == 0 && chunk->position.z == 0) {
if(TEST_MAP_READY) {
}
printf("LOAD CHUNK\n");
}
x = 3, y = 3;
chunk->tiles[(z * CHUNK_WIDTH * CHUNK_HEIGHT) + (y * CHUNK_WIDTH) + x] = TILE_STAIRS_UP;
// x = 3, y = 2, z = 1;
// chunk->tiles[(z * CHUNK_WIDTH * CHUNK_HEIGHT) + (y * CHUNK_WIDTH) + x] = TILE_WALKABLE;
// x = 2, y = 2, z = 1;
// chunk->tiles[(z * CHUNK_WIDTH * CHUNK_HEIGHT) + (y * CHUNK_WIDTH) + x] = TILE_WALKABLE;
// x = 4, y = 2, z = 1;
// chunk->tiles[(z * CHUNK_WIDTH * CHUNK_HEIGHT) + (y * CHUNK_WIDTH) + x] = TILE_WALKABLE;
}
chunkindex_t mapGetChunkIndexAt(const chunkpos_t position) {