initial upload
BIN
tools/spritesheet_creator/input/map_buildings/Church.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
tools/spritesheet_creator/input/map_buildings/Church5.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Brambles1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/BrownHills1.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/BrownHills2.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Brush1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Brush2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Brush3.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Desert1.png
Normal file
|
After Width: | Height: | Size: 8 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Desert2.png
Normal file
|
After Width: | Height: | Size: 8 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/DesertScrub1.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/DesertScrub2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/DesertScrub4.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Grass1.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Grass2.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Grass3.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Hills1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Hills3.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/HillsGreen1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/HillsGreen2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/HillsGreen3.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Lake1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Lake2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LightGrass1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LightGrass2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LowHills1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LowHills2.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LowHills3.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/LowHills4.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mountains1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mountains2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mountains5.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mud1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mud2.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Mud3.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Ocean1.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Ocean2.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Orchards1.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Orchards2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Rough1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Rough2.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/SaltBush1.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/SaltBush2.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Snow1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Snow2.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Water1.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Water2.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Woods1.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/Woods2.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/WoodsDark1.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
tools/spritesheet_creator/input/map_hex_terrain/WoodsDark2.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
tools/spritesheet_creator/input/ui/hex_cursor.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
52
tools/spritesheet_creator/mapping.txt
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
x_col,y_col,tilename
|
||||
0,0,Brambles1
|
||||
0,1,Mud2
|
||||
0,2,Water2
|
||||
0,3,BrownHills2
|
||||
0,4,BoulderHills1
|
||||
0,5,LowHills2
|
||||
0,6,BrownHills1
|
||||
0,7,DesertScrub1
|
||||
1,0,Lake1
|
||||
1,1,Orchards1
|
||||
1,2,HillsGreen3
|
||||
1,3,LowHills4
|
||||
1,4,Brush2
|
||||
1,5,Grass2
|
||||
1,6,Snow2
|
||||
1,7,Water1
|
||||
2,0,Mud3
|
||||
2,1,Woods2
|
||||
2,2,Rough2
|
||||
2,3,Snow1
|
||||
2,4,Ocean1
|
||||
2,5,Desert1
|
||||
2,6,HillsGreen2
|
||||
2,7,Lake2
|
||||
3,0,WoodsDark2
|
||||
3,1,Brush1
|
||||
3,2,Desert2
|
||||
3,3,Mud1
|
||||
3,4,Rough1
|
||||
3,5,Hills1
|
||||
3,6,WoodsDark1
|
||||
3,7,LightGrass1
|
||||
4,0,Mountains2
|
||||
4,1,Mountains1
|
||||
4,2,Mountains5
|
||||
4,3,Woods1
|
||||
4,4,Hills3
|
||||
4,5,Ocean2
|
||||
4,6,Brush3
|
||||
4,7,LowHills3
|
||||
5,0,LightGrass2
|
||||
5,1,SaltBush2
|
||||
5,2,HillsGreen1
|
||||
5,3,Orchards2
|
||||
5,4,Grass3
|
||||
5,5,LowHills1
|
||||
5,6,SaltBush1
|
||||
5,7,Grass1
|
||||
6,0,Church5
|
||||
6,1,DesertScrub4
|
||||
6,2,DesertScrub2
|
||||
17
tools/spritesheet_creator/mapping.txt.import
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[remap]
|
||||
|
||||
importer="csv_translation"
|
||||
type="Translation"
|
||||
uid="uid://eowm7vera01u"
|
||||
|
||||
[deps]
|
||||
|
||||
files=["res://tools/spritesheet_creator/mapping.y.translation", "res://tools/spritesheet_creator/mapping.tilename.translation"]
|
||||
|
||||
source_file="res://tools/spritesheet_creator/mapping.csv"
|
||||
dest_files=["res://tools/spritesheet_creator/mapping.y.translation", "res://tools/spritesheet_creator/mapping.tilename.translation"]
|
||||
|
||||
[params]
|
||||
|
||||
compress=true
|
||||
delimiter=0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
x_col,y_col,tilename
|
||||
0,0,Church5
|
||||
1,0,Church
|
||||
|
After Width: | Height: | Size: 13 KiB |
|
|
@ -0,0 +1,51 @@
|
|||
x_col,y_col,tilename
|
||||
0,0,SaltBush2
|
||||
1,0,Snow1
|
||||
2,0,Hills3
|
||||
3,0,LightGrass2
|
||||
4,0,Brush3
|
||||
5,0,Orchards2
|
||||
6,0,Brush2
|
||||
7,0,Rough2
|
||||
0,1,HillsGreen3
|
||||
1,1,Woods1
|
||||
2,1,LowHills1
|
||||
3,1,HillsGreen1
|
||||
4,1,Brush1
|
||||
5,1,LowHills3
|
||||
6,1,LowHills2
|
||||
7,1,DesertScrub4
|
||||
0,2,Mud1
|
||||
1,2,Grass1
|
||||
2,2,Orchards1
|
||||
3,2,Hills1
|
||||
4,2,Mountains2
|
||||
5,2,BrownHills1
|
||||
6,2,Water2
|
||||
7,2,Lake2
|
||||
0,3,SaltBush1
|
||||
1,3,Water1
|
||||
2,3,Lake1
|
||||
3,3,Desert2
|
||||
4,3,Mud3
|
||||
5,3,BoulderHills1
|
||||
6,3,Mountains5
|
||||
7,3,Grass3
|
||||
0,4,Grass2
|
||||
1,4,Desert1
|
||||
2,4,Mud2
|
||||
3,4,BrownHills2
|
||||
4,4,Brambles1
|
||||
5,4,HillsGreen2
|
||||
6,4,Ocean2
|
||||
7,4,WoodsDark2
|
||||
0,5,DesertScrub2
|
||||
1,5,WoodsDark1
|
||||
2,5,DesertScrub1
|
||||
3,5,Woods2
|
||||
4,5,Ocean1
|
||||
5,5,Rough1
|
||||
6,5,LightGrass1
|
||||
7,5,Mountains1
|
||||
0,6,Snow2
|
||||
1,6,LowHills4
|
||||
|
After Width: | Height: | Size: 496 KiB |
2
tools/spritesheet_creator/output/ui_72x72_mapping.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
x_col,y_col,tilename
|
||||
0,0,hex_cursor
|
||||
BIN
tools/spritesheet_creator/output/ui_72x72_spritesheet.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
116
tools/spritesheet_creator/spritesheet_creator.py
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import pygame
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def create_spritesheet(image_paths, output_path, rows=1, padding=0):
|
||||
"""
|
||||
Combine multiple images into a single spritesheet.
|
||||
|
||||
Args:
|
||||
image_paths (list): List of paths to source images
|
||||
output_path (str): Path to save the combined spritesheet
|
||||
rows (int): Number of rows in the spritesheet
|
||||
padding (int): Pixel padding between images
|
||||
"""
|
||||
if not image_paths:
|
||||
raise ValueError("No images provided")
|
||||
|
||||
# Load all images
|
||||
images = []
|
||||
max_width = 0
|
||||
max_height = 0
|
||||
|
||||
for path in image_paths:
|
||||
try:
|
||||
img = pygame.image.load(path)#.convert_alpha()
|
||||
images.append(img)
|
||||
max_width = max(max_width, img.get_width())
|
||||
max_height = max(max_height, img.get_height())
|
||||
except pygame.error as e:
|
||||
print(f"Failed to load {path}: {e}")
|
||||
continue
|
||||
|
||||
if not images:
|
||||
raise ValueError("No valid images loaded")
|
||||
|
||||
# Calculate spritesheet dimensions
|
||||
cols = (len(images) + rows - 1) // rows
|
||||
sheet_width = cols * (max_width + padding) - padding
|
||||
sheet_height = rows * (max_height + padding) - padding
|
||||
|
||||
# Create blank spritesheet surface
|
||||
spritesheet = pygame.Surface((sheet_width, sheet_height), pygame.SRCALPHA)
|
||||
|
||||
# Blit images onto spritesheet
|
||||
for i, img in enumerate(images):
|
||||
row = i // cols
|
||||
col = i % cols
|
||||
x = col * (max_width + padding)
|
||||
y = row * (max_height + padding)
|
||||
spritesheet.blit(img, (x, y))
|
||||
|
||||
# Save the spritesheet
|
||||
print(f"dir: {os.getcwd()}")
|
||||
pygame.image.save(spritesheet, output_path)
|
||||
print(f"Spritesheet saved to {output_path}")
|
||||
|
||||
return max_width, max_height
|
||||
|
||||
|
||||
|
||||
|
||||
pygame.init()
|
||||
|
||||
tool_root_dir = os.getcwd()
|
||||
|
||||
# Because os.rmdir() only works on empty directories
|
||||
if os.path.isdir(f"{tool_root_dir}/output"): shutil.rmtree(f"{tool_root_dir}/output")
|
||||
os.mkdir(f"{tool_root_dir}/output")
|
||||
|
||||
spritesheet_names = os.listdir(f"{tool_root_dir}/input")
|
||||
|
||||
for spritesheet_name in spritesheet_names:
|
||||
|
||||
source_dir=f"{tool_root_dir}/input/{spritesheet_name}"
|
||||
target_dir=f"{tool_root_dir}/output/"
|
||||
|
||||
filenames = os.listdir(f"{source_dir}")
|
||||
|
||||
# List of image paths to combine
|
||||
image_files = filenames
|
||||
|
||||
cols=8
|
||||
rows=len(image_files)//cols + 1
|
||||
|
||||
print(f"Dir: {os.getcwd()}")
|
||||
print(f"Target: {target_dir}")
|
||||
|
||||
## Create and save spritesheet
|
||||
os.chdir(source_dir)
|
||||
(tile_width, tile_height) = create_spritesheet(image_files, f"{target_dir}/{spritesheet_name}_spritesheet.png", rows, padding=1)
|
||||
spritesheet_filename = f"{target_dir}/{spritesheet_name}_{tile_width}x{tile_height}_spritesheet.png"
|
||||
os.rename(f"{target_dir}/{spritesheet_name}_spritesheet.png", spritesheet_filename)
|
||||
|
||||
## Create+Store metadata
|
||||
mapping = ["x_col,y_col,tilename"]
|
||||
|
||||
for index, filename in enumerate(image_files):
|
||||
#x_col = index // cols
|
||||
#y_row = index - x_col * cols
|
||||
y_row = index // cols
|
||||
x_col = index - y_row * cols
|
||||
|
||||
print(f"[{spritesheet_name}] : {index} - [{x_col},{y_row}] -> {filename}")
|
||||
tilename = filename.split(".")[0]
|
||||
mapping.append( f"{x_col},{y_row},{tilename}" )
|
||||
|
||||
print(f"Wrote {spritesheet_filename}")
|
||||
|
||||
|
||||
mapping_filename = f"{target_dir}/{spritesheet_name}_{tile_width}x{tile_height}_mapping.txt"
|
||||
f = open(mapping_filename,"w")
|
||||
f.write("\n".join(mapping))
|
||||
f.close()
|
||||
print(f"Wrote {mapping_filename}")
|
||||
|
||||
os.chdir(f"{tool_root_dir}")
|
||||