entity={ x=0,y=0, w=8,h=8, init=function(ent) to(entities,ent) end, upd=function(ent) ... end, drw=function(ent) ... end, } entity:init()--add the one entity to the entity table
x
y
w
h
init
entities
upd
drw
function TIC() for i,ent in ipairs(entities)do--update all entities ent:upd() end for i,ent in ipairs(entities)do--draw all entities ent:drw() end end
function newEntity() local entity={ x=0,y=0, w=8,h=8, init=function(ent) to(entities,ent) end, upd=function(ent) ... end, drw=function(ent) ... end, } entity:init() end