A crystal implementation for ECS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Arthur POULET aa71b7029b init: initialize crystal project 6 months ago
spec init: initialize crystal project 6 months ago
src init: initialize crystal project 6 months ago
.editorconfig init: initialize crystal project 6 months ago
.gitignore init: initialize crystal project 6 months ago
.travis.yml init: initialize crystal project 6 months ago
LICENSE init: initialize crystal project 6 months ago
README.md init: initialize crystal project 6 months ago
shard.yml init: initialize crystal project 6 months ago

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