Files
mice/tools/lpc_extract/extract.py
T
Matteo Benedetto e26464d843 Merge origin/new-newnassets: new LPC rat assets and animations
Cherry-picked from new-newnassets (3 commits):
- bdf5a8d Add new start animation asset for game launch
- 5f2d09f Fix rat animations and restore map tiles
- 2e2c5bb feat: add LPC-style rat assets, sprite generation scripts, and grid extraction tools

Conflicts resolved:
- engine/sdl2.py: kept 'if scale:' wrapper (compatible, default scale=True)
- units/rat.py: kept animation frame computation (partial_move * 4)
- 12 PNG files (BMP_BABY/MALE/FEMALE_*): kept new-newnassets versions

Cleanup applied: removed ~480 working artifacts not appropriate for the
production repo:
- 25 PNG in repo root (male_rats*.png, spritesheet*.png)
- 416 tile extracts in tools/lpc_extract/grid/
- scattered debug PNGs (bushes, preview, montages, etc.)
- early iteration scripts (animate_rat v1-v4, restyle v2-v10, etc.)

Kept: 32 new LPC-style sprites in assets/Rat_LPC_Style/, 4 animation
sprite sheets in assets/Rat_Animated/, 64 updated Rat sprites, 22
final-version generator scripts, plus all .py/.md updates.
2026-06-27 17:53:45 +02:00

36 lines
1.3 KiB
Python

from PIL import Image
# Load the source image
src_img = Image.open('/home/enne2/dev/asset-maker/assets/poses/sources/lpc-revised/Terrain/terrain_spring.png').convert('RGBA')
# Define a function to extract a 32x32 tile and scale it to 64x64
def get_tile(tx, ty):
box = (tx * 32, ty * 32, (tx + 1) * 32, (ty + 1) * 32)
img = src_img.crop(box)
return img.resize((64, 64), Image.NEAREST)
# Create a dictionary of the files to create and their corresponding tiles
# Using some standard LPC terrain coordinates as a guess
tiles = {
'BMP_1_GRASS_1.png': get_tile(4, 1), # center of grass-on-dirt
'BMP_1_GRASS_2.png': get_tile(4, 1),
'BMP_1_GRASS_3.png': get_tile(4, 1),
'BMP_1_GRASS_4.png': get_tile(4, 1),
# Let's extract some path edges for N, S, E, W
'BMP_1_N.png': get_tile(4, 0), # Top edge of grass (dirt above)
'BMP_1_S.png': get_tile(4, 2), # Bottom edge
'BMP_1_E.png': get_tile(5, 1), # Right edge
'BMP_1_W.png': get_tile(3, 1), # Left edge
# Corners
'BMP_1_NW.png': get_tile(3, 0),
'BMP_1_NE.png': get_tile(5, 0),
'BMP_1_SW.png': get_tile(3, 2),
'BMP_1_SE.png': get_tile(5, 2),
}
for name, img in tiles.items():
img.save('/home/enne2/dev/mice/tools/lpc_extract/' + name)
print(f"Saved {name}")