From dd21878ee82b275bd1e0bff9600f584e105f5695 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 1 May 2019 16:25:44 +0200 Subject: [PATCH] modules/world: add an initActors function --- gamecore/modules/world/baseworld.lua | 6 +++++- gamecore/modules/world/world2D.lua | 13 +++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index a90d00a..108e63e 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -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 diff --git a/gamecore/modules/world/world2D.lua b/gamecore/modules/world/world2D.lua index de4136f..eeb6899 100644 --- a/gamecore/modules/world/world2D.lua +++ b/gamecore/modules/world/world2D.lua @@ -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