yggame
yggame is a composable Python component library for building 2D games with Pygame-CE. It provides a headless-first runtime core, optional rendering adapters, scene management, input mapping, animation, collision helpers, UI primitives, inventory, dialogue, quests, AI, pathfinding, saves, and asset caching.
The project is being built as a production-oriented foundation. It intentionally favors tested contracts and useful implementations over generated line count. Large systems such as networking, skeletal animation, advanced lighting, and editor windows will be added behind stable interfaces rather than shipped as fragile placeholders.
Developer credit
Developer and maintainer: Yashraj Sachin Ghemud
This project, its public APIs, tests, examples, and release configuration are maintained under the name Yashraj Sachin Ghemud. Please retain this attribution when redistributing the project.
Installation
pip install yggame[dev]
# Add Pygame when building a graphical game:
pip install yggame[pygame]
The core package can be imported without Pygame, a display, or an audio device. This makes content validation, save migrations, simulations, and automated tests safe in CI and server environments.
Quick start
from yggame import Game
from yggame.core import BaseSystem
class Simulation(BaseSystem):
def update(self, delta: float) -> None:
super().update(delta)
# Advance gameplay here using a fixed simulation delta.
def draw(self, target, interpolation: float = 0.0) -> None:
pass
if __name__ == '__main__':
game = Game(fixed_delta=1 / 60)
game.add_system(Simulation())
game.run(frames=1)
Example composition
from yggame.core import Rect, Vec2
from yggame.input import InputMap
from yggame.physics import CollisionGrid, PlatformerBody
from yggame.ui import HealthBar
controls = InputMap()
controls.bind('move_left', 'keyboard:a')
controls.bind('move_right', 'keyboard:d')
controls.bind('jump', 'keyboard:space')
world = CollisionGrid(80, 30, tile_size=32)
player = PlatformerBody(Rect(96, 128, 24, 40))
health = HealthBar(maximum=100)
Public subsystem map
| Namespace | Responsibility | Headless by default |
|---|---|---|
yggame.core |
Game loop, context, events, timing, ECS, geometry, config, pooling | Yes |
yggame.render |
Layered render queue and viewport transforms | Queue yes; drawing adapter optional |
yggame.scenes |
Scene registry, stack navigation, transitions | Yes |
yggame.camera |
Follow camera, bounds, zoom, screen shake | Yes |
yggame.physics |
Collision grids, spatial hash, raycasts, movement bodies | Yes |
yggame.ui |
Retained UI tree and common widgets | Yes |
yggame.anim |
Tweens and frame animation state machines | Yes |
yggame.inventory |
Items, stacks, equipment, crafting, loot | Yes |
yggame.dialogue |
Dialogue trees, choices, quests | Yes |
yggame.ai |
FSM and behavior trees | Yes |
yggame.world |
A* and flow fields | Yes |
yggame.save |
Versioned save files and autosave | Yes |
yggame.assets |
Cached asset loading and hot reload | Yes |
Quality policy
Every public subsystem should have deterministic unit tests, explicit error behavior, and at least one runnable example before being treated as stable. Optional integrations must be isolated so importing the package never requires them. Data files carry schema versions, and public constructors prefer keyword-only extension points to reduce accidental breaking changes.
License
MIT. See LICENSE.
Five runnable demo games
The repository includes five deterministic, headless-first demo games under examples/yggame_demos/. Each demo is a small but complete vertical slice rather than a disconnected API snippet: it owns gameplay state, accepts typed commands, produces a transcript result, renders a terminal board, and composes multiple yggame subsystems.
| Demo | Category | Representative yggame systems |
|---|---|---|
| Skybound Runner | Platformer action | PlatformerBody, CollisionGrid, Camera2D, Health, particles |
| Neon Swarm | Top-down arena survival | TopDownBody, SpatialHash, steering agents, encounter waves, stats, status effects |
| Emberdeep | Roguelike dungeon crawler | BSP rooms, inventory, equipment, weighted loot, stats, recovery checkpoints |
| Last Bastion | Tower-defense strategy | Tilemap, A*, encounter scheduler, cooldowns, health, economy |
| The Missing Signal | Narrative detective RPG | Dialogue parser/session, quest system, content registry, saves, telemetry |
Run the launcher from the repository root:
python3 examples/run_demos.py list
python3 examples/run_demos.py skybound --board
python3 examples/run_demos.py swarm --steps 12 --board
python3 examples/run_demos.py emberdeep --commands 'explore,explore,fight,loot,save' --board
python3 examples/run_demos.py bastion --commands 'build 5,4,build 8,4,wait,wait' --board
python3 examples/run_demos.py signal --commands 'talk,choose 0,inspect dock,talk,choose 1,inspect frequency,travel relay,inspect blueprint,report'
The examples do not require a display or Pygame installation for their scripted scenarios. They are intended to be extended into graphical scenes by replacing the terminal render_text() implementations with yggame render queues and an optional Pygame adapter. The shared DemoGame protocol in examples/yggame_demos/base.py is deliberately small enough to use as a test seam for future graphical front ends.
Verification
Run the complete headless quality gate with:
ruff check src tests examples
mypy src/yggame
python3 -m pytest -q
Release verification
From a clean checkout, the release workflow is:
python -m pip install -e '.[dev]'
ruff check src tests examples
mypy src/yggame
python -m pytest -q
python -m build
python -m twine check dist/*
The package is headless-first and can be installed without Pygame. Optional integrations are available through the pygame, physics, network, localization, and all extras.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yggame-0.2.0.tar.gz.
File metadata
- Download URL: yggame-0.2.0.tar.gz
- Upload date:
- Size: 105.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c3b1d4b7463c810a766535ce9f59d8fd324020aa6a0669333061b2a5750e0f3
|
|
| MD5 |
803715d0111340e8c9268e98a437542e
|
|
| BLAKE2b-256 |
8490e445785414fe610e902c47c3b2f1dd73a02f75b4f8885c2bcb60ca74a998
|
File details
Details for the file yggame-0.2.0-py3-none-any.whl.
File metadata
- Download URL: yggame-0.2.0-py3-none-any.whl
- Upload date:
- Size: 125.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e566d3ef99f1ea6a759370329a11ccf4fbd9edd8d99444d3ba4f01be15e33e3
|
|
| MD5 |
cf0f4832da47208e1a1c8f3e4442dba1
|
|
| BLAKE2b-256 |
95b9c3fb2190a9acd10e9d99f8cd71be15460f08192789842c9a7707885350a9
|