"""Generator for underworld_portraits and rat_race assets in Assembler Casino. Follows the standard 3-tier art pipeline: 1. Master sprite sheets in assets/sprites/hall/ - underworld-portraits-v1.png (11 slots, 256x256) - rat-race-v1.png (4x5 grid, 128x128) - prompts-v10.json (metadata) 2. Compiled binary packs in assets/animations/hall/ - underworld_portraits.bin (ANM1 BGRA, 11 frames of 256x256) - rat_race.bin (ANM1 BGRA, 17 frames of 128x128) - manifest-v5.json 3. Developer contact sheet previews in build/hall/ - underworld_portraits.bin.png - rat_race.bin.png """ import json import math import struct from pathlib import Path from PIL import Image, ImageDraw ROOT = Path(__file__).resolve().parents[2] SPRITES_DIR = ROOT / "assets/sprites/hall" ANIM_DIR = ROOT / "assets/animations/hall" BUILD_DIR = ROOT / "build/hall" def write_pack(filename, frames): w, h = frames[0].size payload = b"".join(f.tobytes("raw", "BGRA") for f in frames) hdr = struct.pack("<4sIIII", b"ANM1", w, h, len(frames), len(payload)) (ANIM_DIR / filename).write_bytes(hdr + payload) print(f"Wrote {ANIM_DIR / filename} ({len(frames)} frames of {w}x{h})") def save_preview(filename, frames, cols=4): w, h = frames[0].size rows = (len(frames) + cols - 1) // cols preview = Image.new("RGBA", (cols * w, rows * h), (25, 29, 31, 255)) for idx, f in enumerate(frames): cx = (idx % cols) * w cy = (idx // cols) * h preview.alpha_composite(f, (cx, cy)) out_path = BUILD_DIR / filename preview.save(out_path) print(f"Saved preview: {out_path} ({preview.width}x{preview.height})") def main(): SPRITES_DIR.mkdir(parents=True, exist_ok=True) ANIM_DIR.mkdir(parents=True, exist_ok=True) BUILD_DIR.mkdir(parents=True, exist_ok=True) # ========================================================================= # 1. underworld_portraits (256x256, 11 frames) # ========================================================================= portraits = [] # Frame 0: Semyon (Loan Shark) f0 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d0 = ImageDraw.Draw(f0) d0.polygon([(40, 256), (80, 150), (128, 140), (176, 150), (216, 256)], fill=(32, 28, 26, 255)) d0.polygon([(78, 150), (105, 210), (128, 180), (151, 210), (178, 150), (128, 140)], fill=(48, 42, 38, 255)) d0.polygon([(110, 150), (128, 210), (146, 150)], fill=(18, 16, 15, 255)) d0.line([(128, 170), (128, 256)], fill=(180, 155, 60, 255), width=3) d0.ellipse([124, 166, 132, 174], fill=(220, 190, 80, 255)) d0.rectangle([112, 120, 144, 150], fill=(185, 130, 95, 255)) d0.rectangle([98, 70, 158, 135], fill=(210, 150, 110, 255)) d0.rectangle([104, 108, 152, 133], fill=(170, 125, 95, 255)) d0.line([(106, 85), (122, 87)], fill=(40, 30, 25, 255), width=3) d0.line([(134, 87), (150, 85)], fill=(40, 30, 25, 255), width=3) d0.rectangle([110, 90, 118, 95], fill=(20, 20, 20, 255)) d0.rectangle([138, 90, 146, 95], fill=(20, 20, 20, 255)) d0.point([(114, 91), (142, 91)], fill=(255, 255, 255, 255)) d0.line([(126, 122), (105, 128)], fill=(230, 230, 220, 255), width=3) d0.rectangle([103, 127, 106, 130], fill=(255, 80, 20, 255)) d0.line([(103, 126), (98, 115), (92, 112), (95, 98), (90, 88)], fill=(180, 180, 190, 140), width=2) d0.polygon([(82, 70), (128, 42), (174, 70), (180, 80), (76, 80)], fill=(45, 42, 40, 255)) d0.polygon([(70, 78), (128, 74), (186, 78), (176, 86), (80, 86)], fill=(25, 24, 23, 255)) d0.line([(80, 76), (176, 76)], fill=(120, 30, 30, 255), width=3) portraits.append(f0) # Frame 1: Collector Thug f1 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d1 = ImageDraw.Draw(f1) d1.polygon([(20, 256), (60, 120), (128, 110), (196, 120), (236, 256)], fill=(24, 26, 32, 255)) d1.polygon([(85, 120), (128, 170), (171, 120)], fill=(45, 48, 55, 255)) d1.rectangle([104, 95, 152, 125], fill=(175, 120, 85, 255)) d1.polygon([(90, 45), (128, 35), (166, 45), (160, 115), (96, 115)], fill=(195, 135, 95, 255)) d1.polygon([(92, 45), (128, 33), (164, 45), (162, 58), (94, 58)], fill=(60, 50, 45, 255)) d1.line([(100, 70), (120, 75)], fill=(35, 30, 30, 255), width=4) d1.line([(136, 75), (156, 70)], fill=(35, 30, 30, 255), width=4) d1.rectangle([106, 78, 116, 83], fill=(15, 15, 15, 255)) d1.rectangle([140, 78, 150, 83], fill=(15, 15, 15, 255)) d1.line([(102, 58), (118, 92)], fill=(160, 80, 70, 255), width=2) d1.rectangle([112, 100, 144, 106], fill=(50, 35, 30, 255)) portraits.append(f1) # Frame 2: Pit Boss f2 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d2 = ImageDraw.Draw(f2) d2.polygon([(40, 256), (75, 140), (128, 130), (181, 140), (216, 256)], fill=(15, 18, 25, 255)) d2.polygon([(105, 130), (128, 190), (151, 130)], fill=(235, 235, 240, 255)) d2.polygon([(124, 140), (128, 210), (132, 140)], fill=(180, 20, 30, 255)) d2.polygon([(160, 165), (175, 165), (178, 180), (167, 192), (157, 180)], fill=(235, 190, 40, 255)) d2.rectangle([110, 100, 146, 130], fill=(215, 160, 125, 255)) d2.rectangle([98, 50, 158, 110], fill=(225, 170, 135, 255)) d2.polygon([(94, 52), (128, 30), (162, 52), (158, 70), (98, 70)], fill=(30, 25, 20, 255)) d2.polygon([(102, 68), (122, 68), (120, 84), (104, 84)], fill=(40, 140, 180, 255)) d2.polygon([(134, 68), (154, 68), (152, 84), (136, 84)], fill=(40, 140, 180, 255)) d2.line([(122, 72), (134, 72)], fill=(220, 190, 50, 255), width=2) d2.line([(114, 98), (142, 98)], fill=(100, 50, 40, 255), width=2) d2.line([(156, 75), (164, 85), (162, 95), (168, 115), (164, 135)], fill=(180, 190, 200, 200), width=2) portraits.append(f2) # Frame 3: Vault Safe Dial f3 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d3 = ImageDraw.Draw(f3) d3.ellipse([18, 18, 238, 238], fill=(65, 70, 75, 255), outline=(180, 150, 60, 255), width=6) d3.ellipse([38, 38, 218, 218], fill=(35, 38, 42, 255), outline=(120, 125, 130, 255), width=3) for deg in range(0, 360, 15): rad = math.radians(deg) r1 = 92 r2 = 104 if (deg % 30 == 0) else 98 x1 = 128 + r1 * math.cos(rad) y1 = 128 + r1 * math.sin(rad) x2 = 128 + r2 * math.cos(rad) y2 = 128 + r2 * math.sin(rad) d3.line([(x1, y1), (x2, y2)], fill=(210, 200, 160, 255), width=2 if deg % 30 == 0 else 1) d3.ellipse([78, 78, 178, 178], fill=(55, 60, 65, 255), outline=(200, 170, 50, 255), width=4) d3.ellipse([108, 108, 148, 148], fill=(85, 90, 95, 255), outline=(140, 145, 150, 255), width=2) d3.polygon([(128, 24), (120, 42), (136, 42)], fill=(255, 50, 40, 255)) portraits.append(f3) # Frame 4: Golden Deck of Cards f4 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d4 = ImageDraw.Draw(f4) for r in range(110, 60, -8): d4.ellipse([128 - r, 128 - r, 128 + r, 128 + r], fill=(255, 215, 50, max(0, 25 - (r - 60)))) d4.polygon([(90, 60), (170, 60), (195, 190), (115, 190)], fill=(240, 195, 45, 255), outline=(255, 240, 120, 255), width=3) d4.polygon([(70, 80), (90, 60), (115, 190), (95, 210)], fill=(190, 145, 30, 255)) d4.ellipse([135, 115, 165, 145], fill=(255, 235, 110, 255)) d4.polygon([(150, 105), (140, 128), (160, 128)], fill=(40, 30, 10, 255)) d4.ellipse([140, 122, 152, 134], fill=(40, 30, 10, 255)) d4.ellipse([148, 122, 160, 134], fill=(40, 30, 10, 255)) d4.polygon([(147, 130), (153, 130), (155, 140), (145, 140)], fill=(40, 30, 10, 255)) portraits.append(f4) # Frame 5: Bartender ("Шейкер" - Heist Insider) f5 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d5 = ImageDraw.Draw(f5) # White shirt & black vest d5.polygon([(45, 256), (80, 145), (128, 138), (176, 145), (211, 256)], fill=(240, 240, 245, 255)) d5.polygon([(45, 256), (80, 145), (105, 145), (115, 256)], fill=(25, 25, 30, 255)) d5.polygon([(211, 256), (176, 145), (151, 145), (141, 256)], fill=(25, 25, 30, 255)) # Red Bowtie d5.polygon([(118, 142), (128, 146), (118, 150)], fill=(190, 25, 35, 255)) d5.polygon([(138, 142), (128, 146), (138, 150)], fill=(190, 25, 35, 255)) d5.rectangle([125, 143, 131, 149], fill=(140, 20, 25, 255)) # Head & combed hair d5.rectangle([110, 95, 146, 135], fill=(215, 160, 125, 255)) d5.polygon([(92, 50), (128, 35), (164, 50), (160, 105), (96, 105)], fill=(225, 170, 135, 255)) d5.polygon([(90, 48), (128, 30), (166, 48), (162, 70), (94, 70)], fill=(45, 30, 25, 255)) # Mustache d5.polygon([(108, 98), (128, 93), (148, 98), (142, 105), (128, 101), (114, 105)], fill=(45, 30, 25, 255)) # Eyes & wink d5.ellipse([108, 75, 118, 83], fill=(20, 20, 20, 255)) d5.line([(136, 79), (148, 78)], fill=(30, 25, 20, 255), width=2) # Cocktail shaker in hand d5.polygon([(165, 170), (195, 155), (205, 220), (175, 235)], fill=(190, 200, 210, 255), outline=(240, 245, 250, 255), width=2) d5.polygon([(178, 145), (192, 138), (198, 158), (184, 165)], fill=(160, 170, 180, 255)) # Green sleeping potion vial d5.rectangle([55, 180, 75, 220], fill=(40, 200, 80, 200), outline=(220, 250, 230, 255), width=2) d5.rectangle([61, 168, 69, 180], fill=(180, 130, 60, 255)) portraits.append(f5) # Frame 6: Cabaret Singer ("Сирена" - Distraction Star) f6 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d6 = ImageDraw.Draw(f6) # Stage glow for r in range(120, 70, -10): d6.ellipse([128 - r, 100 - r, 128 + r, 100 + r], fill=(255, 60, 120, max(0, 18 - (r - 70)))) # Ruby evening dress d6.polygon([(65, 256), (90, 150), (128, 160), (166, 150), (191, 256)], fill=(180, 20, 60, 255)) d6.polygon([(92, 150), (128, 175), (164, 150)], fill=(220, 30, 75, 255)) # Slender neck & face d6.rectangle([114, 105, 142, 145], fill=(235, 180, 150, 255)) d6.polygon([(98, 60), (128, 48), (158, 60), (152, 115), (104, 115)], fill=(245, 190, 160, 255)) # Pearl necklace for px in range(112, 145, 6): d6.ellipse([px - 2, 132, px + 2, 136], fill=(255, 255, 250, 255)) # Vintage wave hair d6.ellipse([88, 40, 168, 90], fill=(30, 20, 20, 255)) d6.ellipse([80, 60, 105, 115], fill=(30, 20, 20, 255)) d6.ellipse([151, 60, 176, 115], fill=(30, 20, 20, 255)) # Makeup & red lips d6.line([(108, 76), (120, 75)], fill=(20, 20, 20, 255), width=2) d6.line([(136, 75), (148, 76)], fill=(20, 20, 20, 255), width=2) d6.ellipse([110, 79, 118, 85], fill=(60, 120, 180, 255)) d6.ellipse([138, 79, 146, 85], fill=(60, 120, 180, 255)) d6.ellipse([120, 102, 136, 112], fill=(220, 20, 50, 255)) # Vintage stand microphone d6.ellipse([120, 135, 136, 155], fill=(190, 195, 205, 255), outline=(240, 240, 250, 255), width=2) d6.line([(128, 155), (128, 256)], fill=(160, 165, 175, 255), width=4) portraits.append(f6) # Frame 7: Fortune Teller ("Таролог" - Mystic Intuition) f7 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d7 = ImageDraw.Draw(f7) # Mystic purple aura for r in range(115, 65, -10): d7.ellipse([128 - r, 110 - r, 128 + r, 110 + r], fill=(130, 50, 210, max(0, 22 - (r - 65)))) # Velvet robe d7.polygon([(40, 256), (80, 140), (128, 135), (176, 140), (216, 256)], fill=(45, 20, 65, 255)) # Purple Hood & Veil d7.polygon([(70, 70), (128, 25), (186, 70), (180, 150), (76, 150)], fill=(75, 25, 105, 255)) d7.polygon([(85, 75), (128, 45), (171, 75), (165, 135), (91, 135)], fill=(30, 10, 45, 255)) # Mysterious face in shadow d7.rectangle([105, 75, 151, 125], fill=(205, 150, 120, 255)) # Golden hoop earrings d7.ellipse([76, 100, 88, 116], fill=(0, 0, 0, 0), outline=(240, 190, 40, 255), width=3) d7.ellipse([168, 100, 180, 116], fill=(0, 0, 0, 0), outline=(240, 190, 40, 255), width=3) # Glowing mystic eyes d7.ellipse([110, 85, 120, 91], fill=(120, 230, 255, 255)) d7.ellipse([136, 85, 146, 91], fill=(120, 230, 255, 255)) # Glowing Tarot Card in hand d7.polygon([(100, 160), (156, 145), (170, 225), (114, 240)], fill=(235, 220, 180, 255), outline=(255, 215, 60, 255), width=3) d7.ellipse([125, 175, 145, 195], fill=(180, 40, 60, 255)) d7.line([(135, 170), (135, 200)], fill=(255, 215, 50, 255), width=2) d7.line([(120, 185), (150, 185)], fill=(255, 215, 50, 255), width=2) portraits.append(f7) # Frame 8: Hacker ("Фантом" - Terminal Infiltrator) f8 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d8 = ImageDraw.Draw(f8) # Matrix green glow for r in range(115, 65, -10): d8.ellipse([128 - r, 110 - r, 128 + r, 110 + r], fill=(20, 200, 100, max(0, 16 - (r - 65)))) # Dark hoodie d8.polygon([(35, 256), (75, 135), (128, 130), (181, 135), (221, 256)], fill=(20, 22, 28, 255)) d8.polygon([(70, 65), (128, 30), (186, 65), (175, 145), (81, 145)], fill=(28, 32, 40, 255)) d8.polygon([(82, 70), (128, 45), (174, 70), (165, 135), (91, 135)], fill=(12, 14, 18, 255)) # Face in shadow d8.rectangle([104, 75, 152, 125], fill=(180, 140, 115, 255)) # Cyber Goggles / Neon Visor d8.polygon([(96, 75), (160, 75), (155, 95), (101, 95)], fill=(0, 255, 200, 255), outline=(0, 180, 140, 255), width=2) d8.line([(100, 85), (156, 85)], fill=(255, 255, 255, 220), width=2) # Portable Cyberdeck d8.polygon([(70, 200), (186, 200), (200, 256), (56, 256)], fill=(35, 40, 50, 255), outline=(0, 255, 180, 255), width=2) for kx in range(78, 175, 12): d8.rectangle([kx, 215, kx + 8, 225], fill=(0, 220, 140, 255)) d8.rectangle([kx, 232, kx + 8, 242], fill=(0, 160, 100, 255)) portraits.append(f8) # Frame 9: Blueprint / Vault Map (Схема вентиляции и хранилища) f9 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d9 = ImageDraw.Draw(f9) # Blueprint deep blue paper d9.rectangle([10, 10, 246, 246], fill=(12, 36, 72, 255), outline=(80, 160, 240, 255), width=4) # Technical grid lines for g in range(25, 240, 15): d9.line([(14, g), (242, g)], fill=(24, 58, 110, 255), width=1) d9.line([(g, 14), (g, 242)], fill=(24, 58, 110, 255), width=1) # Casino Basement Layout (White / Cyan architectural lines) d9.rectangle([35, 40, 110, 110], fill=(18, 48, 95, 255), outline=(220, 240, 255, 255), width=2) d9.rectangle([135, 40, 220, 110], fill=(18, 48, 95, 255), outline=(220, 240, 255, 255), width=2) # Ventilation shaft path (Dashed Red Line) duct_pts = [(45, 170), (85, 170), (85, 120), (150, 120), (150, 160), (195, 160)] for idx in range(len(duct_pts) - 1): d9.line([duct_pts[idx], duct_pts[idx + 1]], fill=(255, 60, 50, 255), width=3) # Vault Room d9.rectangle([170, 140, 230, 215], fill=(30, 75, 140, 255), outline=(255, 215, 50, 255), width=3) # Vault Gold Safe Crest d9.ellipse([185, 162, 215, 192], fill=(240, 195, 40, 255), outline=(255, 240, 120, 255), width=2) d9.line([(190, 177), (210, 177)], fill=(40, 30, 15, 255), width=2) d9.line([(200, 167), (200, 187)], fill=(40, 30, 15, 255), width=2) # Stamp / Label "СЕЙФ" d9.rectangle([178, 144, 222, 156], fill=(220, 40, 30, 255)) d9.line([(182, 150), (218, 150)], fill=(255, 255, 255, 255), width=2) portraits.append(f9) # Frame 10: Escape Helicopter (Побег на крыше в неоновой ночи) f10 = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) d10 = ImageDraw.Draw(f10) # Night sky & neon skyscraper background d10.rectangle([10, 10, 246, 246], fill=(10, 12, 20, 255), outline=(180, 150, 60, 255), width=4) # City neon towers in silhouette d10.rectangle([20, 80, 60, 240], fill=(20, 24, 38, 255)) d10.rectangle([70, 110, 105, 240], fill=(24, 28, 44, 255)) d10.rectangle([195, 95, 235, 240], fill=(20, 24, 38, 255)) # Neon windows for wy in range(95, 190, 15): d10.point([(35, wy), (45, wy), (85, wy + 5), (210, wy)], fill=(255, 215, 80, 255)) d10.point([(35, wy + 6), (45, wy + 6), (220, wy + 4)], fill=(0, 240, 255, 255)) # Searchlight Beams criss-crossing d10.polygon([(30, 240), (180, 20), (210, 20)], fill=(255, 255, 180, 35)) d10.polygon([(230, 240), (80, 20), (110, 20)], fill=(0, 220, 255, 35)) # Helipad "H" on rooftop floor d10.ellipse([50, 170, 206, 240], fill=(30, 35, 45, 255), outline=(240, 200, 50, 255), width=2) d10.line([(112, 190), (112, 220)], fill=(240, 200, 50, 255), width=4) d10.line([(144, 190), (144, 220)], fill=(240, 200, 50, 255), width=4) d10.line([(112, 205), (144, 205)], fill=(240, 200, 50, 255), width=4) # Sleek Helicopter Fuselage d10.ellipse([90, 130, 175, 175], fill=(35, 40, 52, 255), outline=(180, 190, 205, 255), width=2) # Cockpit glass with blue reflection d10.polygon([(145, 138), (172, 145), (168, 162), (140, 158)], fill=(40, 160, 220, 255)) # Tail boom and rotor d10.polygon([(95, 145), (45, 135), (45, 142), (95, 155)], fill=(30, 35, 45, 255)) d10.line([(45, 125), (45, 150)], fill=(180, 190, 200, 255), width=2) # Main rotor mast & blurred spinning blades d10.line([(130, 130), (130, 118)], fill=(120, 125, 135, 255), width=3) d10.ellipse([50, 114, 210, 122], fill=(220, 230, 245, 110), outline=(255, 255, 255, 160), width=1) # Flying banknotes in wind d10.rectangle([180, 160, 192, 167], fill=(80, 180, 100, 255)) d10.rectangle([195, 145, 207, 152], fill=(80, 180, 100, 255)) d10.rectangle([170, 125, 182, 132], fill=(80, 180, 100, 255)) portraits.append(f10) # ========================================================================= # Save Master Sprite Sheet: assets/sprites/hall/underworld-portraits-v1.png # 4 columns x 3 rows = 1024x768 # ========================================================================= cols_sheet = 4 rows_sheet = (len(portraits) + cols_sheet - 1) // cols_sheet sheet_portraits = Image.new("RGBA", (cols_sheet * 256, rows_sheet * 256), (0, 0, 0, 0)) for idx, p in enumerate(portraits): col = idx % cols_sheet row = idx // cols_sheet sheet_portraits.paste(p, (col * 256, row * 256)) sheet_portraits_path = SPRITES_DIR / "underworld-portraits-v1.png" sheet_portraits.save(sheet_portraits_path) print(f"Saved master sprite sheet: {sheet_portraits_path} ({sheet_portraits.width}x{sheet_portraits.height})") # Save Binary Pack: assets/animations/hall/underworld_portraits.bin write_pack("underworld_portraits.bin", portraits) # Save Preview: build/hall/underworld_portraits.bin.png save_preview("underworld_portraits.bin.png", portraits, cols=4) # ========================================================================= # 2. rat_race (128x128, 17 frames) # ========================================================================= racers = [] racer_colors = [ ((130, 135, 140), (220, 160, 170)), # 0: Flash (Grey street rat) ((175, 110, 50), (190, 140, 100)), # 1: Toughie (Brown sewer rat) ((45, 45, 50), (240, 60, 60)), # 2: Speedy (Black rat, red bandana) ((235, 235, 240), (240, 40, 40)), # 3: Ghost (Albino white, red eyes) ] for r_idx, (body_col, acc_col) in enumerate(racer_colors): for f_idx in range(4): fr = Image.new("RGBA", (128, 128), (0, 0, 0, 0)) dr = ImageDraw.Draw(fr) bob = int(math.sin(f_idx * math.pi / 2.0) * 4) leg_ext = int(math.cos(f_idx * math.pi / 2.0) * 8) tail_pts = [(25, 75 + bob), (15, 65 + bob // 2), (5, 70 - bob)] dr.line(tail_pts, fill=acc_col, width=3) # Body dr.ellipse([25, 60 + bob, 85, 88 + bob], fill=body_col) # Snout / head dr.polygon([(75, 62 + bob), (105, 75 + bob), (75, 86 + bob)], fill=body_col) # Eye dr.ellipse([88, 68 + bob, 94, 74 + bob], fill=acc_col if r_idx == 3 else (20, 20, 20, 255)) # Ear dr.ellipse([70, 52 + bob, 82, 66 + bob], fill=acc_col) # Legs dr.line([(40, 84 + bob), (35 - leg_ext, 100)], fill=body_col, width=3) dr.line([(70, 84 + bob), (75 + leg_ext, 100)], fill=body_col, width=3) # Whiskers dr.line([(96, 76 + bob), (112, 72 + bob)], fill=(220, 220, 220, 200), width=1) dr.line([(96, 78 + bob), (112, 82 + bob)], fill=(220, 220, 220, 200), width=1) # Speedy accessory (Red mohawk/bandana) if r_idx == 2: dr.polygon([(78, 60 + bob), (86, 60 + bob), (82, 70 + bob)], fill=(220, 30, 30, 255)) racers.append(fr) # Frame 16: Checkered finish line banner f_banner = Image.new("RGBA", (128, 128), (0, 0, 0, 0)) d_b = ImageDraw.Draw(f_banner) d_b.line([(20, 10), (20, 120)], fill=(180, 180, 190, 255), width=4) d_b.ellipse([16, 6, 24, 14], fill=(230, 190, 50, 255)) for row in range(5): for col in range(6): c = (255, 255, 255, 255) if (row + col) % 2 == 0 else (20, 20, 25, 255) d_b.rectangle([24 + col * 12, 15 + row * 10, 24 + (col + 1) * 12, 15 + (row + 1) * 10], fill=c) racers.append(f_banner) # Save Master Sprite Sheet: assets/sprites/hall/rat-race-v1.png (4 cols x 5 rows = 512x640) sheet_rat = Image.new("RGBA", (4 * 128, 5 * 128), (0, 0, 0, 0)) for idx, r in enumerate(racers): row = idx // 4 col = idx % 4 sheet_rat.paste(r, (col * 128, row * 128)) sheet_rat_path = SPRITES_DIR / "rat-race-v1.png" sheet_rat.save(sheet_rat_path) print(f"Saved master sprite sheet: {sheet_rat_path} (512x640)") # Save Binary Pack: assets/animations/hall/rat_race.bin write_pack("rat_race.bin", racers) # Save Preview: build/hall/rat_race.bin.png save_preview("rat_race.bin.png", racers, cols=4) # ========================================================================= # 3. Update Manifests # ========================================================================= manifest_v5 = { "bartender-v4.bin": {"frames": 24, "size": [256, 256]}, "drink-v5.bin": {"frames": 42, "size": [256, 256]}, "street-life-v4.bin": {"frames": 40, "size": [192, 320]}, "underworld_portraits.bin": {"frames": len(portraits), "size": [256, 256]}, "rat_race.bin": {"frames": len(racers), "size": [128, 128]} } (ANIM_DIR / "manifest-v5.json").write_text(json.dumps(manifest_v5, indent=2), encoding="ascii") print(f"Wrote {ANIM_DIR / 'manifest-v5.json'}") try: m4_file = ANIM_DIR / "manifest-v4.json" m4_data = json.loads(m4_file.read_text(encoding="ascii")) m4_data["underworld_portraits.bin"] = {"frames": len(portraits), "size": [256, 256]} m4_data["rat_race.bin"] = {"frames": len(racers), "size": [128, 128]} m4_data["drink-v5.bin"] = {"frames": 42, "size": [256, 256]} m4_file.write_text(json.dumps(m4_data, indent=2), encoding="ascii") print(f"Updated {m4_file}") except Exception as e: print(f"manifest-v4 notice: {e}") # ========================================================================= # 4. Save Prompt / Metadata file: assets/sprites/hall/prompts-v10.json # ========================================================================= prompts_v10 = { "tool": "underworld and heist asset pipeline", "sources": [ "assets/sprites/hall/drink-hand-v5.png", "assets/sprites/hall/underworld-portraits-v1.png", "assets/sprites/hall/rat-race-v1.png" ], "packs": [ "assets/animations/hall/drink-v5.bin", "assets/animations/hall/underworld_portraits.bin", "assets/animations/hall/rat_race.bin" ], "descriptions": { "drink-hand-v5": "Six 7-phase bar drinks (42 frames of 256x256): Double Bluff Whisky, Cold Calc Crimson Cocktail, Cyber Punch Neon Cyan, Chameleon Emerald Lime, Lucky Clover Gold-Emerald, Pure Ice Water.", "underworld-portraits-v1": "Eleven high-contrast 256x256 portraits and story elements: 0: Semyon (Loan Shark), 1: Collector Thug (Enforcer), 2: Pit Boss (Security Chief), 3: Vault Safe Dial, 4: Golden Deck of Cards, 5: Bartender (Shaker), 6: Cabaret Singer (Siren), 7: Fortune Teller (Tarot Mystic), 8: Hacker (Phantom), 9: Casino Vault Blueprint, 10: Rooftop Helicopter Escape.", "rat-race-v1": "Underground cellar rat racing: 4 distinct rats (Flash, Toughie, Speedy, Ghost) with 4-frame running loops + checkered finish banner (17 frames of 128x128)." }, "normalization": "ANM1 binary format (magic ANM1, width, height, nframes, payload_len, raw BGRA pixel stream) for 320x240 software raycaster." } (SPRITES_DIR / "prompts-v10.json").write_text(json.dumps(prompts_v10, indent=2), encoding="utf-8") print(f"Wrote {SPRITES_DIR / 'prompts-v10.json'}") if __name__ == "__main__": main()