Difference between revisions of "tiny-ecs"

(Entity Component System for lua.)
m (Adding keyword.)
Line 50: Line 50:
 
{{#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]]

Revision as of 12:17, 18 January 2017

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