RubyGems Navigation menu

kiwi-ecs 0.1.1

Description

“Kiwi is a versatile entity component system focussing on fast iteration and a nice api.n”, “n”, “To get started, read the [usage guide](#usage) below.n”, “n”, “[![Tests](github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/Jomy10/kiwi-ecs-ruby/actions/workflows/tests.yml)n”, “n”, “## Installationn”, “n”, “The library is available from [ruby gems](rubygems.org/gems/kiwi-ecs):n”, “n”, ““‘shn”, “gem install kiwi-ecsn”, ““`n”, “n”, “To use it in your ruby source files:n”, “n”, ““`rubyn”, “require ’kiwi-ecs’n”, ““‘n”, “n”, “## Usagen”, “n”, “### The worldn”, “n”, “The world is the main object that controls the ecs.n”, “n”, ““`rubyn”, “world = Kiwi::World.newn”, ““`n”, “n”, “### Componentsn”, “n”, “Creating a component is as simple as declaring a struct:n”, “n”, ““`rubyn”, “Position = Struct.new :x, :yn”, ““`n”, “n”, “Classes can also be used instead of structsn”, “n”, ““`rubyn”, “class Velocityn”, “ attr_accessor :xn”, “ attr_accessor :yn”, “endn”, ““`n”, “n”, “### Entitiesn”, “n”, “An entity is spawned with a set of components:n”, “n”, ““`rubyn”, “entityId = world.spawn(Position.new(10, 10))n”, “n”, “world.spawn(Position.new(3, 5), Velocity.new(1.5, 0.0))n”, ““`n”, “n”, “The `world.spawn(*components)` function will return the id of the spawned entity.n”, “n”, “Killing an entity can be done using `world.kill(entityId)`:n”, “n”, ““`rubyn”, “world.kill(entityId)n”, ““`n”, “n”, “### Systemsn”, “n”, “#### Queriesn”, “n”, “Queries can be constructed as follows:n”, “n”, ““`rubyn”, “# Query all position componentssn”, “world.query(Position) do |pos|n”, “ puts posn”, “endn”, “n”, “# Query all entities having a position and a velocity component, and their entity idsn”, “world.query_with_ids(Position, Velocity) do |id, pos, vel|n”, “ # …n”, “endn”, ““`n”, “n”, “### Flagsn”, “n”, “Entities can be tagged using flagsn”, “n”, “#### Defining flagsn”, “n”, “A flag is an integern”, “n”, ““`rubyn”, “module Flagsn”, “ Player = 0n”, “ Enemy = 1n”, “endn”, ““`n”, “n”, “#### Setting flagsn”, “n”, ““`rubyn”, “id = world.spawnn”, “n”, “world.set_flag(id, Flags::Player)n”, ““`n”, “n”, “#### Removing a flagn”, “n”, ““`rubyn”, “world.remove_flag(id, Flags::Player)n”, ““`n”, “n”, “#### Checking wether an entity has a flagn”, “n”, ““`rubyn”, “world.has_flag(id, Flags::Player)n”, ““`n”, “n”, “#### Filtering queries with flagsn”, “n”, ““`rubyn”, “world.query_with_ids(Pos)n”, “ .filter do |id, pos|n”, “ world.has_flag(id, Flags::Player)n”, “ endn”, “ .each do |id, pos|n”, “ # Do something with the filtered queryn”, “ endn”, ““`n”, “n”, “The `hasFlags` function is also available for when you want to check multiple flags.n”, “n”, “## Road mapn”, “n”, “- [

System groupsn“, ”n“, ”## Contributingn“, ”n“, ”Contributors are welcome to open an issue requesting new features or fixes or opening a pull request for them.n“, ”n“, ”## Licensen“, ”n“, ”The library is licensed under LGPLv3.n“]

Gemfile:
=

install:
=

Versions:

  1. 0.1.1 August 13, 2023 (9 KB)
  2. 0.1.0 August 11, 2023 (8 KB)
  3. 0.0.3 August 11, 2023 (8 KB)
  4. 0.0.2 August 11, 2023 (7.5 KB)

Owners:

Pushed by:

Authors:

  • Jonas Everaert

SHA 256 checksum:

=

Total downloads 1,472

For this version 507

Version Released:

License:

LGPL-3.0-or-later

Required Ruby Version: >= 0

Links: