Starting on shaped tile hitboxes

This commit is contained in:
2025-06-19 23:49:53 -05:00
parent 6b16c97c64
commit 1022f45565
17 changed files with 360 additions and 48 deletions

View File

@ -422,7 +422,7 @@ with open(headerPath, 'w') as f:
for i in range(worldHeight):
f.write(" ")
for j in range(worldWidth):
if (j, i) in chunksDone:
if(j, i) in chunksDone:
f.write(f"&CHUNK_{j}_{i}, ")
else:
f.write("NULL, ")

View File

@ -0,0 +1,21 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
find_package(Python3 COMPONENTS Interpreter REQUIRED)
# Custom command to generate all header files
add_custom_target(DUSK_CHUNKS
# OUTPUT ${DUSK_GENERATED_HEADERS_DIR}/world/world.h
COMMAND
${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mapcompile.py
--output ${DUSK_GENERATED_HEADERS_DIR}
--input ${DUSK_DATA_DIR}/map.tmj
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mapcompile.py
COMMENT "Generating chunk header files"
VERBATIM
)
# Ensure headers are generated before compiling main
add_dependencies(${DUSK_TARGET_NAME} DUSK_CHUNKS)

View File

@ -0,0 +1,32 @@
import sys, os
import argparse
from datetime import datetime
import json
import math
# Check if the script is run with the correct arguments
parser = argparse.ArgumentParser(description="Generate chunk header files")
parser.add_argument('--output', required=True, help='Dir to output headers')
parser.add_argument('--input', required=True, help='Input JSON file from tiled')
args = parser.parse_args()
# Ensure outdir exists
outputDir = args.output
os.makedirs(outputDir, exist_ok=True)
# Create world directory if it does not exist
worldDir = os.path.join(outputDir, "world")
os.makedirs(worldDir, exist_ok=True)
# Some vars used during printing
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Read the input JSON file
inputFile = args.input
if not os.path.isfile(inputFile):
print(f"Error: Input file '{inputFile}' does not exist.")
sys.exit(1)
with open(inputFile, 'r') as f:
data = json.load(f)