hot entity on entity action

This commit is contained in:
2025-06-19 09:55:56 -05:00
parent 04158a1ad2
commit 78837b3212
14 changed files with 414 additions and 86 deletions

View File

@ -9,8 +9,8 @@ CHUNK_WIDTH = 8
CHUNK_HEIGHT = 8
CHUNK_TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT
CHUNK_ENTITY_COUNT_MAX = 8
TILE_WIDTH = 16
TILE_HEIGHT = 16
TILE_WIDTH_HEIGHT = 16
TILE_WIDTH_HEIGHT = 16
ENTITY_TYPE_MAP = {
"npc": "ENTITY_TYPE_NPC",
@ -194,11 +194,11 @@ for obIndex, ob in enumerate(objectLayer['objects']):
print(f"Error: Object in object layer does not contain 'x' or 'y' key.")
sys.exit(1)
ob['x'] -= inputMapLowestX * TILE_WIDTH
ob['y'] -= inputMapLowestY * TILE_HEIGHT
ob['x'] -= inputMapLowestX * TILE_WIDTH_HEIGHT
ob['y'] -= inputMapLowestY * TILE_WIDTH_HEIGHT
# Objects are bottom aligned in tiled, so we need to adjust the Y coordinate.
ob['y'] -= TILE_HEIGHT
ob['y'] -= TILE_WIDTH_HEIGHT
# Round off the coordinates
ob['x'] = round(ob['x'])
@ -281,13 +281,13 @@ for chunkY in range(mapHeightInRealChunks):
sys.exit(1)
# Is this object within the chunk?
if ob['x'] < topLeftTileX * TILE_WIDTH:
if ob['x'] < topLeftTileX * TILE_WIDTH_HEIGHT:
continue
if ob['x'] >= (topLeftTileX + CHUNK_WIDTH) * TILE_WIDTH:
if ob['x'] >= (topLeftTileX + CHUNK_WIDTH) * TILE_WIDTH_HEIGHT:
continue
if ob['y'] < topLeftTileY * TILE_HEIGHT:
if ob['y'] < topLeftTileY * TILE_WIDTH_HEIGHT:
continue
if ob['y'] >= (topLeftTileY + CHUNK_HEIGHT) * TILE_HEIGHT:
if ob['y'] >= (topLeftTileY + CHUNK_HEIGHT) * TILE_WIDTH_HEIGHT:
continue
entities.append(ob)
@ -372,8 +372,8 @@ for chunkY in range(mapHeightInRealChunks):
f.write(f" .entities = {{\n")
for entity in entities:
# Entities are center aligned in tiled.
localX = round(entity['x'] - (topLeftTileX * TILE_WIDTH))
localY = round(entity['y'] - (topLeftTileY * TILE_HEIGHT))
localX = round(entity['x'] - (topLeftTileX * TILE_WIDTH_HEIGHT))
localY = round(entity['y'] - (topLeftTileY * TILE_WIDTH_HEIGHT))
if 'type' in entity and entity['type'] not in ENTITY_TYPE_MAP:
continue