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

@@ -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")