You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adorbs is a functional entity framework for LÖVE. The goal was to provide a
minimal entity framework sdk with a centralized game state.
Getting Started
Below is an example of a minimal ECS setup in adorbs.
localengine, system, entity, component=require'adorbs' ()
functionlove.load()
entity.create('player', {
'characterController', -- components are defined inline, and can be empty, as long as they are a stringtransform= { x=15, y=0 }
})
system.create(
'systemName',
{'characterController', 'transform'},
function(delta, characterController, transform) -- called on each entity that matches componentsprint(transform.x) -- should print out 15end
)
endfunctionlove.draw()
engine.process()
end
If you're looking to move past the pare minimum I generally lay my projects out like so:
folders
-> components
-> entities
-> systems
I populate those folders with my a respective ECS lua module that return a function, here is an example.
Component
-- newTransform.luareturnfunction(x, y, scale, rotation)
return { x=x, y=y, scale=scale, rotation=rotation}
end
Entity
returnfunction(spriteSheetLoc, x, y, speed)
entity.create('player', {
characterController=newCharacterController(speed),
transform=newTransform(x, y)
})
end
System
returnfunction()
system.create(
'animator',
{'animation', 'transform'},
function(dt, animation, transform)
localcurrentAnimation=animation.animations[animation.current]
ifcurrentAnimation==nilthenerror('You called an animation (' ..animation.current..') that does\'nt exist!')
returnendcurrentAnimation:update(dt)
currentAnimation:draw(animation.image, transform.x, transform.y)
end
)
end
Then in your main.lua or scene file you just require what you need and they get added to the state automatically.
-- overworld.lualocalscene= {}
require'systems/map' ()
require'systems/inputController' ()
require'systems/animator' ()
functionscene:enter()
require'entities/map' ('maps/test') --you can make the functions accept argumentsrequire'entities/player' ('assets/animplayers.png', 20, 20, 40)
endfunctionscene:draw(dt)
engine.process()
endreturnscene