refactor(levels): use the gamecore world loading functions
This commit is contained in:
parent
557de3b503
commit
39a998d773
|
@ -35,8 +35,9 @@ function Level:loadMission(levelID, missionID)
|
||||||
local datas, missiondatas
|
local datas, missiondatas
|
||||||
self.datas = require("datas.levels." .. levelID)
|
self.datas = require("datas.levels." .. levelID)
|
||||||
|
|
||||||
self.world = World(self, self.datas.mapfile)
|
local mapfile = "assets.maps." .. self.datas.mapfile
|
||||||
self.world:load()
|
self.world = World(self, self.datas.mapfile, "scenes.levels.entities")
|
||||||
|
self.world:loadMap()
|
||||||
self.assets:setMusic("assets/music/" .. self.datas.music)
|
self.assets:setMusic("assets/music/" .. self.datas.music)
|
||||||
|
|
||||||
self:launchMission()
|
self:launchMission()
|
||||||
|
|
|
@ -8,21 +8,23 @@ local Sti = require "libs.sti"
|
||||||
-- INIT FUNCTIONS
|
-- INIT FUNCTIONS
|
||||||
-- All functions to init the world and the map
|
-- All functions to init the world and the map
|
||||||
|
|
||||||
function World:new(scene, mapfile)
|
function World:new(scene, mapfile, actorlist)
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
self.map = Sti("assets/maps/" .. mapfile .. ".lua")
|
self.actorlist = actorlist
|
||||||
self.obj = Obj
|
self.mapfile = mapfile
|
||||||
self:initActors()
|
|
||||||
self:setGravity()
|
self:initActors()
|
||||||
self.backcolor = self.map.backgroundcolor or {0, 0, 0}
|
|
||||||
|
self:initMap(self.mapfile)
|
||||||
|
self:setActorList(self.actorlist)
|
||||||
|
self:setGravity()
|
||||||
|
|
||||||
self.activeObjects = 0
|
|
||||||
self:register()
|
self:register()
|
||||||
|
|
||||||
self.isActive = true
|
self.isActive = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:load()
|
function World:loadMapObjects()
|
||||||
self:loadMapCollisions()
|
self:loadMapCollisions()
|
||||||
self:loadMapActors()
|
self:loadMapActors()
|
||||||
end
|
end
|
||||||
|
@ -49,14 +51,6 @@ function World:getDimensions()
|
||||||
self.map.height * self.map.tileheight
|
self.map.height * self.map.tileheight
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:setBackgroundColor(r, g, b)
|
|
||||||
self.backcolor = {r, g, b}
|
|
||||||
end
|
|
||||||
|
|
||||||
function World:getBackgroundColor()
|
|
||||||
return self.backcolor[1]/256, self.backcolor[2]/256, self.backcolor[3]/256
|
|
||||||
end
|
|
||||||
|
|
||||||
-- UPDATE FUNCTIONS
|
-- UPDATE FUNCTIONS
|
||||||
-- All update functions
|
-- All update functions
|
||||||
|
|
||||||
|
@ -121,11 +115,4 @@ function World:drawMap()
|
||||||
self.map:draw(-tx, -ty, scale, scale)
|
self.map:draw(-tx, -ty, scale, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:drawBackgroundColor()
|
|
||||||
local r, g, b = self.backcolor[1], self.backcolor[2], self.backcolor[3]
|
|
||||||
love.graphics.setColor(r/256, g/256, b/256)
|
|
||||||
love.graphics.rectangle("fill", 0, 0, 480, 272)
|
|
||||||
utils.graphics.resetColor()
|
|
||||||
end
|
|
||||||
|
|
||||||
return World
|
return World
|
||||||
|
|
Loading…
Reference in New Issue