Starting on shaped tile hitboxes
This commit is contained in:
@ -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, ")
|
||||
|
21
tools/tilecompile/CMakeLists.txt
Normal file
21
tools/tilecompile/CMakeLists.txt
Normal 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)
|
32
tools/tilecompile/tilecompile.py
Normal file
32
tools/tilecompile/tilecompile.py
Normal 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)
|
||||
|
Reference in New Issue
Block a user