wobblyhead hg > minor_monsters
diff tools/build.py @ 8:2c4fed8baed9
art update, persistent sound setting, tower selling as double action
| author | ark |
|---|---|
| date | 2026-10-19 13:37 +0200 |
| parents | 910b26feca76 |
| children | 53f015966118 |
line wrap: on
line diff
--- a/tools/build.py Mon Oct 19 11:50:24 2026 +0200 +++ b/tools/build.py Mon Oct 19 13:37:52 2026 +0200 @@ -8,7 +8,7 @@ a step is skipped when all its outputs are newer than its inputs and the build scripts; --force runs every step. --watch reruns the build whenever a file -in art/, art/sounds/ or config/ changes. +in art/, art/sounds/, art/digits/ or config/ changes. requires python 3.11 or later and pillow. """ @@ -34,6 +34,7 @@ ROOT = Path(__file__).resolve().parent.parent ART = ROOT / "art" SOUNDS = ART / "sounds" +DIGITS = ART / "digits" CONFIG = ROOT / "config" ASSETS = ROOT / "game" / "assets" DATA = ROOT / "game" / "data" @@ -47,7 +48,14 @@ SPRITES = (["m%d" % i for i in range(5)] + ["b%d" % i for i in range(4)] + ["t%d" % i for i in range(4)] + ["p%d" % i for i in range(4)] - + ["c%d" % i for i in range(4)] + ["hpm", "hpb"]) + + ["c%d" % i for i in range(4)] + ["hpm", "hpb"] + # icons, buttons and screens (art.md) + + ["coin_icon", "heart", "monster_icon", "play_button", "pause_button", + "speed_x1", "speed_x2", "speed_x4", "sound_on", "sound_off", "next_wave", + "shop_bubble", "shop_bubble_dark", "shop_bubble_dark2", "tower_popup", + "upgrade_button", "sell_button", "monster_death", "boss_death", + "splash", "splash_play", "map_won", "map_won_button", + "game_lost", "game_lost_button", "game_won", "game_won_button"]) # hp bar variants (art.md): the empty part is a darkened copy, the bar of a # slowed monster has its colour set to this hue in degrees BAR_DARKEN = 0.35 @@ -90,12 +98,19 @@ # 1. sprites def step_sprites(force): - inputs = [ART / f"{n}.png" for n in SPRITES] - outputs = [ASSETS / f"{n}.png" for n in SPRITES + BAR_VARIANTS] + # digits cut by tools/cut_digits.py, written as digit_NAME_N + digits = sorted(DIGITS.glob("*.png")) + inputs = [ART / f"{n}.png" for n in SPRITES] + digits + [DIGITS] + outputs = ([ASSETS / f"{n}.png" for n in SPRITES + BAR_VARIANTS] + + [ASSETS / f"digit_{p.name}" for p in digits]) if not stale(inputs, outputs, force): print("sprites: up to date") return False ASSETS.mkdir(parents=True, exist_ok=True) + for p in ASSETS.glob("digit_*.png"): + p.unlink() + for p in digits: + images.trim(Image.open(p).convert("RGBA")).save(ASSETS / f"digit_{p.name}", optimize=True) for n in SPRITES: im = images.trim(Image.open(ART / f"{n}.png").convert("RGBA")) im.save(ASSETS / f"{n}.png", optimize=True) @@ -104,7 +119,8 @@ images.darken(im, BAR_DARKEN).save(ASSETS / f"{n}_empty.png", optimize=True) slow.save(ASSETS / f"{n}_slow.png", optimize=True) images.darken(slow, BAR_DARKEN).save(ASSETS / f"{n}_slow_empty.png", optimize=True) - print(f"sprites: wrote {len(SPRITES)} sprites and {len(BAR_VARIANTS)} bar variants") + print(f"sprites: wrote {len(SPRITES)} sprites, {len(BAR_VARIANTS)} bar variants" + f" and {len(digits)} digits") return True @@ -492,7 +508,8 @@ def watch(): def snapshot(): - files = list(ART.iterdir()) + list(SOUNDS.glob("*.mp3")) + list(CONFIG.iterdir()) + TOOLS + files = (list(ART.iterdir()) + list(SOUNDS.glob("*.mp3")) + list(DIGITS.glob("*.png")) + + list(CONFIG.iterdir()) + TOOLS) return {p: p.stat().st_mtime for p in files if p.is_file()} seen = None
