Files
mice/tools/lpc_extract/generate_all.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

91 lines
3.3 KiB
Python

from PIL import Image, ImageDraw
import os
src_img = Image.open('/home/enne2/dev/asset-maker/assets/poses/sources/lpc-revised/Terrain/terrain_spring.png').convert('RGBA')
out_dir = '/home/enne2/dev/mice/assets/Rat'
def get_tile(tx, ty):
box = (tx * 32, ty * 32, (tx + 1) * 32, (ty + 1) * 32)
return src_img.crop(box)
def scale(img):
return img.resize((64, 64), Image.NEAREST)
# Grass variations (just use the same grass for now)
grass = get_tile(4, 1)
grass_scaled = scale(grass)
grass_scaled.save(os.path.join(out_dir, 'BMP_1_GRASS_1.png'))
grass_scaled.save(os.path.join(out_dir, 'BMP_1_GRASS_2.png'))
grass_scaled.save(os.path.join(out_dir, 'BMP_1_GRASS_3.png'))
grass_scaled.save(os.path.join(out_dir, 'BMP_1_GRASS_4.png'))
# Paths
paths = {
'BMP_1_N.png': (4, 0),
'BMP_1_S.png': (4, 2),
'BMP_1_E.png': (5, 1),
'BMP_1_W.png': (3, 1),
'BMP_1_NE.png': (5, 0),
'BMP_1_NW.png': (3, 0),
'BMP_1_SE.png': (5, 2),
'BMP_1_SW.png': (3, 2),
'BMP_1_WN.png': (3, 3), # dirt bottom-right
'BMP_1_WS.png': (3, 4), # dirt top-right
'BMP_1_EN.png': (4, 3), # dirt bottom-left
'BMP_1_ES.png': (4, 4), # dirt top-left
}
for name, (tx, ty) in paths.items():
scale(get_tile(tx, ty)).save(os.path.join(out_dir, name))
# Flowers - draw simple flowers on grass
def make_flower(color, positions):
img = grass.copy()
draw = ImageDraw.Draw(img)
for px, py in positions:
draw.rectangle([px, py, px+2, py+2], fill=color)
return scale(img)
make_flower((255, 255, 255), [(16, 16), (10, 20), (22, 10)]).save(os.path.join(out_dir, 'BMP_1_FLOWER_1.png')) # white
make_flower((255, 0, 0), [(10, 10), (20, 20), (14, 26)]).save(os.path.join(out_dir, 'BMP_1_FLOWER_2.png')) # red
make_flower((255, 100, 200), [(16, 16)]).save(os.path.join(out_dir, 'BMP_1_FLOWER_3.png')) # pink
make_flower((100, 200, 255), [(8, 8), (24, 24)]).save(os.path.join(out_dir, 'BMP_1_FLOWER_4.png')) # blue
# Caves - draw black hole on dirt (tx=7, ty=1)
dirt = get_tile(7, 1)
def make_cave(direction):
img = dirt.copy()
draw = ImageDraw.Draw(img)
if direction == 'UP':
draw.pieslice([8, -16, 24, 16], 0, 180, fill=(0,0,0))
elif direction == 'DOWN':
draw.pieslice([8, 16, 24, 48], 180, 360, fill=(0,0,0))
elif direction == 'LEFT':
draw.pieslice([-16, 8, 16, 24], 270, 90, fill=(0,0,0))
elif direction == 'RIGHT':
draw.pieslice([16, 8, 48, 24], 90, 270, fill=(0,0,0))
return scale(img)
make_cave('UP').save(os.path.join(out_dir, 'BMP_1_CAVE_UP.png'))
make_cave('DOWN').save(os.path.join(out_dir, 'BMP_1_CAVE_DOWN.png'))
make_cave('LEFT').save(os.path.join(out_dir, 'BMP_1_CAVE_LEFT.png'))
make_cave('RIGHT').save(os.path.join(out_dir, 'BMP_1_CAVE_RIGHT.png'))
# Gas and Explosion
def make_fx(color, is_gas=False):
img = grass.copy()
draw = ImageDraw.Draw(img)
if is_gas:
draw.ellipse([4, 4, 28, 28], fill=(200, 200, 200, 200))
draw.ellipse([8, 8, 20, 20], fill=(255, 255, 255, 220))
else:
draw.ellipse([4, 4, 28, 28], fill=(255, 100, 0, 255))
draw.ellipse([8, 8, 20, 20], fill=(255, 255, 0, 255))
return scale(img)
for d in ['UP', 'DOWN', 'LEFT', 'RIGHT']:
make_fx(None, True).save(os.path.join(out_dir, f'BMP_1_GAS_{d}.png'))
make_fx(None, False).save(os.path.join(out_dir, f'BMP_1_EXPLOSION_{d}.png'))
print("All 32 files generated.")