Skip to content

Instantly share code, notes, and snippets.

@torus
Created July 12, 2009 09:54
Show Gist options
  • Save torus/145588 to your computer and use it in GitHub Desktop.
Save torus/145588 to your computer and use it in GitHub Desktop.
---
--- Game Engine
---
EntityBase = {}
function EntityBase:new (name)
local o = {}
setmetatable (o, {__index = self})
o.name = name
return o
end
function create_entity_class ()
local c = {}
setmetatable (c, {__index = EntityBase})
return c
end
-- messages
FINISHED = {}
--- main function
function run (entlist)
while #entlist > 0 do
local willremove = {}
for i, v in pairs (entlist) do
local m = v:update ()
if m == FINISHED then
table.insert (willremove, i)
end
end
for i, k in pairs (willremove) do
local e = entlist[k];
print (e.name .. ": removed")
entlist[k] = nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment