Skip to main content

An ECS python game engine with Raylib

Project description

Arepy 🎮

Upload Python Package

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:

window

TODO!: create a nice README.md

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

arepy-0.2.2.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

arepy-0.2.2-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file arepy-0.2.2.tar.gz.

File metadata

  • Download URL: arepy-0.2.2.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for arepy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 bafc3eb19c102a904990b88e640979cb8ed9be37b49ea1222d07d22a8f8f5b39
MD5 b1610fcfe51eb917718f525084993d02
BLAKE2b-256 7545980e125041d16b5a1a11e6225fbfb0df2028d1d5ba4f91c7d8be7dd0ccea

See more details on using hashes here.

Provenance

The following attestation bundles were made for arepy-0.2.2.tar.gz:

Publisher: python-publish.yml on Scr44gr/arepy

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

File details

Details for the file arepy-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: arepy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for arepy-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 821b67870773183c51be603daae46553462daf3f1c4d615322d2de1498a2cf8b
MD5 4e4cba3f063184bec0c87ae4f7556950
BLAKE2b-256 8460a8654af82f2b41792517be00fe99e688d2d95d56bd5da1c4073f3e518900

See more details on using hashes here.

Provenance

The following attestation bundles were made for arepy-0.2.2-py3-none-any.whl:

Publisher: python-publish.yml on Scr44gr/arepy

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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page