Skip to main content

Python game engine featuring a event and data driven archictecture.

Project description

PyGuara

PyGuara is a modern, modular, and high-performance 2D game engine for Python 3.12+. It features a robust Entity-Component-System (ECS) architecture, a native Dependency Injection (DI) container, and a decoupled event-driven design, making it suitable for scalable and maintainable game development.

Note: This project is currently in Pre-Alpha. APIs are subject to change.

CI codecov PyPI version Python versions Ruff License

🚀 Key Features

  • ⚡ Performance-First ECS:
    • Optimized EntityManager using Inverted Indexes for $O(1)$ component queries.
    • Cache-friendly data layout designed to minimize Python overhead.
  • 💉 Native Dependency Injection:
    • Built-in DIContainer supporting Singleton, Transient, and Scoped lifetimes.
    • Automatic dependency resolution via Python type hints.
  • 🎨 Decoupled Rendering Pipeline:
    • Backend-agnostic design (currently supporting pygame-ce).
    • Support for Z-sorting, Batching, and efficient draw call management.
  • 📢 Event-Driven Architecture:
    • Protocol-based event system for loose coupling between subsystems (Input, Physics, AI).
  • 🤖 Integrated AI & Physics:
    • Built-in Finite State Machines (FSM), Steering Behaviors, and Blackboard patterns.
    • Physics integration via pymunk.

🛠️ Installation

PyGuara requires Python 3.12 or higher.

Using uv (Recommended)

# Clone the repository
git clone https://github.com/Wedeueis/pyguara
cd pyguara

# Sync dependencies
uv sync

Using pip

pip install -e .[dev]

🎮 Quick Start

To run the default example scene included with the engine:

python main.py

Creating a Basic Scene

Here is a minimal example of how to define a scene using PyGuara's ECS:

from pyguara.scene.base import Scene
from pyguara.common.components import Transform
from pyguara.graphics.components.sprite import Sprite
from pyguara.common.types import Vector2

class MyGameScene(Scene):
    def on_enter(self) -> None:
        print("Welcome to PyGuara!")

        # Create an entity
        player = self.entity_manager.create_entity("player")

        # Add components
        player.add_component(Transform(position=Vector2(100, 100)))
        player.add_component(Sprite(texture_path="assets/player.png"))

    def update(self, dt: float) -> None:
        # Game logic goes here
        pass

🏗️ Architecture Overview

The codebase is organized to enforce separation of concerns:

  • pyguara/ecs/: The core Entity-Component-System implementation.
  • pyguara/di/: The Dependency Injection container.
  • pyguara/events/: The event dispatching system.
  • pyguara/graphics/: Rendering protocols, pipelines, and backends.
  • pyguara/physics/: Physics engine integration (Pymunk).
  • pyguara/application/: Application lifecycle and bootstrapping.

🤝 Contributing

Contributions are welcome! Please ensure you adhere to the project's code quality standards.

  1. Install development dependencies:
    uv sync --extra dev
    
  2. Run tests:
    pytest
    
  3. Run linters:
    ruff check .
    mypy pyguara
    

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

✍️ Author

Developed by Wedeueis Braz.

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

pyguara-0.2.0.tar.gz (113.4 kB view details)

Uploaded Source

Built Distribution

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

pyguara-0.2.0-py3-none-any.whl (170.3 kB view details)

Uploaded Python 3

File details

Details for the file pyguara-0.2.0.tar.gz.

File metadata

  • Download URL: pyguara-0.2.0.tar.gz
  • Upload date:
  • Size: 113.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pyguara-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c93f2bbcdfddfd04e49097f91159a1882b141067d1a7100667043fc7d3710ae7
MD5 b90c08ee5e9683e3be1edd90d8cee312
BLAKE2b-256 eba10d5931d771ba158541b75c674c4787349e2f26e6e3f5a2f83c171812bf07

See more details on using hashes here.

File details

Details for the file pyguara-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyguara-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 170.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pyguara-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09d204387c4c1d9c284294ddeb481755c8334af2965440c10897b8e1a4999a1d
MD5 edab679afb1e2ebc286b12f421b31e51
BLAKE2b-256 7f9d36a318342fa7b508da1b07f7c94266b02b79d67ad389b3fb189c28c451bf

See more details on using hashes here.

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