- Added BMP_1_EXPLOSION_DOWN.png to original and preview directories. - Added BMP_1_EXPLOSION_LEFT.png to original and preview directories. - Added BMP_1_EXPLOSION_RIGHT.png to original and preview directories. - Added BMP_1_EXPLOSION_UP.png to original and preview directories. These assets are part of the explosion animation for the game, enhancing visual effects during gameplay.master
|
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 347 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 337 B After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,74 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import json |
||||||
|
import sys |
||||||
|
from pathlib import Path |
||||||
|
|
||||||
|
from PIL import Image |
||||||
|
|
||||||
|
|
||||||
|
CHROMAKEY = [128, 128, 128, 255] |
||||||
|
GREEN_LIGHT = [0, 255, 0, 255] |
||||||
|
GREEN_DARK = [0, 128, 0, 255] |
||||||
|
|
||||||
|
|
||||||
|
def is_green(pixel): |
||||||
|
return pixel == GREEN_LIGHT or pixel == GREEN_DARK |
||||||
|
|
||||||
|
|
||||||
|
def is_background(pixel): |
||||||
|
return pixel == CHROMAKEY or is_green(pixel) |
||||||
|
|
||||||
|
|
||||||
|
def cave_reference_path(sprite_name): |
||||||
|
direction = sprite_name.rsplit("_", 1)[-1] |
||||||
|
return Path("assets/Rat") / f"BMP_1_CAVE_{direction}.png" |
||||||
|
|
||||||
|
|
||||||
|
def load_cave_grid(sprite_name): |
||||||
|
cave_path = cave_reference_path(sprite_name) |
||||||
|
cave_image = Image.open(cave_path).convert("RGBA") |
||||||
|
width, height = cave_image.size |
||||||
|
pixel_access = cave_image.load() |
||||||
|
return [ |
||||||
|
[list(pixel_access[x, y]) for x in range(width)] |
||||||
|
for y in range(height) |
||||||
|
] |
||||||
|
|
||||||
|
|
||||||
|
def enhance_pixels(name, pixels): |
||||||
|
cave_pixels = load_cave_grid(name) |
||||||
|
enhanced = [] |
||||||
|
for y, row in enumerate(pixels): |
||||||
|
enhanced_row = [] |
||||||
|
for x, pixel in enumerate(row): |
||||||
|
if is_background(pixel): |
||||||
|
enhanced_row.append(cave_pixels[y][x][:]) |
||||||
|
else: |
||||||
|
enhanced_row.append(pixel[:]) |
||||||
|
enhanced.append(enhanced_row) |
||||||
|
return enhanced |
||||||
|
|
||||||
|
|
||||||
|
def process_file(src_path, dst_path): |
||||||
|
data = json.loads(src_path.read_text()) |
||||||
|
pixels = data["pixels"] |
||||||
|
data["pixels"] = enhance_pixels(src_path.stem, pixels) |
||||||
|
dst_path.write_text(json.dumps(data, indent=2)) |
||||||
|
|
||||||
|
|
||||||
|
def main(): |
||||||
|
if len(sys.argv) != 3: |
||||||
|
raise SystemExit("usage: enhance_stage1_explosions.py <src_dir> <dst_dir>") |
||||||
|
|
||||||
|
src_dir = Path(sys.argv[1]) |
||||||
|
dst_dir = Path(sys.argv[2]) |
||||||
|
dst_dir.mkdir(parents=True, exist_ok=True) |
||||||
|
|
||||||
|
for src_path in sorted(src_dir.glob("BMP_1_EXPLOSION_*.json")): |
||||||
|
dst_path = dst_dir / src_path.name |
||||||
|
process_file(src_path, dst_path) |
||||||
|
print(f"Wrote {dst_path}") |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
main() |
||||||
|
After Width: | Height: | Size: 336 B |
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 347 B |
|
After Width: | Height: | Size: 337 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.8 KiB |