An ECS python game engine with Raylib
Project description
Arepy 🎮
An ECS game engine created in python with raylib and imgui integration :)
Installation 📖
pip install arepy
Usage 📝
Basic usage example
Creating a simple square that moves to the right
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
WHITE_COLOR = Color(255, 255, 255, 255)
RED_COLOR = Color(255, 0, 0, 255)
def movement_system(
query: Query[Entities, With[Transform, RigidBody2D]], renderer: Renderer2D
):
delta_time = renderer.get_delta_time()
entities = query.get_entities()
for entity in entities:
transform = entity.get_component(Transform)
velocity = entity.get_component(RigidBody2D).velocity
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
):
renderer.start_frame()
renderer.clear(color=WHITE_COLOR)
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_COLOR,
)
renderer.end_frame()
if __name__ == "__main__":
game = ArepyEngine()
game.title = "Example :p"
game.init()
# Add world to the game engine
world = game.create_world("example_world")
# spawn some entities
entity = world.create_entity()
entity.with_component(Transform(position=Vec2(0, 0))).with_component(RigidBody2D(velocity=Vec2(50, 10))).build()
# Add systems to the world
world.add_system(SystemPipeline.UPDATE, movement_system)
world.add_system(SystemPipeline.RENDER, render_system)
# Add set the world as the current world to the game engine
game.set_current_world("example_world")
game.run()
And you can see the result:
TODO!: create a nice README.md
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
arepy-0.2.3.tar.gz
(34.8 kB
view details)
Built Distribution
arepy-0.2.3-py3-none-any.whl
(46.4 kB
view details)
File details
Details for the file arepy-0.2.3.tar.gz
.
File metadata
- Download URL: arepy-0.2.3.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b04f75110f305e61f577b052c846bb4470e98fa5ba24b51b8db15a2e7cb6e34 |
|
MD5 | 8304e4f31b319eea50b73f0f0579af43 |
|
BLAKE2b-256 | b4c0dedf30888552c76574875d4fbc7815cb5d87cb9ab3eedc31a0323a534a98 |
Provenance
The following attestation bundles were made for arepy-0.2.3.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.2.3.tar.gz
- Subject digest:
3b04f75110f305e61f577b052c846bb4470e98fa5ba24b51b8db15a2e7cb6e34
- Sigstore transparency entry: 167779926
- Sigstore integration time:
- Permalink:
Scr44gr/arepy@f2e49e6dff763e608542f4fa779506382c97909d
- Branch / Tag:
refs/tags/v0.2.3
- Owner: https://github.com/Scr44gr
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@f2e49e6dff763e608542f4fa779506382c97909d
- Trigger Event:
release
- Statement type:
File details
Details for the file arepy-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: arepy-0.2.3-py3-none-any.whl
- Upload date:
- Size: 46.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbaacdff59d7661bd5cb93dcb3e0d8edf3795176dbb2de6a4a2a8eb1f445123e |
|
MD5 | 5e5dd272e4d74f5333cd64226395fccb |
|
BLAKE2b-256 | 04af27c4944813b08233728c87b4ec0fe1acf05b823d4a30e4309351c0e3099e |
Provenance
The following attestation bundles were made for arepy-0.2.3-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.2.3-py3-none-any.whl
- Subject digest:
fbaacdff59d7661bd5cb93dcb3e0d8edf3795176dbb2de6a4a2a8eb1f445123e
- Sigstore transparency entry: 167779927
- Sigstore integration time:
- Permalink:
Scr44gr/arepy@f2e49e6dff763e608542f4fa779506382c97909d
- Branch / Tag:
refs/tags/v0.2.3
- Owner: https://github.com/Scr44gr
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@f2e49e6dff763e608542f4fa779506382c97909d
- Trigger Event:
release
- Statement type: