Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukasturcani/xecs-pygame
https://github.com/lukasturcani/xecs-pygame
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/lukasturcani/xecs-pygame
- Owner: lukasturcani
- Created: 2023-09-29T09:44:58.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-04T09:50:06.000Z (about 1 year ago)
- Last Synced: 2024-10-12T11:43:34.578Z (2 months ago)
- Language: Python
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
xecs-pygame
===========A plugin for xecs_, allowing you to render your entities with pygame_.
Usage
-----First, add the plugin to your xecs_ app.
.. code-block:: python
import xecs as xx
from xecs_pygame import PyGamePlugindef main() -> None:
app = xx.RealTimeApp()
app.add_plugin(PyGamePlugin())Now, when you spawn entities, you can give them a
``Circle``, ``Polygon``, ``Rectangle`` component. If you do that,
your entities will be rendered on the screen:.. code-block:: python
import xecs as xx
from xecs_pygame import Circle, PyGamePlugindef spawn_three_circles(commands: xx.Commands, world: xx.World) -> None:
transformi, _ = commands.spawn((xx.Transform2, Circle), 3)
transform = world.get_view(xx.Transform2, transformi)
transform.translation.x.fill([0, 15, 30])def main() -> None:
app = xx.RealTimeApp()
app.add_plugin(PyGamePlugin())
app.add_startup_system(spawn_three_circles)
app.add_pool(Circle.create_pool(3))
app.add_pool(xx.Transform2.create_pool(3))
app.run()if __name__ == "__main__":
main()Further examples
----------------* `draw shapes`_
* `moving circles`_
* `boids`_
* `mouse presses`_
* `mouse position`_
* `text`_
* keyboard_.. _xecs: https://github.com/lukasturcani/xecs
.. _pygame: https://github.com/pygame/pygame
.. _`draw shapes`: https://github.com/lukasturcani/xecs-pygame/blob/master/examples/draw_shapes.py
.. _`moving circles`: https://xecs.readthedocs.io/en/latest/moving_circles.html
.. _boids: https://xecs.readthedocs.io/en/latest/boids.html
.. _`mouse presses`: https://xecs.readthedocs.io/en/latest/mouse_presses.html
.. _`mouse position`: https://xecs.readthedocs.io/en/latest/mouse_position.html
.. _`text`: https://xecs.readthedocs.io/en/latest/text.html
.. _keyboard: https://xecs.readthedocs.io/en/latest/keyboard.htmlInstallation
------------.. code-block:: bash
pip install xecs-pygame