simple entity-component-system implementation for lua
| LICENSE | add MIT license because for some reason i hadn't done that already | |
| llecs.lua | replace table.insert/ipairs in system member lists with a simpler set-inspired thing . unsure why i wasn't doing this before | |
| README.md | initial commit | |
llecs
a framework-agnostic small and simple entity-component-system implementation for lua
(example below uses love2d)
local ecs = require 'llecs'
ecs:filter('position', 'draw_rect')
function ecs.draw(position)
love.graphics.rectangle('fill', position.x - 4, position.y - 4, 8, 8)
end
ecs:filter('position', 'velocity')
function ecs.update(dt, position, velocity)
position.x = position.x + dt * velocity.x
position.y = position.y + dt * velocity.y
end
love.draw = ecs.draw
love.update = ecs.update
function love.load()
ecs:new {
position = { x = 0, y = 0 },
velocity = { x = 0, y = 0 },
draw_rect = true,
}
end