2019-04-01 08:08:54 +02:00
|
|
|
local BaseWorld = Object:extend()
|
|
|
|
|
|
|
|
function BaseWorld:new(scene)
|
|
|
|
self.scene = scene
|
|
|
|
|
2019-04-01 13:09:21 +02:00
|
|
|
self.actors = {}
|
2019-04-01 08:08:54 +02:00
|
|
|
end
|
|
|
|
|
2019-04-01 13:09:21 +02:00
|
|
|
function BaseWorld:registerActor(actor)
|
|
|
|
table.insert(self.actors, actor)
|
2019-04-01 08:08:54 +02:00
|
|
|
end
|
|
|
|
|
2019-04-01 13:09:21 +02:00
|
|
|
function BaseWorld:countActors()
|
|
|
|
return #self.actors
|
2019-04-01 12:47:08 +02:00
|
|
|
end
|
|
|
|
|
2019-04-01 08:08:54 +02:00
|
|
|
function BaseWorld:update(dt)
|
2019-04-01 13:09:21 +02:00
|
|
|
for i,v in ipairs(self.actors) do
|
2019-04-01 08:08:54 +02:00
|
|
|
v:update(dt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function BaseWorld:draw(dt)
|
2019-04-01 13:09:21 +02:00
|
|
|
for i,v in ipairs(self.actors) do
|
2019-04-01 08:08:54 +02:00
|
|
|
v:draw(dt)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return BaseWorld
|