Implement Nova Farma S1 Max: Layered terrain, water mechanics, Y-sorting, and asset cleanup

This commit is contained in:
2026-01-27 01:02:24 +01:00
parent 3b0c26fa5a
commit 51b3b67423
41 changed files with 734 additions and 268 deletions

View File

@@ -1,48 +1,48 @@
from PIL import Image
import cv2
import os
# Configuration
# Configuration
TARGET_DIRS = ["assets/grounds", "assets/maps/tilesets"] # Expanded targets
TARGET_SIZE = (256, 256)
# Define target widths for assets
TARGETS = {
'assets/DEMO_FAZA1/UI/badge_purchase.png': 512,
'assets/DEMO_FAZA1/UI/health_critical.png': 512,
'assets/DEMO_FAZA1/VFX/toxic_fog.png': 512,
'assets/DEMO_FAZA1/Environment/obstacle_thorns.png': 256,
'assets/DEMO_FAZA1/Structures/foundation_concrete.png': 512,
'assets/DEMO_FAZA1/Items/hay_drop_0.png': 128
}
def resize_images():
for target_dir in TARGET_DIRS:
if not os.path.exists(target_dir):
print(f"⚠️ Directory {target_dir} not found. Skipping.")
continue
def resize_image(path, target_width):
if not os.path.exists(path):
print(f"Skipping {path}, file not found.")
return
print(f"📂 Processing directory: {target_dir}...")
files = [f for f in os.listdir(target_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
for filename in files:
filepath = os.path.join(target_dir, filename)
try:
with Image.open(filepath) as img:
width, height = img.size
# SELECTIVE RESIZE LOGIC
# 1. Must be Square 1024x1024 (Grounds, Props, Trees)
# 2. Or if explicitly in 'grounds' folder and > 256
should_resize = False
if "grounds" in target_dir and width > 256:
should_resize = True
elif width == 1024 and height == 1024:
should_resize = True
if should_resize:
print(f"✨ Resizing {filename} ({width}x{height}) -> {TARGET_SIZE} (Lanczos)")
img_resized = img.resize(TARGET_SIZE, Image.Resampling.LANCZOS)
img_resized.save(filepath)
else:
pass # print(f"Skipping {filename} ({width}x{height}) - Criteria not met")
except Exception as e:
print(f"❌ Error processing {filename}: {e}")
img = cv2.imread(path, cv2.IMREAD_UNCHANGED)
if img is None:
print(f"Error loading {path}")
return
h, w = img.shape[:2]
# Check if resize is needed
if w <= target_width:
print(f"{path} is already {w}px (Target: {target_width}px). Skipping resize.")
return
# Calculate new height to maintain aspect ratio
ratio = target_width / w
new_h = int(h * ratio)
resized = cv2.resize(img, (target_width, new_h), interpolation=cv2.INTER_AREA)
cv2.imwrite(path, resized)
print(f"Resized {path}: {w}x{h} -> {target_width}x{new_h}")
if __name__ == "__main__":
resize_images()
base_path = os.getcwd()
print("Starting Resize Job...")
for rel_path, width in TARGETS.items():
full_path = os.path.join(base_path, rel_path)
resize_image(full_path, width)
print("Resize Job Complete.")