Files
novafarma/tools/fix_tiled_map.py
NovaFarma Dev a4d795c561 Tiled Map Setup: Ground tiles, ruins & automated asset processing
Features:
- Resized 4513 PNG assets to 40% for optimal Tiled performance
- Created comprehensive tileset library (grass, dirt, trees, flowers, ruins, walls)
- Generated 3 test maps: travnik_32x32, zapuscena_vas_48x48, travnik_s_objekti
- Added 9 different ruined building tilesets for TownRestorationSystem integration

 Tools Added:
- resize_assets_for_tiled.py: Batch resize all assets to 40%
- generate_tiled_map.py: Auto-generate maps with placed objects
- fix_tiled_map.py: Create proper tile-based maps

 Structure:
- Slike_za_Tiled/: 4513 resized assets ready for Tiled
- assets/tilesets/: 16 tileset definitions (.tsx files)
- assets/maps/: 3 ready-to-use Tiled maps (.tmx files)

 Documentation:
- docs/TILED_SETUP_GUIDE.md: Complete setup and usage guide

Ready for map design in Tiled Map Editor!
2025-12-24 03:41:40 +01:00

47 lines
1.5 KiB
Python

"""
Generate improved Tiled map with proper tile layers (not objects)
"""
import os
OUTPUT_MAP = r"c:\novafarma\assets\maps\travnik_s_objekti.tmx"
MAP_WIDTH = 32
MAP_HEIGHT = 32
TILE_WIDTH = 48
TILE_HEIGHT = 48
def create_simple_grass_map():
"""Create a simple map with grass ground layer"""
# Create CSV data for ground - all grass (tile ID 1)
ground_data = []
for y in range(MAP_HEIGHT):
row = ["1"] * MAP_WIDTH
ground_data.append(",".join(row))
ground_csv = "\n".join(ground_data)
xml_content = f'''<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.1" orientation="orthogonal" renderorder="right-down" width="{MAP_WIDTH}" height="{MAP_HEIGHT}" tilewidth="{TILE_WIDTH}" tileheight="{TILE_HEIGHT}" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" name="grass_single" tilewidth="48" tileheight="48" tilecount="1" columns="1">
<image source="../../tilesets/grass.png" width="48" height="48"/>
</tileset>
<layer id="1" name="Ground" width="{MAP_WIDTH}" height="{MAP_HEIGHT}">
<data encoding="csv">
{ground_csv}
</data>
</layer>
</map>'''
os.makedirs(os.path.dirname(OUTPUT_MAP), exist_ok=True)
with open(OUTPUT_MAP, 'w', encoding='utf-8') as f:
f.write(xml_content)
print(f"✅ Created simple grass map: {OUTPUT_MAP}")
print(f"📏 Size: {MAP_WIDTH}x{MAP_HEIGHT} tiles")
print(f"🟢 Ground layer: All grass")
print(f"\n🚀 Open in Tiled to see the grass!")
if __name__ == "__main__":
create_simple_grass_map()