Created
July 12, 2009 09:54
-
-
Save torus/145588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- 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