Skip to main content

A simple implementation of the Entity-Component pattern.

Project description


A simple implementation of the Entity-Component pattern.

PyPI - Version PyPI - Status PyPI - Python Version PyPI - License

Build Status codecov codebeat badge Code style: black Checked with mypy


This project is available on PyPI so you can simply install it via

pip install pyecs


from dataclasses import dataclass
from typing import Tuple

from pyecs import Store

# 1. build your components
class Transform:
    position: Tuple[float, float] = (0.0, 0.0)

class Rigidbody:
    velocity: Tuple[float, float] = (0.0, 0.0)
    acceleration: Tuple[float, float] = (0.0, 0.0)

if __name__ == "__main__":
    # 2. intialize entity-component store
    store = Store()

    # 3. add some entities
    scene = store.add_entity()
    scene.add_child(Transform(), Rigidbody(acceleration=(1.0, 0.0)))
    scene.add_child(Transform(), Rigidbody(acceleration=(0.0, 1.0)))
    scene.add_child(Transform(), Rigidbody(acceleration=(1.0, 1.0)))

    # 4. run everything
    while True:
        for entity in store.get_entities_with(Transform, Rigidbody):
            transform, rigidbody = entity.get_components(Transform, Rigidbody)
            rigidbody.velocity = (
                rigidbody.velocity[0] + rigidbody.acceleration[0],
                rigidbody.velocity[1] + rigidbody.acceleration[1],
            transform.position = (
                transform.position[0] + rigidbody.velocity[0],
                transform.position[1] + rigidbody.velocity[1],

Dev Setup

Simply install pipenv and run the following line:

pipenv install --dev

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyecs, version 0.19
Filename, size File type Python version Upload date Hashes
Filename, size pyecs-0.19-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyecs-0.19.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page