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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: arepy-0.2.0.tar.gz
  • Upload date:
  • Size: 34.0 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.0.tar.gz
Algorithm Hash digest
SHA256 33bb5d23d782b77e05515ee942aa3f408aa5df0af1beb00a11effd89ab505e17
MD5 7e520c6a608bca20da109061ce25a7b3
BLAKE2b-256 563038c17bf8fb753122844629b0ff543495e45cfdb5e0e6018eddf43fffbf4f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: arepy-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f046c64a1a259743ac3c8a862b8133f8d69684032a3a40627b4e613218935dcc
MD5 e40ac739275c2765848719db8cde127a
BLAKE2b-256 6774c30fc14cd048584f7c0879c3b001412b4a1c46252ac2695f779c7ce17ca5

See more details on using hashes here.

Provenance

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