How jayparmar1301/retro-pixel-platformer works
Project type and purpose
• This is a single-page, browser‐based 2D pixel art platformer game built on Streamlit (a Python web app framework).
• It provides retro gaming mechanics—random level generation, player movement, collision detection, scoring—entirely in-memory with no external database or microservices.
File structure
• Top level:
• README.md – overview, setup, technologies
• app.py – the entire Streamlit application (UI + game logic)
• requirements.txt – dependencies (streamlit, PIL, etc.)
• No separate backend/frontend directories; Streamlit merges UI and server logic in one process.
README for additional insights
• Core technologies: Streamlit for UI/event loop, PIL for pixel graphics.
• Game features hint at internal modules (randomized level generator, asset loader, input controls, scoring, game‐over logic).
Main components
a. User Client (Browser)
• Streams UI to and from Streamlit server.
b. Streamlit Server (app.py)
• Entry point and event loop. Handles HTTP<–>Python bridge.
c. Game Engine Module (subsystems inside app.py)
1. Input Handler
– Captures button presses (←, →, ↑) via Streamlit widgets.
2. Physics & Collision Logic
– Updates player position, platform collisions, fall detection.
3. Level Generator
– Randomly places platforms, coins, special gems per level.
4. Asset Manager
– Loads and caches pixel art sprites via PIL.
5. Score & Lives Manager
– Tracks collected items, calculates score, decrements lives.
6. Game State Controller
– Manages level transitions and game‐over conditions.
d. Rendering Module
– Converts to an image object that Streamlit displays.
e. External Dependencies
– PIL (Python Imaging Library)
– Streamlit runtime (handles web server, UI rendering, session state)
Relationships & interactions
• User Client sends input events → Streamlit Server
• Streamlit Server invokes Input Handler → Physics & Game State → Rendering Module
• Rendering Module produces an image → Streamlit Server → User Client display
• Level Generator and Asset Manager feed into Physics & Rendering subsystems
• Score Manager updates UI widgets for display
Architectural patterns & design principles
• Single-process, event-driven loop (Streamlit’s rerun-per-interaction model)
• Modular separation within app.py: clearly distinguish “game logic” vs. “UI layer” vs. “rendering engine”
• Stateless UI calls with state persisted in Streamlit’s Session State
• In-memory data—no external persistence
• Clear labels on every component and subsystem