Files
battery/main.py

53 lines
1.6 KiB
Python
Raw Normal View History

2026-07-21 19:36:02 -04:00
#!/usr/bin/env python3
"""Dying Phone — a single-screen 2D platformer of ridiculous traps.
Story: your phone is dying. Reach the charger at the end of each level before
the battery runs out. The level is littered with obvious and (mostly) hidden
traps. Touch one and you're instantly respawned at the start — traps reset.
Controls:
A / D (or arrows) move
Space / W / Up jump (hold for higher, tap for a hop)
S + Space drop through one-way platforms
R give up and respawn
Esc quit
Usage:
python main.py # play every level in ./levels
python main.py levels/foo.yaml [more.yaml ...] # play specific levels
python main.py --debug # force debug view on for all levels
"""
import os
import sys
from game.game import Game, discover_levels
ROOT = os.path.dirname(os.path.abspath(__file__))
def main():
args = sys.argv[1:]
debug = "--debug" in args
args = [a for a in args if a != "--debug"]
if args:
level_paths = [os.path.abspath(p) for p in args]
else:
level_paths = discover_levels(os.path.join(ROOT, "levels"))
if not level_paths:
print("No levels found. Add a .yaml level file to the levels/ directory.")
sys.exit(1)
missing = [p for p in level_paths if not os.path.isfile(p)]
if missing:
print("Level file(s) not found:", *missing, sep="\n ")
sys.exit(1)
assets_dir = os.path.join(ROOT, "assets")
Game(level_paths, assets_dir, debug=debug).run()
if __name__ == "__main__":
main()