nalaganje tiled mape. ozadje ni OK.

This commit is contained in:
2025-12-27 04:04:24 +01:00
parent 875eb0516a
commit f8d533465b
11 changed files with 1891 additions and 1081 deletions

179
scripts/generate_128_map.py Normal file
View File

@@ -0,0 +1,179 @@
import json
import os
# Configuration
WIDTH = 128
HEIGHT = 128
TILE_SIZE = 32
# Create the data array (128x128 filled with 1s for 'Ground' tile)
# 1 = Grass tile from firstgid:1
ground_data = [1] * (WIDTH * HEIGHT)
# Create Objects layer (mostly 0s, with some trees/rocks at center)
objects_data = [0] * (WIDTH * HEIGHT)
# Create Player layer (mostly 0s, with Kai at center)
player_data = [0] * (WIDTH * HEIGHT)
# Center coordinates
cx, cy = WIDTH // 2, HEIGHT // 2
# Helper to set tile at x,y
def set_tile(layer_data, x, y, gid):
index = y * WIDTH + x
if 0 <= index < len(layer_data):
layer_data[index] = gid
# Place some test objects (from 02_Obstacles, firstgid=300)
set_tile(objects_data, cx, cy, 300) # Test Object 1
set_tile(objects_data, cx+2, cy, 301) # Test Object 2
set_tile(objects_data, cx-2, cy, 302) # Test Object 3
set_tile(objects_data, cx, cy-2, 303) # Test Object 4
# Place Player (Kai)
# Assuming FirstGID 1500 for Kai characters
# Tile 41 corresponds to "Front View" typically in a standard grid (relative index starts at 0, so GID = firstgid + 41)
set_tile(player_data, cx, cy, 1541)
map_structure = {
"compressionlevel": -1,
"height": HEIGHT,
"infinite": False,
"layers": [
{
"data": ground_data,
"height": HEIGHT,
"id": 1,
"name": "Ground",
"opacity": 1,
"type": "tilelayer",
"visible": True,
"width": WIDTH,
"x": 0,
"y": 0
},
{
"data": objects_data,
"height": HEIGHT,
"id": 2,
"name": "Objects",
"opacity": 1,
"type": "tilelayer",
"visible": True,
"width": WIDTH,
"x": 0,
"y": 0
},
{
"data": player_data,
"height": HEIGHT,
"id": 3,
"name": "Player",
"opacity": 1,
"type": "tilelayer",
"visible": True,
"width": WIDTH,
"x": 0,
"y": 0
}
],
"nextlayerid": 4,
"nextobjectid": 1,
"orientation": "orthogonal",
"renderorder": "right-down",
"tiledversion": "1.11.2",
"tileheight": TILE_SIZE,
"tilesets": [
{
"columns": 16,
"firstgid": 1,
"image": "../narezano_in_majhno/krvava_zetev_sprites/grass_soil_tileset_1766171156780_obdelan.png",
"imageheight": 512,
"imagewidth": 512,
"margin": 0,
"name": "01_Ground",
"spacing": 0,
"tilecount": 256,
"tileheight": 32,
"tilewidth": 32
},
{
"columns": 16,
"firstgid": 300,
"image": "../narezano_in_majhno/krvava_zetev_sprites/farm_obstacles_1766171194583_obdelan.png",
"imageheight": 512,
"imagewidth": 512,
"margin": 0,
"name": "02_Obstacles",
"spacing": 0,
"tilecount": 256,
"tileheight": 32,
"tilewidth": 32
},
{
"columns": 16,
"firstgid": 600,
"image": "../narezano_in_majhno/krvava_zetev_sprites/town_buildings_pack_1766099810580_obdelan.png",
"imageheight": 512,
"imagewidth": 512,
"margin": 0,
"name": "04_Buildings",
"spacing": 0,
"tilecount": 256,
"tileheight": 32,
"tilewidth": 32
},
{
"columns": 16,
"firstgid": 900,
"image": "../narezano_in_majhno/krvava_zetev_sprites/fence_tileset_1766171177275_obdelan.png",
"imageheight": 512,
"imagewidth": 512,
"margin": 0,
"name": "03_Fences",
"spacing": 0,
"tilecount": 256,
"tileheight": 32,
"tilewidth": 32
},
{
"columns": 16,
"firstgid": 1200,
"image": "../narezano_in_majhno/krvava_zetev_sprites/tools_items_pack_tiled_1766099926620_obdelan.png",
"imageheight": 512,
"imagewidth": 512,
"margin": 0,
"name": "05_Tools_Items",
"spacing": 0,
"tilecount": 256,
"tileheight": 32,
"tilewidth": 32
},
{
"columns": 10,
"firstgid": 1500,
"image": "../krvava_zetev_sprites/kai_character_2x2_grid_1766098341666.png",
"imageheight": 1024,
"imagewidth": 1024,
"margin": 0,
"name": "Kai_Character",
"spacing": 0,
"tilecount": 100,
"tileheight": 96,
"tilewidth": 96
}
],
"tilewidth": TILE_SIZE,
"type": "map",
"version": "1.10",
"width": WIDTH
}
output_path = "assets/maps/NovaFarma.json"
with open(output_path, "w") as f:
json.dump(map_structure, f, indent=4)
print(f"✅ Generated 128x128 map with Kai: {output_path}")