Skip to content

rakin406/pecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

pecs is a library for integrating Entity Component System (ECS) with game development. It is inspired by entt, another ECS library but for C++.

From Wikipedia:

Entity component system (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed of components of data, with systems which operate on entities' components.

Code Example

import pecs

from dataclasses import dataclass


@dataclass
class Position:
    x: float
    y: float


def update(registry: pecs.Registry):
    view: list = registry.view(Position)
    for entity in view:
        pos = registry.get(entity, Position)
        ...


def main():
    registry = pecs.Registry()

    for i in range(10):
        entity = registry.create()
        registry.emplace(entity, Position(i * 2, i))

    update(registry)


if __name__ == "__main__":
    main()

Authors

Rakin Rahman

License

This project is licensed under the MIT License - see the LICENSE file for details