epervier-old/gamecore/modules/world/baseworld.lua

42 lines
698 B
Lua

local BaseWorld = Object:extend()
-- INIT FUNCTIONS
-- All functions to init the world and the map
function BaseWorld:new(scene)
self.scene = scene
self.actors = {}
end
-- ACTOR MANAGEMENT FUNCTIONS
-- Basic function to handle actors
function BaseWorld:registerActor(actor)
table.insert(self.actors, actor)
end
function BaseWorld:countActors()
return #self.actors
end
-- UPDATE FUNCTIONS
-- All update functions
function BaseWorld:update(dt)
for i,v in ipairs(self.actors) do
v:update(dt)
end
end
-- DRAW FUNCTIONS
-- All function to draw the map, world and actors
function BaseWorld:draw(dt)
for i,v in ipairs(self.actors) do
v:draw(dt)
end
end
return BaseWorld