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.1.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

arepy-0.2.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arepy-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 62c1bc0d3b8fd1e2f942e82c4b8c6a0b86dca982ea3045110a8669cce198a77c
MD5 0b93706d5d430c11a720ba23eca4b8b9
BLAKE2b-256 831678769da32188175dea264a25574bc80e4ee7a374b1099ac43d4e68ef7ace

See more details on using hashes here.

Provenance

The following attestation bundles were made for arepy-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: arepy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 45.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8554b2b2dc353c51096537ddd8695c6b0587290402df7c50e498f64cd6e5dadc
MD5 72465d06cc1cfdd4617245f54ff1de8d
BLAKE2b-256 7ce6cadd59e45a083380c4caeb1987e055430783040012e6b15156ae7d8e77ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for arepy-0.2.1-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