modules/world: add an initActors function
This commit is contained in:
parent
18d75f825c
commit
dd21878ee8
2 changed files with 10 additions and 9 deletions
|
@ -36,7 +36,7 @@ function BaseWorld:new(scene, actorlist, mapfile)
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
|
|
||||||
self.cameras = CameraSystem(self)
|
self.cameras = CameraSystem(self)
|
||||||
self.actors = {}
|
self:initActors()
|
||||||
|
|
||||||
self:initPlayers()
|
self:initPlayers()
|
||||||
self:setActorList(actorlist)
|
self:setActorList(actorlist)
|
||||||
|
@ -61,6 +61,10 @@ end
|
||||||
-- ACTOR MANAGEMENT FUNCTIONS
|
-- ACTOR MANAGEMENT FUNCTIONS
|
||||||
-- Basic function to handle actors
|
-- Basic function to handle actors
|
||||||
|
|
||||||
|
function BaseWorld:initActors( )
|
||||||
|
self.actors = {}
|
||||||
|
end
|
||||||
|
|
||||||
function BaseWorld:newActor(name, x, y)
|
function BaseWorld:newActor(name, x, y)
|
||||||
self.obj.index[name](self, x, y)
|
self.obj.index[name](self, x, y)
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,19 +31,16 @@ local Bump = require(cwd .. "libs.bump")
|
||||||
local CameraSystem = require(cwd .. "camera")
|
local CameraSystem = require(cwd .. "camera")
|
||||||
|
|
||||||
function World2D:new(scene, actorlist, mapfile)
|
function World2D:new(scene, actorlist, mapfile)
|
||||||
self.scene = scene
|
World2D.super.new(self, scene, actorlist, mapfile)
|
||||||
|
|
||||||
self.cameras = CameraSystem(self)
|
|
||||||
self.actors = Bump.newWorld(50)
|
|
||||||
|
|
||||||
self:initPlayers()
|
|
||||||
self:setActorList(actorlist)
|
|
||||||
self:initMap(mapfile)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ACTORS FUNCTIONS
|
-- ACTORS FUNCTIONS
|
||||||
-- Wrappers around Bump2D functions
|
-- Wrappers around Bump2D functions
|
||||||
|
|
||||||
|
function World2D:initActors()
|
||||||
|
self.actors = Bump.newWorld(50)
|
||||||
|
end
|
||||||
|
|
||||||
function World2D:registerActor(actor)
|
function World2D:registerActor(actor)
|
||||||
return self.actors:add(actor, actor.x, actor.y, actor.w, actor.h)
|
return self.actors:add(actor, actor.x, actor.y, actor.w, actor.h)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue