An ECS python game engine with Raylib
Project description
Arepy 🎮
Arepy is a modern ECS (Entity Component System) game engine written in Python, featuring seamless integration with Raylib for graphics and ImGui for debugging interfaces.
✨ Features
- 🚀 High-performance ECS architecture - Optimized entity-component-system design
- 🎨 Raylib integration - Hardware-accelerated 2D graphics
- 🛠️ ImGui debugging - Real-time debugging and profiling tools
- 🔧 Component pools - Memory-efficient component management
- 🎯 Query system - Flexible entity filtering with
With/Withoutqueries - 📦 Easy to use - Simple and intuitive API design
- 🏗️ Entity builder - Fluent interface for entity creation
📖 Installation
From PyPI
pip install arepy
Development Installation
git clone https://github.com/Scr44gr/arepy.git
cd arepy
pip install -e ".[testing]"
🚀 Quick Start
Basic Example - Moving Square
Create a simple red square that moves across the screen:
from arepy import ArepyEngine, Color, Rect, Renderer2D, SystemPipeline
from arepy.bundle.components.rigidbody_component import RigidBody2D
from arepy.bundle.components.transform_component import Transform
from arepy.ecs import Entities, Query, With
from arepy.math import Vec2
# Colors
WHITE = Color(255, 255, 255, 255)
RED = Color(255, 0, 0, 255)
def movement_system(query: Query[Entities, With[Transform, RigidBody2D]], renderer: Renderer2D):
"""System that updates entity positions based on velocity."""
delta_time = renderer.get_delta_time()
for entity in query.get_entities():
transform = entity.get_component(Transform)
velocity = entity.get_component(RigidBody2D).velocity
# Update position
transform.position.x += velocity.x * delta_time
transform.position.y += velocity.y * delta_time
def render_system(query: Query[Entities, With[Transform, RigidBody2D]], renderer: Renderer2D):
"""System that renders all entities with transform and rigidbody components."""
renderer.start_frame()
renderer.clear(color=WHITE)
for entity in query.get_entities():
transform = entity.get_component(Transform)
renderer.draw_rectangle(
Rect(transform.position.x, transform.position.y, 50, 50),
color=RED
)
renderer.end_frame()
if __name__ == "__main__":
game = ArepyEngine(
title="Arepy Example",
)
# Create a world
world = game.create_world("main_world")
# Create an entity with components
entity = (world.create_entity()
.with_component(Transform(position=Vec2(0, 0)))
.with_component(RigidBody2D(velocity=Vec2(50, 10)))
.build())
# Register systems
world.add_system(SystemPipeline.UPDATE, movement_system)
world.add_system(SystemPipeline.RENDER, render_system)
# Set as current world and run
game.set_current_world("main_world")
game.run()
🏗️ Core Concepts
Entities
Entities are lightweight identifiers that represent game objects:
# Create an entity
entity = world.create_entity()
# Or use the builder pattern
player = (world.create_entity()
.with_component(Transform(position=Vec2(100, 100)))
.with_component(PlayerController())
.build())
Components
Components are pure data containers:
from arepy.ecs import Component
class Health(Component):
def __init__(self, value: int = 100):
self.value = value
self.max_value = value
class Weapon(Component):
def __init__(self, damage: int = 10, range: float = 100.0):
self.damage = damage
self.range = range
Systems
Systems contain the game logic and operate on entities with specific components:
def damage_system(query: Query[Entity, With[Health, Weapon]]):
"""System that processes combat between entities."""
for entity in query.get_entities():
health = entity.get_component(Health)
weapon = entity.get_component(Weapon)
# Game logic here
if health.value <= 0:
entity.kill()
Queries
Queries allow you to filter entities based on their components:
# Entities WITH specific components
Query[Entity, With[Transform, Velocity]]
# Entities WITHOUT specific components
Query[Entity, Without[Dead]]
# Complex combinations (planned feature)
Query[Entity, With[Transform, Velocity], Without[Frozen]]
🧪 Testing
Run the comprehensive test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=arepy --cov-report=html
# Run specific test file
pytest tests/test_registry.py -v
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Ensure tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📋 Requirements
- Python 3.10+
- Raylib 5.5.0+
- Bitarray 3.4.2+
🗺️ Roadmap
- Advanced Query System - Support for complex component combinations
- Scene Management - Built-in scene loading and transitions
- Asset Pipeline - Better streamlined asset loading and management
- Physics Integration - Built-in 2D/3D physics systems
- Audio System - Comprehensive audio management
- Networking - Multiplayer game support
- Visual Editor - GUI editor for game development
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Raylib - Amazing C library for 2D/3D graphics
- ImGui - Fantastic debugging interface
- EnTT - Inspiration for ECS design
- Bevy Engine - Inspiration for ECS Query system
- Pikuma - Educational resources :)
- raylib-python-cffi - Python bindings for Raylib
Made with ❤️ by Abrahan Gil
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 arepy-0.4.1.tar.gz.
File metadata
- Download URL: arepy-0.4.1.tar.gz
- Upload date:
- Size: 54.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e8293f261b465dfa0f6faf4c132fb62c33d857e921d17a996e3af2b67233cd8
|
|
| MD5 |
00df339bfec74d1c2c6bebdbd9c4abe2
|
|
| BLAKE2b-256 |
b8c3f9a80131f094a06d30c9599bdc47c4d17b89b25f761666140b4d89ddc887
|
Provenance
The following attestation bundles were made for arepy-0.4.1.tar.gz:
Publisher:
python-publish.yml on Scr44gr/arepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arepy-0.4.1.tar.gz -
Subject digest:
7e8293f261b465dfa0f6faf4c132fb62c33d857e921d17a996e3af2b67233cd8 - Sigstore transparency entry: 738092943
- Sigstore integration time:
-
Permalink:
Scr44gr/arepy@a9ade15f70a24cb941e9e1aeb5edc0596ec95397 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Scr44gr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a9ade15f70a24cb941e9e1aeb5edc0596ec95397 -
Trigger Event:
release
-
Statement type:
File details
Details for the file arepy-0.4.1-py3-none-any.whl.
File metadata
- Download URL: arepy-0.4.1-py3-none-any.whl
- Upload date:
- Size: 57.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54d5120d994e89bde94a711ceb6d74d1c2cc720c3557fd206d411507e084fcc5
|
|
| MD5 |
3a979ef6c695ef5d7d9289c281b7e55d
|
|
| BLAKE2b-256 |
287e9a8766861e6346121d6f90ecf15c409c38aa83887c155610914fb953db17
|
Provenance
The following attestation bundles were made for arepy-0.4.1-py3-none-any.whl:
Publisher:
python-publish.yml on Scr44gr/arepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arepy-0.4.1-py3-none-any.whl -
Subject digest:
54d5120d994e89bde94a711ceb6d74d1c2cc720c3557fd206d411507e084fcc5 - Sigstore transparency entry: 738092947
- Sigstore integration time:
-
Permalink:
Scr44gr/arepy@a9ade15f70a24cb941e9e1aeb5edc0596ec95397 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Scr44gr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a9ade15f70a24cb941e9e1aeb5edc0596ec95397 -
Trigger Event:
release
-
Statement type: