Difference between revisions of "tiny-ecs"

(Created page with "== Entity Component System for lua. == Tiny-ecs is an Entity Component System for lua that's simple, flexible, and useful. Because of lua's tabular nature, Entity Component Sys...")
 
m
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
Because of lua's tabular nature, Entity Component Systems are a natural choice for
 
Because of lua's tabular nature, Entity Component Systems are a natural choice for
 
simulating large and complex systems. In game programming, ECS is a great way to simplify the game loop. For more explanation on Entity Component Systems,
 
simulating large and complex systems. In game programming, ECS is a great way to simplify the game loop. For more explanation on Entity Component Systems,
here is some basic info. http://en.wikipedia.org/wiki/Entity_component_system
+
here is some [http://en.wikipedia.org/wiki/Entity_component_system basic info].
 +
<br/>
 +
<br/>
  
 
Tiny-ecs also works well with objected oriented programming in lua because Systems and
 
Tiny-ecs also works well with objected oriented programming in lua because Systems and
 
Entities do not use metatables. This means you can subclass your Systems and Entities, and
 
Entities do not use metatables. This means you can subclass your Systems and Entities, and
 
use existing lua class frameworks with tiny-ecs, no problem.
 
use existing lua class frameworks with tiny-ecs, no problem.
 +
<br/>
 +
<br/>
  
* Source: https://github.com/bakpakin/tiny-ecs
+
Example:
* Demo Source: https://github.com/bakpakin/tiny-ecs/tree/demo-commandokibbles
+
<source lang="lua">
* API: https://bakpakin.github.io/tiny-ecs/doc/
+
local tiny = require("tiny")
* Forum Thread: https://love2d.org/forums/viewtopic.php?f=5&t=79937
+
 
 +
local talkingSystem = tiny.processingSystem()
 +
talkingSystem.filter = tiny.requireAll("name", "mass", "phrase")
 +
function talkingSystem:process(e, dt)
 +
    e.mass = e.mass + dt * 3
 +
    print(e.name .. ", who weighs " .. e.mass .. " pounds, says, \"" .. e.phrase .. "\"")
 +
end
 +
 
 +
local joe = {
 +
    name = "Joe",
 +
    phrase = "I'm a plumber.",
 +
    mass = 150,
 +
    hairColor = "brown"
 +
}
 +
 
 +
local world = tiny.world(talkingSystem, joe)
 +
 
 +
for i = 1, 20 do
 +
    world:update(1)
 +
end
 +
</source>
 +
<br/>
 +
 
 +
 
 +
[https://raw.githubusercontent.com/bakpakin/tiny-ecs/master/tiny.lua Copy/Paste Latest Source]
 +
 
 +
* [https://github.com/bakpakin/tiny-ecs Source]
 +
* [https://github.com/bakpakin/tiny-ecs/tree/demo-commandokibbles Demo Source]
 +
* [https://bakpakin.github.io/tiny-ecs/doc/ API]
 +
* [https://love2d.org/forums/viewtopic.php?f=5&t=79937 Forum Thread]
  
 
{{#set:LOVE Version=Any}}
 
{{#set:LOVE Version=Any}}
 
{{#set:Description=Entity Component System for lua.}}
 
{{#set:Description=Entity Component System for lua.}}
 +
{{#set:Keyword=Framework}}
 
[[Category:Libraries]]
 
[[Category:Libraries]]
 +
 +
== Other Languages ==
 +
{{i18n|tiny-ecs}}

Latest revision as of 15:42, 15 December 2019

Entity Component System for lua.

Tiny-ecs is an Entity Component System for lua that's simple, flexible, and useful. Because of lua's tabular nature, Entity Component Systems are a natural choice for simulating large and complex systems. In game programming, ECS is a great way to simplify the game loop. For more explanation on Entity Component Systems, here is some basic info.

Tiny-ecs also works well with objected oriented programming in lua because Systems and Entities do not use metatables. This means you can subclass your Systems and Entities, and use existing lua class frameworks with tiny-ecs, no problem.

Example:

local tiny = require("tiny")

local talkingSystem = tiny.processingSystem()
talkingSystem.filter = tiny.requireAll("name", "mass", "phrase")
function talkingSystem:process(e, dt)
    e.mass = e.mass + dt * 3
    print(e.name .. ", who weighs " .. e.mass .. " pounds, says, \"" .. e.phrase .. "\"")
end

local joe = {
    name = "Joe",
    phrase = "I'm a plumber.",
    mass = 150,
    hairColor = "brown"
}

local world = tiny.world(talkingSystem, joe)

for i = 1, 20 do
    world:update(1)
end



Copy/Paste Latest Source

Other Languages