A crystal implementation for ECS
Go to file
Arthur POULET aa71b7029b init: initialize crystal project 2021-04-16 10:49:21 +02:00
spec init: initialize crystal project 2021-04-16 10:49:21 +02:00
src init: initialize crystal project 2021-04-16 10:49:21 +02:00
.editorconfig init: initialize crystal project 2021-04-16 10:49:21 +02:00
.gitignore init: initialize crystal project 2021-04-16 10:49:21 +02:00
.travis.yml init: initialize crystal project 2021-04-16 10:49:21 +02:00
LICENSE init: initialize crystal project 2021-04-16 10:49:21 +02:00
README.md init: initialize crystal project 2021-04-16 10:49:21 +02:00
shard.yml init: initialize crystal project 2021-04-16 10:49:21 +02:00

README.md

entity_cool_system

An ECS implementation in crystal

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      entity_cool_system:
        git: https://git.sceptique.eu/Sceptique/EntityCoolSystem
        branch: master
    
  2. 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

  1. Fork it (https://git.sceptique.eu/Sceptique/EntityCoolSystem)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors