Skip to main content

A Python game engine with physics, rendering, and input systems

Project description

Pyg Engine

A Python game engine built with 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, 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: Easy and simple game object implementation system. Create players, environment, enemies, etc. with ease
  • 2D Physics: Built-in physics via Pymunk
  • Input: Mouse and keyboard input handling
  • Components: Modular component-based architecture
  • Scripts: Dynamic script loading and execution
  • Camera: Flexible camera with multiple scaling modes
  • Collision: Advanced collision detection and response

Installation

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/mouse_example.py
python examples/enhanced_mouse_example.py
python examples/simple_drag_test.py

Available examples:

  • basic_example.py - Basic engine setup and object creation
  • test.py - An example script into basic gameobject creation, components, and scripts
  • main.py - Complete physics demo with collision detection, mouse and keyboard input, multiple game objects, and physics materials.
  • enhanced_mouse_example.py - Advanced mouse interactions with physics
  • mouse_example.py - Mouse input handling and interaction

Documentation

See the docs/ directory for detailed guides:

  • README.md - General documentation
  • PHYSICS_CONTROLS_GUIDE.md - Physics system guide
  • MOUSE_INPUT_GUIDE.md - Input system guide
  • SPRITE_SYSTEM_UPGRADE.md - Sprite system documentation

Testing

Run the test suite:

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.
  • Scripts and Components need better documentation
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyg_engine-1.0.0a3.tar.gz (63.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyg_engine-1.0.0a3-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

File details

Details for the file pyg_engine-1.0.0a3.tar.gz.

File metadata

  • Download URL: pyg_engine-1.0.0a3.tar.gz
  • Upload date:
  • Size: 63.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyg_engine-1.0.0a3.tar.gz
Algorithm Hash digest
SHA256 19fb3dc067d98b6ba34f349af5ec6d267aaba77bad06693cc4668981382b3c36
MD5 6c42ecf6d58e92b35ca1161d1021654f
BLAKE2b-256 8cec9049bc44b6751583e6fee1acc661aa03655a1364e8b1f248bfacd6b266ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyg_engine-1.0.0a3.tar.gz:

Publisher: publish-to-pypi.yml on aram-ap/pyg-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyg_engine-1.0.0a3-py3-none-any.whl.

File metadata

  • Download URL: pyg_engine-1.0.0a3-py3-none-any.whl
  • Upload date:
  • Size: 42.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyg_engine-1.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 352c321e46c9ea7b645b0701b24b6d016497b7bd4d16a93c3eb5654ba014b683
MD5 4ff4cf5380ded986264941b75d84cfc6
BLAKE2b-256 4a6f56718b43a8db90a8325f18865becc36af4ad0a270229f333e7f884f002c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyg_engine-1.0.0a3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on aram-ap/pyg-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page