modules/world: add an initActors function

This commit is contained in:
Kazhnuz 2019-05-01 16:25:44 +02:00
parent 18d75f825c
commit dd21878ee8
2 changed files with 10 additions and 9 deletions

View file

@ -36,7 +36,7 @@ function BaseWorld:new(scene, actorlist, mapfile)
self.scene = scene
self.cameras = CameraSystem(self)
self.actors = {}
self:initActors()
self:initPlayers()
self:setActorList(actorlist)
@ -61,6 +61,10 @@ end
-- ACTOR MANAGEMENT FUNCTIONS
-- Basic function to handle actors
function BaseWorld:initActors( )
self.actors = {}
end
function BaseWorld:newActor(name, x, y)
self.obj.index[name](self, x, y)
end

View file

@ -31,19 +31,16 @@ local Bump = require(cwd .. "libs.bump")
local CameraSystem = require(cwd .. "camera")
function World2D:new(scene, actorlist, mapfile)
self.scene = scene
self.cameras = CameraSystem(self)
self.actors = Bump.newWorld(50)
self:initPlayers()
self:setActorList(actorlist)
self:initMap(mapfile)
World2D.super.new(self, scene, actorlist, mapfile)
end
-- ACTORS FUNCTIONS
-- Wrappers around Bump2D functions
function World2D:initActors()
self.actors = Bump.newWorld(50)
end
function World2D:registerActor(actor)
return self.actors:add(actor, actor.x, actor.y, actor.w, actor.h)
end