Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rakin406/pecs
An entity component system (ECS) for Python
https://github.com/rakin406/pecs
data-oriented-design ecs entity-component-system game-development gamedev python
Last synced: 3 days ago
JSON representation
An entity component system (ECS) for Python
- Host: GitHub
- URL: https://github.com/rakin406/pecs
- Owner: rakin406
- License: mit
- Created: 2023-11-18T14:43:41.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-12T11:54:29.000Z (5 months ago)
- Last Synced: 2024-06-12T15:52:54.403Z (5 months ago)
- Topics: data-oriented-design, ecs, entity-component-system, game-development, gamedev, python
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
**pecs** is a library for integrating Entity Component System (ECS) with game
development. It is inspired by [**entt**](https://github.com/skypjack/entt),
another ECS library but for C++.From [Wikipedia](https://en.wikipedia.org/wiki/Entity_component_system):
> **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
```python
import pecsfrom dataclasses import dataclass
@dataclass
class Position:
x: float
y: floatdef 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