This file provides guidance to Claude Code when working with code in this repository.
JackGames Multicart is a PyGame-based collection of games built for a nephew named Jack. The project features multiple mini-games in a single executable, supporting both desktop (Windows/Linux/macOS) and web browsers via PyGame CE and pygbag.
The game uses a scene stack system where scenes are managed by the Game class:
- Scene Stack: Scenes can be pushed, popped, or replaced using
game.scene_push,game.scene_pop,game.scene_replace,game.scene_push_under - Scene Base Class: All scenes inherit from
Sceneclass inscene.pywhich provides common functionality - Scene Loading: Scenes are dynamically loaded using
eval("scenes." + scene_name + "(self)")pattern
- Game: Main game loop, input handling, scene management, and configuration
- Scene: Base class for all game scenes with drawing utilities, text rendering, and sound management
- FastText: Optimized text rendering system that only re-renders when text changes
- Button: UI button class with hover and click states
- SpriteSheet: Utility for managing sprite sheet assets
The project uses multiple settings files that are swapped during build:
settings.py- Current active settings (never edit directly)settings-win.py- Desktop/Windows settingssettings-wasm.py- Web browser settings via pygbag
This project uses uv for Python package and virtual environment management.
# Install dependencies and create virtual environment
uv sync
# Add a new dependency
uv add <package># Run the main game
uv run main.py
# Create a new scene
uv run main.py scene new
# List all available scenes
uv run main.py scene list# Build Windows executable
build-win.bat
# Build for web browsers
build-web.bat# Generate color palette CSV from image folder
uv run swappy.py <source_folder> <output.csv>
# Apply palette swap using CSV
uv run swappy.py <source_folder> <palette.csv> <target_folder># Install server dependencies (fastapi, uvicorn, psycopg, etc.)
uv pip install -r requirements.txt
# Run the multiplayer game server
uv run qbfastapi.py
# Server runs on port 8000 by default, or PORT environment variable- Create scene using
python main.py scene new - Implement
update()anddraw()methods - Scene is automatically imported in
scenes/__init__.py - Add to game selection logic as needed
game.pressed- Current key statesgame.just_pressed- Keys pressed this framegame.just_released- Keys released this framegame.just_mouse_down/up- Mouse button events
- Images:
self.load_png("filename.png")returns image and rect - Sounds: Automatically loaded from
assets/sounds/intogame.sfxdict - Music:
self.play_music("path/in/assets")
- Quick text:
self.standard_text("Hello")using scene defaults - Custom text:
self.make_text(text, color, fontSize, font, stroke options) - Dynamic text:
self.Text("Hello", (x,y), anchor)returns FastText object
- Press backtick (`) to open/close console
- Add commands to scenes via
self.commandsdict - Console provides logging and debugging capabilities
- Built-in console commands:
helpor?- Show help and available commandsclear- Clear console outputdebug- Toggle debug modescene list- List scenes in the scene stackscene len- Show scene stack lengthscene init- Reinitialize the scene under consoleexitorquit- Quit the game- Any Python code can be executed directly
- Upheaval font looks best at multiples of 20px
- Default fonts:
upheavtt.ttf(main),TeenyTinyPixls-o2zo.ttf(small)
- Build scripts swap settings files automatically
- PyInstaller used for Windows builds
- pygbag used for web builds
- Assets folder must be copied to distribution
- 640x360 resolution (16:9 aspect ratio)
- 60 FPS target
- Built-in performance monitoring in debug mode
- Frame load percentage displayed when
DEBUG = True
The QuadBlox multiplayer game includes a FastAPI server that can be deployed to fly.io or Railway:
- PostgreSQL database required for leaderboards
- Environment variable
DATABASEfor connection string - Environment variable
PORTfor server port (defaults to 8000)