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

42 lines
698 B
Lua
Raw Normal View History

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