Load is now rounded compile time.

This commit is contained in:
2025-08-18 21:46:12 -05:00
parent d79e12ffaa
commit 1e57183ca1
5 changed files with 9 additions and 13 deletions

View File

@@ -10,8 +10,8 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT DEFINED DUSK_TARGET_SYSTEM)
set(DUSK_TARGET_SYSTEM "psp")
# set(DUSK_TARGET_SYSTEM "linux")
# set(DUSK_TARGET_SYSTEM "psp")
set(DUSK_TARGET_SYSTEM "linux")
endif()
# Prep cache

View File

@@ -40,8 +40,8 @@ void entityLoad(entity_t *entity, const entity_t *source) {
memoryZero(entity, sizeof(entity_t));
entity->type = source->type;
entity->x = (uint32_t)roundf(source->x / (float_t)TILE_WIDTH_HEIGHT);
entity->y = (uint32_t)roundf(source->y / (float_t)TILE_WIDTH_HEIGHT);
entity->x = source->x;
entity->y = source->y;
entity->dir = source->dir;
entity->id = source->id;

View File

@@ -3,5 +3,4 @@ CHUNK_WIDTH = 8
CHUNK_HEIGHT = 8
CHUNK_TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT
CHUNK_ENTITY_COUNT_MAX = 8
TILE_WIDTH_HEIGHT = 16
TILE_WIDTH_HEIGHT = 16

View File

@@ -1,2 +0,0 @@
def floatToFixed248(value):
return value;

View File

@@ -2,11 +2,10 @@ import sys, os
import argparse
from datetime import datetime
import math
from helper import floatToFixed248
from inputParser import parseInputFile
from mapParser import parseMap
from chunkParser import parseChunk
from constants import CHUNK_WIDTH, CHUNK_HEIGHT
from constants import CHUNK_WIDTH, CHUNK_HEIGHT, TILE_WIDTH_HEIGHT
# Check if the script is run with the correct arguments
parser = argparse.ArgumentParser(description="Generate chunk header files")
@@ -83,8 +82,8 @@ for chunkY in range(mapData['mapHeightInRealChunks']):
f.write(" {\n")
f.write(f" .id = {entity['id']},\n")
f.write(f" .type = {entity['type']},\n")
f.write(f" .x = {floatToFixed248(entity['x'])},\n")
f.write(f" .y = {floatToFixed248(entity['y'])},\n")
f.write(f" .x = {round(entity['x'] / TILE_WIDTH_HEIGHT)},\n")
f.write(f" .y = {round(entity['y'] / TILE_WIDTH_HEIGHT)},\n")
if 'dir' in entity:
f.write(f" .dir = {entity['dir']},\n")
@@ -128,8 +127,8 @@ with open(headerPath, 'w') as f:
f.write(f"#define WORLD_HEIGHT {worldHeight}\n")
# Write out other global variables.
f.write(f"#define WORLD_PLAYER_SPAWN_X ((float_t){floatToFixed248(mapData['playerSpawnX'])})\n")
f.write(f"#define WORLD_PLAYER_SPAWN_Y ((float_t){floatToFixed248(mapData['playerSpawnY'])})\n")
f.write(f"#define WORLD_PLAYER_SPAWN_X ({round(mapData['playerSpawnX'] / TILE_WIDTH_HEIGHT)})\n")
f.write(f"#define WORLD_PLAYER_SPAWN_Y ({round(mapData['playerSpawnY'] / TILE_WIDTH_HEIGHT)})\n")
f.write("\n")