config.pyΒΆ

Part of Clumsy Bird.

 1"""Shared constants and asset paths for Clumsy Bird."""
 2
 3from pathlib import Path
 4
 5# ----------------------------------------------------------------------------
 6# Layout: original game runs at 900x600. We match that so the asset PNGs
 7# (bg.png 900x504, ground.png 900x96) tile and align without scaling.
 8# ----------------------------------------------------------------------------
 9WIDTH = 900
10HEIGHT = 600
11GROUND_HEIGHT = 96
12GROUND_Y = HEIGHT - GROUND_HEIGHT  # top of the ground strip
13
14# ----------------------------------------------------------------------------
15# Bird tunables (translated from the MelonJS source's per-tick deltas into
16# proper per-second physics so the game is framerate-independent).
17# Original: gravity 0.2 px/tick @ ~60Hz, flap = -72 px instantaneous step.
18# ----------------------------------------------------------------------------
19BIRD_X = 120
20GRAVITY = 1500.0
21FLAP_IMPULSE = 480.0
22MAX_FALL_SPEED = 700.0
23
24# ----------------------------------------------------------------------------
25# Pipes: original vel.x = -5 px/tick (~300 px/s), spawn every 92 ticks
26# (~1.53s), gap 240 px between pipe rims (1240 px gap value in the source
27# refers to the literal sprite-distance between top + bottom pipe sprites,
28# which are 1664 px tall sliding-door images. Our gap is the visible hole
29# between them.)
30# ----------------------------------------------------------------------------
31PIPE_WIDTH = 148
32PIPE_HEIGHT = 1664  # source sprite height; far taller than the screen
33PIPE_SCROLL_SPEED = 220.0
34PIPE_GAP = 200.0  # vertical hole height
35PIPE_SPAWN_INTERVAL = 1.6
36PIPE_MIN_TOP = 80  # smallest top-pipe length (so hole isn't at the ceiling)
37PIPE_MAX_TOP = 300  # largest top-pipe length
38
39GROUND_SCROLL_SPEED = 220.0  # match pipe speed so ground & pipes move together
40
41# ----------------------------------------------------------------------------
42# Asset directory: resolved relative to this file, so the path stays valid
43# regardless of cwd when a user runs the game from any directory.
44# ----------------------------------------------------------------------------
45ASSETS = (Path(__file__).parent / "assets").resolve()