A Python game engine with physics, rendering, and input systems
Project description
PyG Engine
A Python game engine built on Pygame and Pymunk for 2D physics, rendering, and game development. Inspired by the Unity game engine's Monobehavior system with scriptable game objects, rigidbody and collider system. Built-in physics materials, update system, event system and mouse+keyboard input system. Built-in window resizing.
NOTE: This is in alpha development stage. Everything is under active development and large changes will likely be made. Also, its pronounced pig engine :)
Features
- OOP Model: Simple game object implementation system
- 2D Physics: Built-in physics via Pymunk
- Input: Mouse, keyboard, and joystick input handling
- Components: Modular component-based architecture
- Scripts: Dynamic script loading and execution
- Camera: Flexible camera with multiple scaling modes
- Event System: Thread-safe event-driven communication with priority-based handling
- Documentation: Comprehensive CORE_SYSTEMS_GUIDE with examples and best practices
Installation
Requires Python 3.7+.
Dependencies:
- pygame >= 2.5.0
- pymunk >= 6.4.0
Install via pip:
pip install pyg-engine
Or install from source:
git clone <repository-url>
cd pyg-engine
pip install -e .
Quick Start
from pyg_engine import Engine, GameObject, Size
from pygame import Color, Vector2
# Create the engine
engine = Engine(
size=Size(w=800, h=600),
backgroundColor=Color(0, 0, 0),
windowName="My Game"
)
# Create a game object (supports both tuple and Vector2 formats)
player = GameObject(
name="Player",
position=(400, 300), # Can use tuple
size=(50, 50), # Can use tuple
color=Color(255, 0, 0)
)
# Alternative using Vector2 objects:
# player = GameObject(
# name="Player",
# position=Vector2(400, 300),
# size=Vector2(50, 50),
# color=Color(255, 0, 0)
# )
# Add to engine
engine.addGameObject(player)
# Start the game loop
engine.start()
Examples
Run examples directly:
# List all available examples
python examples/__init__.py
# Run a specific example
python examples/basic_example.py
python examples/test.py
python examples/enhanced_mouse_example.py
python examples/enum_event_example.py
python examples/main.py
python examples/snake_game.py
python examples/performance_analysis.py
python examples/performance_test.py
python examples/visual_runnable_demo.py
Available examples:
basic_example.py- Basic engine setup and object creationtest.py- Basic gameobject creation, components, and scriptsmain.py- Complete physics demo with collision detection, input, multiple game objects, and physics materialsenhanced_mouse_example.py- Advanced mouse interactions with physicsenum_event_example.py- Enum-based event handling examplesnake_game.py- Simple snake game demoperformance_analysis.py- Performance profiling and analysisperformance_test.py- Performance test scenariosvisual_runnable_demo.py- Visual demo with runnablesmouse_test.py- Mouse input testing and validationinput_test.py- Input system testing and validationusing_no_display.py- Headless engine operation without displayglobal_dictionary_test.py- Global dictionary system testingrunnable_demo.py- Runnable system demonstration and testing
Documentation
See the docs/ directory for detailed guides:
CORE_SYSTEMS_GUIDE.md- Comprehensive guide to engine architecture, systems, and usage
Testing
Run the test suite (tests are located in the tests/ directory):
cd pyg_engine
python -m pytest tests/
Development
To set up the development environment:
pip install -e .
TODO
Known Bugs/QOL Issues:
QOL:
- Components should be separate objects that can be passed into the add_component() function
- Discrepancies in sizing. Box colliders should accept Size() or Tuples.
- Needs better debug logs + distinguish between errors and console outputs
- Need a texture system
BUGS:
- Theres definitely some, but idk yet. Need to search more.
In Development:
- Sprite rendering and physics
- State machine
- Animation system
- Sprite colliders
- Audio system
- Coroutines and async services
- More basic shapes
Planned:
- Debug interface
- File storage system
- 2D lighting system
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
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 pyg_engine-1.0.0a5.tar.gz.
File metadata
- Download URL: pyg_engine-1.0.0a5.tar.gz
- Upload date:
- Size: 91.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c202deb47fb6e69d5ebdad2d518300683baa9ad0f306fd466cae563502b6977e
|
|
| MD5 |
a83ee2751a1bda9a189f122a83c4d005
|
|
| BLAKE2b-256 |
632afda80017592570c3442ec5f049162a109a2b4bcdcb8216a8a2be65876b72
|
Provenance
The following attestation bundles were made for pyg_engine-1.0.0a5.tar.gz:
Publisher:
publish-to-pypi.yml on aram-ap/pyg-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyg_engine-1.0.0a5.tar.gz -
Subject digest:
c202deb47fb6e69d5ebdad2d518300683baa9ad0f306fd466cae563502b6977e - Sigstore transparency entry: 343959913
- Sigstore integration time:
-
Permalink:
aram-ap/pyg-engine@a7ec0ed59a0154b19f18436bdcd45e57f7140e86 -
Branch / Tag:
refs/tags/v1.0.0a5 - Owner: https://github.com/aram-ap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a7ec0ed59a0154b19f18436bdcd45e57f7140e86 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyg_engine-1.0.0a5-py3-none-any.whl.
File metadata
- Download URL: pyg_engine-1.0.0a5-py3-none-any.whl
- Upload date:
- Size: 45.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f893bf50877daf1e039c37fcd7ed8530572f45471e54f6fd975495c9d1baf25
|
|
| MD5 |
89d5e628959cb320dfd6d633a39b6c6b
|
|
| BLAKE2b-256 |
8ff4330b89256111b742d500c17b9d44e7756df0dd80f6a5cbe7ade5fc8b28e3
|
Provenance
The following attestation bundles were made for pyg_engine-1.0.0a5-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on aram-ap/pyg-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyg_engine-1.0.0a5-py3-none-any.whl -
Subject digest:
0f893bf50877daf1e039c37fcd7ed8530572f45471e54f6fd975495c9d1baf25 - Sigstore transparency entry: 343959940
- Sigstore integration time:
-
Permalink:
aram-ap/pyg-engine@a7ec0ed59a0154b19f18436bdcd45e57f7140e86 -
Branch / Tag:
refs/tags/v1.0.0a5 - Owner: https://github.com/aram-ap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a7ec0ed59a0154b19f18436bdcd45e57f7140e86 -
Trigger Event:
release
-
Statement type: