settings.pyΒΆ

Part of Clear Code Zelda.

  1"""Game-wide constants for the Clear Code Zelda port.
  2
  3Mirrors the upstream ``settings.py`` but expressed in SimVX idioms
  4(seconds instead of milliseconds, RGBA float colours, asset paths
  5relative to the package).
  6"""
  7
  8from __future__ import annotations
  9
 10from pathlib import Path
 11
 12ASSET_ROOT = Path(__file__).resolve().parent / "assets"
 13
 14# World
 15TILESIZE = 64
 16
 17# Window
 18WIDTH = 1280
 19HEIGHT = 720
 20
 21# Hitbox shrink (Pygame `rect.inflate(0, n)`, y-axis only)
 22HITBOX_OFFSET = {
 23    "player": -26,
 24    "object": -40,
 25    "grass": -10,
 26    "invisible": 0,
 27}
 28
 29# UI sizing
 30BAR_HEIGHT = 20
 31HEALTH_BAR_WIDTH = 200
 32ENERGY_BAR_WIDTH = 140
 33ITEM_BOX_SIZE = 80
 34UI_FONT_SIZE = 18
 35
 36# Colours (RGBA 0..1 floats)
 37WATER_COLOUR = (0.443, 0.867, 0.933, 1.0)
 38UI_BG_COLOUR = (0.133, 0.133, 0.133, 1.0)
 39UI_BORDER_COLOUR = (0.067, 0.067, 0.067, 1.0)
 40TEXT_COLOUR = (0.933, 0.933, 0.933, 1.0)
 41TEXT_COLOUR_SELECTED = (0.067, 0.067, 0.067, 1.0)
 42
 43HEALTH_COLOUR = (0.85, 0.20, 0.20, 1.0)
 44ENERGY_COLOUR = (0.25, 0.45, 0.95, 1.0)
 45UI_BORDER_COLOUR_ACTIVE = (1.0, 0.85, 0.10, 1.0)
 46BAR_COLOUR = (0.933, 0.933, 0.933, 1.0)
 47BAR_COLOUR_SELECTED = (0.067, 0.067, 0.067, 1.0)
 48UPGRADE_BG_COLOUR_SELECTED = (0.933, 0.933, 0.933, 1.0)
 49GROUND_COLOUR = (0.18, 0.46, 0.21, 1.0)  # Procedural floor tint (substitutes ground.png)
 50
 51# Weapons (cooldown is now in *seconds*)
 52weapon_data: dict[str, dict] = {
 53    "sword": {"cooldown": 0.10, "damage": 15, "graphic": "weapons/sword/full.png"},
 54    "lance": {"cooldown": 0.40, "damage": 30, "graphic": "weapons/lance/full.png"},
 55    "axe": {"cooldown": 0.30, "damage": 20, "graphic": "weapons/axe/full.png"},
 56    "rapier": {"cooldown": 0.05, "damage": 8, "graphic": "weapons/rapier/full.png"},
 57    "sai": {"cooldown": 0.08, "damage": 10, "graphic": "weapons/sai/full.png"},
 58}
 59
 60# Magic
 61magic_data: dict[str, dict] = {
 62    "flame": {"strength": 5, "cost": 20, "graphic": "particles/flame/fire.png"},
 63    "heal": {"strength": 20, "cost": 10, "graphic": "particles/heal/heal.png"},
 64}
 65
 66# Enemies (`speed` rescaled to px/sec; original is "Pygame frame units" at 60 FPS).
 67monster_data: dict[str, dict] = {
 68    "squid": {
 69        "health": 100,
 70        "exp": 100,
 71        "damage": 20,
 72        "attack_type": "slash",
 73        "attack_sound": "attack/slash.wav",
 74        "speed": 180,
 75        "resistance": 3,
 76        "attack_radius": 80,
 77        "notice_radius": 360,
 78        "colour": (0.55, 0.30, 0.85, 1.0),
 79    },
 80    "raccoon": {
 81        "health": 300,
 82        "exp": 250,
 83        "damage": 40,
 84        "attack_type": "claw",
 85        "attack_sound": "attack/claw.wav",
 86        "speed": 120,
 87        "resistance": 3,
 88        "attack_radius": 120,
 89        "notice_radius": 400,
 90        "colour": (0.50, 0.35, 0.20, 1.0),
 91    },
 92    "spirit": {
 93        "health": 100,
 94        "exp": 110,
 95        "damage": 8,
 96        "attack_type": "thunder",
 97        "attack_sound": "attack/fireball.wav",
 98        "speed": 240,
 99        "resistance": 3,
100        "attack_radius": 60,
101        "notice_radius": 350,
102        "colour": (0.85, 0.85, 0.95, 1.0),
103    },
104    "bamboo": {
105        "health": 70,
106        "exp": 120,
107        "damage": 6,
108        "attack_type": "leaf_attack",
109        "attack_sound": "attack/slash.wav",
110        "speed": 180,
111        "resistance": 3,
112        "attack_radius": 50,
113        "notice_radius": 300,
114        "colour": (0.20, 0.55, 0.30, 1.0),
115    },
116}
117
118
119def asset(rel: str) -> str:
120    """Resolve a graphics-folder asset path to an absolute string."""
121    return str(ASSET_ROOT / "graphics" / rel)
122
123
124def audio_asset(rel: str) -> str:
125    return str(ASSET_ROOT / "audio" / rel)
126
127
128def map_csv(name: str) -> Path:
129    return ASSET_ROOT / "map" / name