ok
This commit is contained in:
40
scripts/expand_tilesets.py
Normal file
40
scripts/expand_tilesets.py
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import os
|
||||
from PIL import Image
|
||||
|
||||
TERRAIN_PATH = "assets/slike/teren"
|
||||
|
||||
def expand_image(filename, copies=4):
|
||||
path = os.path.join(TERRAIN_PATH, filename)
|
||||
if not os.path.exists(path):
|
||||
print(f"Skipping {filename}, not found.")
|
||||
return
|
||||
|
||||
try:
|
||||
img = Image.open(path)
|
||||
original_w, original_h = img.size
|
||||
|
||||
new_w = original_w * copies
|
||||
new_h = original_h * copies
|
||||
|
||||
new_img = Image.new('RGBA', (new_w, new_h))
|
||||
|
||||
# Tile it
|
||||
for x in range(copies):
|
||||
for y in range(copies):
|
||||
new_img.paste(img, (x * original_w, y * original_h))
|
||||
|
||||
output_name = filename.replace(".png", "_atlas.png")
|
||||
output_path = os.path.join(TERRAIN_PATH, output_name)
|
||||
new_img.save(output_path)
|
||||
print(f"✅ Created {output_name} ({new_w}x{new_h})")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error expanding {filename}: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Expand main tilesets likely to be used in large maps
|
||||
expand_image("grass.png", copies=4) # 512*4 = 2048 (covers GIDs up to ~1700)
|
||||
expand_image("dirt.png", copies=4)
|
||||
expand_image("stone.png", copies=4)
|
||||
expand_image("water.png", copies=4)
|
||||
Reference in New Issue
Block a user