(Underdepth) Prepare for Pass 5
This commit is contained in:
32 files changed
+31
-4892
No files matched your search
Whitespace-only changes.
@@ -1,133 +0,0 @@
|
||||
"""Tuning constants, palettes, and progression tables for Underdepths.
|
||||
|
||||
All magic numbers live here so balancing is a one-file edit.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
# --- Grid / viewport -------------------------------------------------------- #
|
||||
TILE: int = 24
|
||||
MAP_WIDTH: int = 80
|
||||
MAP_HEIGHT: int = 50
|
||||
SIGHT_RADIUS: int = 8
|
||||
FLOORS: int = 10
|
||||
MAX_LEVEL: int = 10
|
||||
|
||||
# --- Base palette / colors -------------------------------------------------- #
|
||||
# Tiles
|
||||
COLORS: dict[str, tuple[int, int, int]] = {
|
||||
"wall_visible": (60, 60, 70),
|
||||
"wall_explored": (30, 30, 35),
|
||||
"floor_visible": (40, 35, 30),
|
||||
"floor_explored": (20, 18, 15),
|
||||
"void": (6, 5, 8),
|
||||
# entity accent hues (dominant sprite color per type)
|
||||
"player": (225, 225, 235),
|
||||
"rat": (150, 110, 75),
|
||||
"goblin": (95, 165, 75),
|
||||
"skeleton_archer": (215, 215, 205),
|
||||
"orc_warrior": (155, 55, 50),
|
||||
"wraith": (160, 95, 205),
|
||||
"green_slime": (125, 205, 85),
|
||||
"ancient_dragon": (205, 65, 50),
|
||||
# feature / item accents
|
||||
"stairs": (240, 220, 80),
|
||||
"weapon": (240, 220, 80), # yellow
|
||||
"armor": (95, 145, 230), # blue
|
||||
"potion": (220, 85, 85), # red
|
||||
"scroll": (95, 220, 220), # cyan
|
||||
# UI
|
||||
"ui_border": (150, 130, 95),
|
||||
"ui_border_hi": (200, 180, 130),
|
||||
"ui_bg": (15, 12, 18),
|
||||
"ui_panel": (24, 20, 28),
|
||||
"hp_full": (190, 55, 60),
|
||||
"hp_back": (60, 22, 24),
|
||||
"xp_full": (90, 170, 230),
|
||||
"xp_back": (26, 34, 48),
|
||||
"log_combat": (235, 235, 235),
|
||||
"log_damage": (225, 90, 90),
|
||||
"log_levelup": (130, 225, 100),
|
||||
"log_item": (240, 220, 90),
|
||||
"log_miss": (170, 170, 170),
|
||||
"prompt": (245, 235, 180),
|
||||
"shadow": (0, 0, 0),
|
||||
"highlight": (255, 255, 255),
|
||||
}
|
||||
|
||||
# Sprite-palette keys (single chars in data/sprites.py grids) -> RGB.
|
||||
# "." is transparent. Keys are intentionally short; phase 4 sprites use them.
|
||||
PALETTE: dict[str, tuple[int, int, int] | None] = {
|
||||
".": None, # transparent
|
||||
"K": (18, 14, 20), # dark outline
|
||||
"k": (40, 32, 38), # soft outline
|
||||
"W": (95, 85, 72), # warm light shade (stone/skin highlight)
|
||||
"s": (62, 56, 50), # mid shade (stone/skin)
|
||||
"h": (38, 33, 30), # dark shade (stone/skin shadow)
|
||||
"d": (24, 20, 18), # deep shadow
|
||||
"w": (245, 245, 250), # white (bone / sclera)
|
||||
"g": (120, 200, 80), # green (goblin / slime)
|
||||
"G": (70, 150, 55), # dark green
|
||||
"r": (200, 60, 50), # red (orc / dragon)
|
||||
"R": (140, 35, 30), # dark red
|
||||
"p": (160, 95, 205), # purple (wraith)
|
||||
"P": (95, 55, 140), # dark purple
|
||||
"b": (95, 145, 230), # blue (armor / magic)
|
||||
"y": (240, 220, 80), # yellow (stairs / weapon / gold)
|
||||
"o": (225, 150, 60), # orange (fire / accents)
|
||||
"c": (95, 220, 220), # cyan (scroll)
|
||||
"m": (220, 85, 85), # muted red (potion)
|
||||
"e": (90, 230, 120), # eye glow green
|
||||
"E": (120, 200, 255), # eye glow blue
|
||||
}
|
||||
|
||||
# --- Progression: XP and level-up tables (plan.md §7) ----------------------- #
|
||||
# Cumulative XP required to REACH a given level (keyed by level 1..10).
|
||||
XP_THRESHOLDS: dict[int, int] = {
|
||||
1: 0, 2: 30, 3: 70, 4: 140, 5: 250,
|
||||
6: 400, 7: 600, 8: 850, 9: 1150, 10: 1500,
|
||||
}
|
||||
# Stat gains applied when leveling INTO a given level.
|
||||
LEVEL_HP_GAIN: dict[int, int] = {2: 10, 3: 10, 4: 10, 5: 10, 6: 15, 7: 15, 8: 15, 9: 15, 10: 20}
|
||||
LEVEL_POWER_GAIN: dict[int, int] = {2: 1, 3: 1, 4: 1, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2, 10: 3}
|
||||
|
||||
# --- Player base stats (plan.md §7) ---------------------------------------- #
|
||||
PLAYER_BASE: dict[str, int | float] = {
|
||||
"hp": 50, "max_hp": 50, "power": 4, "armor": 0,
|
||||
"accuracy": 5, "evasion": 2, "crit_chance": 0.10, "speed": 1,
|
||||
}
|
||||
|
||||
# --- Per-floor spawn distribution (plan.md §1) ----------------------------- #
|
||||
# (min, max) enemies / items per floor. Floor 9 is the boss arena.
|
||||
ENEMY_COUNT: dict[int, tuple[int, int]] = {
|
||||
0: (3, 4), 1: (3, 4),
|
||||
2: (4, 6), 3: (4, 6),
|
||||
4: (5, 7), 5: (5, 7),
|
||||
6: (6, 8), 7: (6, 8),
|
||||
8: (7, 9),
|
||||
}
|
||||
ITEM_COUNT: dict[int, tuple[int, int]] = {
|
||||
0: (2, 3), 1: (2, 3),
|
||||
2: (2, 3), 3: (2, 3),
|
||||
4: (3, 4), 5: (3, 4),
|
||||
6: (3, 4), 7: (3, 4),
|
||||
8: (4, 5), 9: (2, 2),
|
||||
}
|
||||
|
||||
# --- Key bindings (plan.md Controls) --------------------------------------- #
|
||||
# Map of intent -> pygame key constant names; resolved in phase 4 input layer.
|
||||
KEY_BINDINGS: dict[str, list[str]] = {
|
||||
"move_n": ["K_UP", "K_k"],
|
||||
"move_s": ["K_DOWN", "K_j"],
|
||||
"move_w": ["K_LEFT", "K_h"],
|
||||
"move_e": ["K_RIGHT", "K_l"],
|
||||
"pickup": ["K_g"],
|
||||
"inventory": ["K_i"],
|
||||
"equipment": ["K_e"],
|
||||
"quaff": ["K_q"],
|
||||
"read": ["K_r"],
|
||||
"descend": ["K_f"],
|
||||
"save_quit": ["K_s"],
|
||||
"help": ["K_QUESTION"],
|
||||
"mute": ["K_m"],
|
||||
"cancel": ["K_ESCAPE"],
|
||||
}
|
||||
@@ -1,535 +0,0 @@
|
||||
"""Procedural pixel-art sprite definitions (plan.md Rendering).
|
||||
|
||||
Every entity, item, and feature is a 16x16 grid of single-char palette keys
|
||||
(data/constants.PALETTE: "." transparent). Grids are drawn with small canvas
|
||||
primitives (rect, disc, triangle, line) so the art is symmetric and
|
||||
recognizable rather than hand-counted ASCII. render/sprites.py rasterizes a
|
||||
grid to a pygame.Surface once and caches it.
|
||||
|
||||
Tiles (walls/floor) are NOT here: they need seeded per-tile variation, so the
|
||||
renderer draws them procedurally. This file holds the distinct, judged sprites:
|
||||
player (4 facings), 7 enemies + small slime, 13 item icons, and stairs.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
SIZE: int = 16
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Canvas primitives — operate on a mutable list[list[str]] grid of SIZE rows.
|
||||
# --------------------------------------------------------------------------- #
|
||||
def _blank() -> list[list[str]]:
|
||||
return [["." for _ in range(SIZE)] for _ in range(SIZE)]
|
||||
|
||||
|
||||
def _set(g: list[list[str]], x: int, y: int, k: str) -> None:
|
||||
if 0 <= x < SIZE and 0 <= y < SIZE:
|
||||
g[y][x] = k
|
||||
|
||||
|
||||
def _rect(g, x0, y0, x1, y1, k) -> None:
|
||||
for y in range(max(0, y0), min(SIZE - 1, y1) + 1):
|
||||
for x in range(max(0, x0), min(SIZE - 1, x1) + 1):
|
||||
g[y][x] = k
|
||||
|
||||
|
||||
def _frame(g, x0, y0, x1, y1, k) -> None:
|
||||
for x in range(x0, x1 + 1):
|
||||
_set(g, x, y0, k)
|
||||
_set(g, x, y1, k)
|
||||
for y in range(y0, y1 + 1):
|
||||
_set(g, x0, y, k)
|
||||
_set(g, x1, y, k)
|
||||
|
||||
|
||||
def _disc(g, cx, cy, rx, ry, k) -> None:
|
||||
rx = max(0.1, rx)
|
||||
ry = max(0.1, ry)
|
||||
for y in range(SIZE):
|
||||
for x in range(SIZE):
|
||||
dx = (x - cx) / rx
|
||||
dy = (y - cy) / ry
|
||||
if dx * dx + dy * dy <= 1.0:
|
||||
g[y][x] = k
|
||||
|
||||
|
||||
def _hline(g, x0, x1, y, k) -> None:
|
||||
for x in range(min(x0, x1), max(x0, x1) + 1):
|
||||
_set(g, x, y, k)
|
||||
|
||||
|
||||
def _vline(g, x, y0, y1, k) -> None:
|
||||
for y in range(min(y0, y1), max(y0, y1) + 1):
|
||||
_set(g, x, y, k)
|
||||
|
||||
|
||||
def _line(g, x0, y0, x1, y1, k) -> None:
|
||||
dx = abs(x1 - x0)
|
||||
dy = -abs(y1 - y0)
|
||||
sx = 1 if x0 < x1 else -1
|
||||
sy = 1 if y0 < y1 else -1
|
||||
err = dx + dy
|
||||
while True:
|
||||
_set(g, x0, y0, k)
|
||||
if x0 == x1 and y0 == y1:
|
||||
break
|
||||
e2 = 2 * err
|
||||
if e2 >= dy:
|
||||
err += dy
|
||||
x0 += sx
|
||||
if e2 <= dx:
|
||||
err += dx
|
||||
y0 += sy
|
||||
|
||||
|
||||
def _tri(g, ax, ay, bx, by, cx, cy, k) -> None:
|
||||
ymin = max(0, int(min(ay, by, cy)))
|
||||
ymax = min(SIZE - 1, int(max(ay, by, cy)))
|
||||
for y in range(ymin, ymax + 1):
|
||||
xs = []
|
||||
for (x0, y0, x1, y1) in ((ax, ay, bx, by), (bx, by, cx, cy), (cx, cy, ax, ay)):
|
||||
if y0 == y1:
|
||||
if y0 == y:
|
||||
xs.extend([x0, x1])
|
||||
continue
|
||||
t = (y - y0) / (y1 - y0)
|
||||
xs.append(x0 + t * (x1 - x0))
|
||||
if len(xs) >= 2:
|
||||
_hline(g, int(round(min(xs))), int(round(max(xs))), y, k)
|
||||
|
||||
|
||||
def _flip(g) -> list[list[str]]:
|
||||
return [row[::-1] for row in g]
|
||||
|
||||
|
||||
def _shift(g, dy: int) -> list[list[str]]:
|
||||
out = _blank()
|
||||
for y in range(SIZE):
|
||||
for x in range(SIZE):
|
||||
ny = y + dy
|
||||
if 0 <= ny < SIZE:
|
||||
out[ny][x] = g[y][x]
|
||||
return out
|
||||
|
||||
|
||||
def _outline(g) -> list[list[str]]:
|
||||
"""1px dark 'K' border around the silhouette (keeps sprites off the floor)."""
|
||||
out = [row[:] for row in g]
|
||||
for y in range(SIZE):
|
||||
for x in range(SIZE):
|
||||
if g[y][x] != ".":
|
||||
continue
|
||||
for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
|
||||
nx, ny = x + dx, y + dy
|
||||
if 0 <= nx < SIZE and 0 <= ny < SIZE and g[ny][nx] != ".":
|
||||
out[y][x] = "K"
|
||||
break
|
||||
return out
|
||||
|
||||
|
||||
def _rows(g) -> list[str]:
|
||||
return ["".join(row) for row in g]
|
||||
|
||||
|
||||
def _eframes(g) -> list[list[str]]:
|
||||
"""2 idle frames: base + 1px bob, both outlined."""
|
||||
ob = _outline(g)
|
||||
return [_rows(ob), _rows(_shift(ob, 1))]
|
||||
|
||||
|
||||
def _iframe(g) -> list[list[str]]:
|
||||
return [_rows(_outline(g))]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Player — hooded adventurer, 4 facings. Weapon/armor visibly change via the
|
||||
# renderer (held-weapon icon + armor shoulder tint), not extra grids.
|
||||
# --------------------------------------------------------------------------- #
|
||||
def _player_down():
|
||||
g = _blank()
|
||||
_rect(g, 6, 1, 9, 1, "W") # hood crown
|
||||
_rect(g, 5, 2, 10, 5, "W") # hood dome
|
||||
_rect(g, 6, 4, 9, 5, "s") # face shadow
|
||||
_set(g, 7, 4, "E"); _set(g, 8, 4, "E") # blue eyes
|
||||
_rect(g, 4, 6, 11, 7, "W") # shoulders
|
||||
_set(g, 4, 6, "w"); _set(g, 11, 6, "w") # shoulder highlights
|
||||
_rect(g, 5, 8, 10, 11, "W") # torso
|
||||
_hline(g, 5, 10, 11, "y") # belt
|
||||
_vline(g, 4, 8, 11, "W"); _vline(g, 11, 8, 11, "W") # arms
|
||||
_rect(g, 6, 12, 7, 13, "h"); _rect(g, 8, 12, 9, 13, "h") # legs
|
||||
_hline(g, 6, 7, 14, "K"); _hline(g, 8, 9, 14, "K") # boots
|
||||
return g
|
||||
|
||||
|
||||
def _player_up():
|
||||
g = _player_down()
|
||||
_rect(g, 6, 3, 9, 5, "W") # back of hood: no face/eyes
|
||||
_hline(g, 6, 9, 5, "k")
|
||||
return g
|
||||
|
||||
|
||||
def _player_right():
|
||||
g = _blank()
|
||||
_rect(g, 5, 1, 9, 1, "W")
|
||||
_rect(g, 5, 2, 11, 5, "W") # hood, extending right (point)
|
||||
_set(g, 12, 4, "W")
|
||||
_rect(g, 7, 4, 9, 5, "s") # side face
|
||||
_set(g, 10, 4, "E") # one eye
|
||||
_rect(g, 4, 6, 11, 7, "W")
|
||||
_set(g, 4, 6, "w")
|
||||
_rect(g, 5, 8, 10, 11, "W")
|
||||
_hline(g, 5, 10, 11, "y")
|
||||
_vline(g, 4, 8, 11, "W")
|
||||
_rect(g, 6, 12, 7, 13, "h"); _rect(g, 8, 12, 9, 13, "h")
|
||||
_hline(g, 6, 7, 14, "K"); _hline(g, 8, 9, 14, "K")
|
||||
return g
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Enemies — each a distinct silhouette + dominant hue.
|
||||
# --------------------------------------------------------------------------- #
|
||||
def _rat():
|
||||
g = _blank()
|
||||
_disc(g, 5, 5, 1.5, 1.5, "W"); _disc(g, 9, 5, 1.5, 1.5, "W") # ears
|
||||
_set(g, 5, 5, "o"); _set(g, 9, 5, "o") # inner ear
|
||||
_disc(g, 10, 8, 2.3, 2.0, "s") # head
|
||||
_disc(g, 6, 9, 3.8, 2.7, "s") # body
|
||||
_disc(g, 6, 8, 3.0, 1.5, "W") # back highlight
|
||||
_set(g, 11, 8, "K") # eye
|
||||
_set(g, 12, 9, "o") # nose
|
||||
_set(g, 13, 8, "w"); _set(g, 13, 9, "w") # whiskers
|
||||
_line(g, 3, 10, 0, 13, "o") # tail
|
||||
_set(g, 5, 12, "h"); _set(g, 8, 12, "h") # feet
|
||||
return g
|
||||
|
||||
|
||||
def _goblin():
|
||||
g = _blank()
|
||||
_set(g, 4, 5, "g"); _set(g, 4, 6, "g"); _set(g, 11, 5, "g"); _set(g, 11, 6, "g") # pointed ears
|
||||
_disc(g, 8, 6, 3.1, 2.7, "G") # head (dark green)
|
||||
_disc(g, 7, 5, 1.8, 1.0, "g") # forehead highlight
|
||||
_set(g, 7, 6, "e"); _set(g, 9, 6, "e") # glowing eyes
|
||||
_set(g, 7, 8, "w"); _set(g, 9, 8, "w") # tusks
|
||||
_rect(g, 6, 9, 10, 12, "g") # torso
|
||||
_rect(g, 6, 9, 10, 9, "G") # shoulder shade
|
||||
_hline(g, 6, 10, 12, "y") # loincloth
|
||||
_vline(g, 5, 9, 12, "g"); _vline(g, 10, 9, 12, "g") # arms
|
||||
_vline(g, 12, 6, 12, "W"); _set(g, 12, 5, "K") # crude club
|
||||
_rect(g, 6, 13, 7, 14, "G"); _rect(g, 9, 13, 10, 14, "G")
|
||||
return g
|
||||
|
||||
|
||||
def _skeleton_archer():
|
||||
g = _blank()
|
||||
# big drawn bow on the left (clear arc + taut string)
|
||||
_vline(g, 2, 4, 12, "w") # bow back
|
||||
_set(g, 1, 5, "w"); _set(g, 1, 6, "w")
|
||||
_set(g, 1, 10, "w"); _set(g, 1, 11, "w") # recurve curve
|
||||
_line(g, 2, 4, 9, 8, "K") # bowstring pulled to the hand
|
||||
_line(g, 2, 12, 9, 8, "K")
|
||||
_hline(g, 3, 7, 8, "w") # draw arm
|
||||
_disc(g, 9, 4, 2.0, 2.0, "w") # skull
|
||||
_set(g, 8, 4, "E"); _set(g, 10, 4, "E") # glowing sockets
|
||||
_hline(g, 8, 10, 6, "w"); _set(g, 8, 6, "K"); _set(g, 10, 6, "K")
|
||||
_rect(g, 8, 7, 10, 11, "w") # ribcage
|
||||
_hline(g, 8, 10, 8, "K"); _hline(g, 8, 10, 10, "K")
|
||||
_vline(g, 9, 7, 11, "K") # spine
|
||||
_vline(g, 12, 5, 11, "b"); _set(g, 12, 4, "y"); _set(g, 12, 5, "y") # quiver
|
||||
_vline(g, 8, 12, 14, "w"); _vline(g, 10, 12, 14, "w") # legs
|
||||
return g
|
||||
|
||||
|
||||
def _orc_warrior():
|
||||
g = _blank()
|
||||
_disc(g, 8, 5, 3.1, 2.7, "R") # head
|
||||
_disc(g, 8, 4, 2.3, 1.2, "r") # crown highlight
|
||||
_set(g, 7, 5, "o"); _set(g, 9, 5, "o") # eyes
|
||||
_set(g, 7, 7, "w"); _set(g, 9, 7, "w") # tusks
|
||||
_set(g, 7, 8, "w"); _set(g, 9, 8, "w")
|
||||
_rect(g, 4, 8, 12, 9, "R") # shoulder plate
|
||||
_set(g, 4, 8, "r"); _set(g, 12, 8, "r")
|
||||
_rect(g, 5, 9, 11, 13, "r") # torso
|
||||
_rect(g, 5, 9, 11, 9, "R")
|
||||
_hline(g, 5, 12, 11, "K") # belt
|
||||
_line(g, 13, 13, 13, 4, "w") # great blade
|
||||
_line(g, 12, 13, 12, 4, "K") # edge
|
||||
_set(g, 13, 13, "y") # pommel
|
||||
_rect(g, 6, 13, 7, 14, "R"); _rect(g, 9, 13, 10, 14, "R")
|
||||
return g
|
||||
|
||||
|
||||
def _wraith():
|
||||
g = _blank()
|
||||
_disc(g, 8, 6, 3.6, 3.5, "P") # hood (dark purple)
|
||||
_disc(g, 8, 5, 2.7, 2.0, "p") # hood light
|
||||
_disc(g, 8, 7, 1.9, 1.7, "K") # face void
|
||||
_set(g, 7, 6, "E"); _set(g, 9, 6, "E") # glowing eyes
|
||||
_rect(g, 5, 9, 11, 12, "P") # cloak
|
||||
# tattered hem (no legs)
|
||||
_set(g, 5, 13, "p"); _set(g, 7, 13, "P"); _set(g, 9, 13, "p"); _set(g, 11, 13, "P")
|
||||
_set(g, 6, 14, "p"); _set(g, 10, 14, "p")
|
||||
_set(g, 4, 10, "P"); _set(g, 12, 10, "P") # wisps
|
||||
return g
|
||||
|
||||
|
||||
def _slime():
|
||||
g = _blank()
|
||||
for y in range(6, 13):
|
||||
for x in range(3, 13):
|
||||
dx = (x - 8) / 4.7
|
||||
dy = (y - 9) / 3.3
|
||||
if dx * dx + dy * dy <= 1.0:
|
||||
g[y][x] = "g"
|
||||
_hline(g, 3, 12, 12, "G") # darker base
|
||||
_set(g, 6, 7, "w"); _set(g, 7, 8, "w") # gloss
|
||||
_disc(g, 6, 10, 1.3, 1.4, "w"); _disc(g, 10, 10, 1.3, 1.4, "w") # googly eyes
|
||||
_set(g, 6, 10, "K"); _set(g, 10, 10, "K")
|
||||
_set(g, 8, 13, "g"); _set(g, 8, 14, "g") # drip
|
||||
return g
|
||||
|
||||
|
||||
def _small_slime():
|
||||
g = _blank()
|
||||
for y in range(7, 14):
|
||||
for x in range(4, 12):
|
||||
dx = (x - 8) / 3.8
|
||||
dy = (y - 10) / 3.4
|
||||
if dx * dx + dy * dy <= 1.0:
|
||||
g[y][x] = "g"
|
||||
_hline(g, 4, 11, 13, "G") # base
|
||||
_set(g, 6, 8, "w"); _set(g, 7, 9, "w") # gloss
|
||||
_disc(g, 6, 10, 1.1, 1.2, "w"); _disc(g, 10, 10, 1.1, 1.2, "w") # big eyes
|
||||
_set(g, 6, 10, "K"); _set(g, 10, 10, "K")
|
||||
_set(g, 8, 13, "g") # drip
|
||||
_hline(g, 7, 9, 12, "G") # smile
|
||||
return g
|
||||
|
||||
|
||||
def _dragon():
|
||||
g = _blank()
|
||||
# spread wings (membrane triangles)
|
||||
_tri(g, 6, 7, 0, 4, 1, 10, "R")
|
||||
_tri(g, 6, 7, 0, 4, 1, 10, "R")
|
||||
_tri(g, 10, 7, 15, 4, 14, 10, "R")
|
||||
_tri(g, 10, 7, 15, 4, 14, 10, "R")
|
||||
_set(g, 0, 4, "r"); _set(g, 15, 4, "r") # wingtips
|
||||
_set(g, 2, 6, "r"); _set(g, 13, 6, "r") # membrane ribs
|
||||
# body + head
|
||||
_disc(g, 8, 9, 3.5, 3.3, "r")
|
||||
_disc(g, 8, 8, 2.7, 1.8, "R")
|
||||
_disc(g, 8, 5, 3.1, 2.7, "r")
|
||||
# horns
|
||||
_line(g, 6, 3, 4, 0, "y"); _line(g, 10, 3, 12, 0, "y")
|
||||
# snout + fangs
|
||||
_rect(g, 7, 5, 9, 6, "R")
|
||||
_set(g, 7, 7, "w"); _set(g, 9, 7, "w")
|
||||
_set(g, 7, 4, "o"); _set(g, 9, 4, "o") # eyes
|
||||
_set(g, 7, 6, "K"); _set(g, 9, 6, "K") # nostrils
|
||||
# scales + belly
|
||||
for sx, sy in ((7, 9), (9, 9), (8, 10), (6, 10), (10, 10)):
|
||||
_set(g, sx, sy, "o")
|
||||
_rect(g, 7, 10, 9, 12, "o")
|
||||
# tail + legs
|
||||
_line(g, 8, 12, 8, 15, "R")
|
||||
_rect(g, 6, 12, 7, 14, "R"); _rect(g, 9, 12, 10, 14, "R")
|
||||
return g
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Items — pixel-art icons with category accent hues.
|
||||
# --------------------------------------------------------------------------- #
|
||||
def _dagger():
|
||||
g = _blank()
|
||||
_tri(g, 7, 2, 9, 2, 8, 7, "w") # short wide blade (clearly a dagger)
|
||||
_set(g, 7, 2, "K"); _set(g, 9, 2, "K")
|
||||
_vline(g, 8, 3, 6, "K") # fuller
|
||||
_hline(g, 6, 10, 8, "y") # guard
|
||||
_vline(g, 8, 9, 12, "h"); _set(g, 8, 12, "y") # handle + pommel
|
||||
return g
|
||||
|
||||
|
||||
def _sword():
|
||||
g = _blank()
|
||||
_line(g, 8, 1, 8, 9, "w"); _line(g, 7, 1, 7, 9, "K")
|
||||
_hline(g, 5, 11, 9, "y")
|
||||
_vline(g, 8, 10, 13, "h"); _set(g, 8, 13, "y")
|
||||
return g
|
||||
|
||||
|
||||
def _axe():
|
||||
g = _blank()
|
||||
_vline(g, 7, 2, 14, "h") # handle
|
||||
_tri(g, 7, 3, 13, 2, 7, 7, "w") # head
|
||||
_set(g, 13, 2, "K"); _set(g, 12, 3, "K")
|
||||
_set(g, 7, 14, "y")
|
||||
return g
|
||||
|
||||
|
||||
def _hammer():
|
||||
g = _blank()
|
||||
_vline(g, 8, 5, 14, "h")
|
||||
_rect(g, 5, 2, 11, 5, "w")
|
||||
_frame(g, 5, 2, 11, 5, "K")
|
||||
_set(g, 8, 14, "y")
|
||||
return g
|
||||
|
||||
|
||||
def _leather():
|
||||
g = _blank()
|
||||
_disc(g, 8, 8, 4.1, 4.3, "s")
|
||||
_disc(g, 8, 7, 3.0, 2.6, "W")
|
||||
_vline(g, 6, 5, 12, "h"); _vline(g, 10, 5, 12, "h") # straps
|
||||
_hline(g, 4, 12, 11, "h")
|
||||
_set(g, 8, 8, "y") # buckle
|
||||
return g
|
||||
|
||||
|
||||
def _chain():
|
||||
g = _blank()
|
||||
_disc(g, 8, 4, 2.6, 2.2, "b") # coif (mail hood)
|
||||
_disc(g, 8, 5, 1.3, 1.1, "K") # face opening
|
||||
# hauberk torso: broad shoulders tapering to a waist (rows: y -> x-range)
|
||||
for y, (a, b) in ((6, (4, 12)), (7, (4, 12)), (8, (5, 11)), (9, (5, 11)),
|
||||
(10, (6, 10)), (11, (6, 10)), (12, (6, 10)), (13, (6, 10))):
|
||||
_hline(g, a, b, y, "b")
|
||||
_hline(g, 4, 11, 6, "w") # collar
|
||||
for y in range(6, 13): # interlocking ring texture
|
||||
for x in range(4, 13):
|
||||
if g[y][x] == "b" and (x + y) % 2 == 0:
|
||||
_set(g, x, y, "w")
|
||||
return g
|
||||
|
||||
|
||||
def _plate():
|
||||
g = _blank()
|
||||
_disc(g, 4, 6, 1.8, 1.6, "w"); _disc(g, 11, 6, 1.8, 1.6, "w") # pauldrons
|
||||
# breastplate torso: broad chest tapering to a waist
|
||||
for y, (a, b) in ((6, (4, 11)), (7, (4, 11)), (8, (5, 10)), (9, (5, 10)),
|
||||
(10, (5, 10)), (11, (6, 9)), (12, (6, 9)), (13, (6, 9))):
|
||||
_hline(g, a, b, y, "w")
|
||||
_disc(g, 6, 8, 1.7, 1.5, "w"); _disc(g, 10, 8, 1.7, 1.5, "w") # pec domes
|
||||
_set(g, 6, 8, "c"); _set(g, 10, 8, "c") # steel highlights
|
||||
_vline(g, 8, 7, 13, "K") # center ridge
|
||||
_hline(g, 6, 9, 12, "K") # belt
|
||||
for x, y in ((5, 7), (10, 7)):
|
||||
_set(g, x, y, "b") # rivets
|
||||
return g
|
||||
|
||||
|
||||
def _potion(color):
|
||||
def draw():
|
||||
g = _blank()
|
||||
_vline(g, 6, 3, 5, "w"); _vline(g, 10, 3, 5, "w") # neck
|
||||
_hline(g, 6, 10, 3, "w")
|
||||
_set(g, 8, 2, "h") # cork
|
||||
_disc(g, 8, 9, 3.3, 3.3, "w") # flask
|
||||
_disc(g, 8, 9, 2.5, 2.5, color) # liquid
|
||||
_set(g, 7, 8, "w") # gloss
|
||||
return g
|
||||
return draw
|
||||
|
||||
|
||||
def _scroll(emblem):
|
||||
def draw():
|
||||
g = _blank()
|
||||
# rolled scroll: horizontal cylinder with capped ends
|
||||
_rect(g, 3, 7, 12, 11, "c") # paper body
|
||||
_hline(g, 3, 12, 7, "b"); _hline(g, 3, 12, 11, "b") # roll shading
|
||||
_disc(g, 3, 9, 1.2, 2.6, "b"); _disc(g, 12, 9, 1.2, 2.6, "b") # end knobs
|
||||
_disc(g, 3, 9, 0.7, 1.7, "c"); _disc(g, 12, 9, 0.7, 1.7, "c")
|
||||
_vline(g, 7, 6, 12, "y"); _vline(g, 8, 6, 12, "y") # tie ribbon
|
||||
emblem(g) # floating magic emblem up top
|
||||
return g
|
||||
return draw
|
||||
|
||||
|
||||
def _emblem_fireball(g):
|
||||
_tri(g, 5, 5, 11, 5, 8, 0, "o") # flame
|
||||
_set(g, 8, 1, "y"); _set(g, 7, 2, "y"); _set(g, 9, 2, "y")
|
||||
_set(g, 8, 3, "r")
|
||||
|
||||
|
||||
def _emblem_teleport(g):
|
||||
_vline(g, 8, 1, 5, "E"); _hline(g, 6, 10, 3, "E") # 4-point star
|
||||
_set(g, 6, 1, "c"); _set(g, 10, 1, "c"); _set(g, 6, 5, "c"); _set(g, 10, 5, "c")
|
||||
_set(g, 8, 3, "w")
|
||||
|
||||
|
||||
def _emblem_mapping(g):
|
||||
_frame(g, 5, 1, 11, 5, "b") # map frame
|
||||
_hline(g, 6, 10, 2, "c")
|
||||
_set(g, 6, 3, "y"); _set(g, 9, 4, "y") # landmarks
|
||||
_line(g, 6, 3, 10, 4, "c") # road
|
||||
|
||||
|
||||
def _stairs():
|
||||
g = _blank()
|
||||
_rect(g, 1, 11, 14, 14, "y") # bottom landing
|
||||
_rect(g, 1, 9, 12, 11, "y") # mid step
|
||||
_rect(g, 1, 7, 10, 9, "y") # upper step
|
||||
_rect(g, 1, 5, 8, 7, "y") # top step
|
||||
_hline(g, 1, 14, 11, "o"); _hline(g, 1, 12, 9, "o") # lit tread edges
|
||||
_hline(g, 1, 10, 7, "o"); _hline(g, 1, 8, 5, "o")
|
||||
_hline(g, 1, 14, 14, "K") # base shadow
|
||||
_line(g, 5, 2, 9, 4, "w"); _line(g, 9, 4, 5, 4, "w") # down-chevron into the hole
|
||||
_set(g, 9, 4, "y")
|
||||
return g
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Registry
|
||||
# --------------------------------------------------------------------------- #
|
||||
def _build() -> dict[str, list[list[str]]]:
|
||||
s: dict[str, list[list[str]]] = {}
|
||||
s["player"] = s["player_down"] = _eframes(_player_down())
|
||||
s["player_up"] = _eframes(_player_up())
|
||||
s["player_right"] = _eframes(_player_right())
|
||||
s["player_left"] = _eframes(_flip(_player_right()))
|
||||
|
||||
for name, fn in (
|
||||
("rat", _rat), ("goblin", _goblin), ("skeleton_archer", _skeleton_archer),
|
||||
("orc_warrior", _orc_warrior), ("wraith", _wraith), ("green_slime", _slime),
|
||||
("small_slime", _small_slime), ("ancient_dragon", _dragon),
|
||||
):
|
||||
s[name] = _eframes(fn())
|
||||
|
||||
for name, fn in (
|
||||
("weapon_dagger", _dagger), ("weapon_sword", _sword),
|
||||
("weapon_axe", _axe), ("weapon_hammer", _hammer),
|
||||
("armor_leather", _leather), ("armor_chain", _chain),
|
||||
("armor_plate", _plate),
|
||||
):
|
||||
s[name] = _iframe(fn())
|
||||
|
||||
s["potion_healing"] = _iframe(_potion("m")())
|
||||
s["potion_strength"] = _iframe(_potion("o")())
|
||||
s["potion_invisibility"] = _iframe(_potion("p")())
|
||||
s["scroll_fireball"] = _iframe(_scroll(_emblem_fireball)())
|
||||
s["scroll_teleport"] = _iframe(_scroll(_emblem_teleport)())
|
||||
s["scroll_mapping"] = _iframe(_scroll(_emblem_mapping)())
|
||||
|
||||
s["stairs"] = _eframes(_stairs())
|
||||
return s
|
||||
|
||||
|
||||
SPRITES: dict[str, list[list[str]]] = _build()
|
||||
NAMES: list[str] = sorted(SPRITES.keys())
|
||||
|
||||
|
||||
def frames_count(name: str) -> int:
|
||||
return len(SPRITES[name]) if name in SPRITES else 1
|
||||
|
||||
|
||||
def grid(name: str, frame: int = 0) -> list[str]:
|
||||
"""Return the frame's row list for `name` (frame wraps modulo count)."""
|
||||
frames = SPRITES.get(name)
|
||||
if not frames:
|
||||
return ["................"] * SIZE
|
||||
return frames[frame % len(frames)]
|
||||
|
||||
|
||||
if __name__ == "__main__": # tiny self-check
|
||||
for n in NAMES:
|
||||
grd = grid(n, 0)
|
||||
assert len(grd) == SIZE and all(len(r) == SIZE for r in grd), n
|
||||
print(f"{len(NAMES)} sprites, all {SIZE}x{SIZE}: {', '.join(NAMES)}")
|
||||
Reference in new issue
Block a user