A crystal implementation for ECS
spec | ||
src | ||
.editorconfig | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
shard.yml |
entity_cool_system
An ECS implementation in crystal
Installation
-
Add the dependency to your
shard.yml
:dependencies: entity_cool_system: git: https://git.sceptique.eu/Sceptique/EntityCoolSystem branch: master
-
Run
shards install
Usage
require "entity_cool_system"
# init the world
world = ECS::World.new
# add custom systems
world << { name: "name_of_a_system", system: new MyScope::Systems::CustomSystem }
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params1")
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params2")
world["name_of_a_system"] << new MyScope::Entities::SomeKind("params3")
# call the systems #init methods
world.init
# maybe infinite loop
100.times do |i|
# call the systems #update methods
world.update
end
# call the systems #cleanup methods
world.cleanup
First you must define your systems and components.
Systems extend ECS::System
and may provide #init
, #update
, #cleanup
methods. To do so they also must implement ECS::System::Init
, ECS::System::Update
, ECS::System::Cleanup
.
Components are extending CS::Component
and they are initialized with an entity as first parameter. A macro ECS::Components.generate_component
is provided in order to be able to generate new simple component initializer in one line.
You may provide entities generator if needed.
Development
TODO: Write development instructions here
Contributing
- Fork it (https://git.sceptique.eu/Sceptique/EntityCoolSystem)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- [Arthur Poulet](https://git.sceptique.eu/Sceptique - creator and maintainer