refactor(levels): remove more replacable functions in World
This commit is contained in:
parent
1c29ae0dfa
commit
201cc80d0a
|
@ -9,24 +9,7 @@ local Sti = require "libs.sti"
|
||||||
-- All functions to init the world and the map
|
-- All functions to init the world and the map
|
||||||
|
|
||||||
function World:new(scene, mapfile, actorlist)
|
function World:new(scene, mapfile, actorlist)
|
||||||
self.scene = scene
|
self.super.new(self, scene, actorlist, mapfile)
|
||||||
self.actorlist = actorlist
|
|
||||||
self.mapfile = mapfile
|
|
||||||
|
|
||||||
self:initActors()
|
|
||||||
|
|
||||||
self:initMap(self.mapfile)
|
|
||||||
self:setActorList(self.actorlist)
|
|
||||||
self:setGravity()
|
|
||||||
|
|
||||||
self:register()
|
|
||||||
|
|
||||||
self.isActive = true
|
|
||||||
end
|
|
||||||
|
|
||||||
function World:loadMapObjects()
|
|
||||||
self:loadMapCollisions()
|
|
||||||
self:loadMapActors()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:getStartPosition()
|
function World:getStartPosition()
|
||||||
|
@ -50,21 +33,12 @@ function World:changeActorData(actor)
|
||||||
self.actors:update(actor, actor.x, actor.y, actor.w, actor.h)
|
self.actors:update(actor, actor.x, actor.y, actor.w, actor.h)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MAP FUNCTIONS
|
|
||||||
-- All map wrappers
|
|
||||||
|
|
||||||
function World:getDimensions()
|
|
||||||
return self.map.width * self.map.tilewidth,
|
|
||||||
self.map.height * self.map.tileheight
|
|
||||||
end
|
|
||||||
|
|
||||||
-- UPDATE FUNCTIONS
|
-- UPDATE FUNCTIONS
|
||||||
-- All update functions
|
-- All update functions
|
||||||
|
|
||||||
function World:update(dt)
|
function World:update(dt)
|
||||||
self.scene.playermanager:update(dt)
|
self.scene.playermanager:update(dt)
|
||||||
self:updateActors(dt)
|
self.super.update(self, dt)
|
||||||
self:updateMap(dt)
|
|
||||||
self.scene.camera:update(dt)
|
self.scene.camera:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,20 +52,10 @@ function World:draw()
|
||||||
self:drawBackgroundColor()
|
self:drawBackgroundColor()
|
||||||
self.scene.camera:attach()
|
self.scene.camera:attach()
|
||||||
self:drawMap()
|
self:drawMap()
|
||||||
self:drawEntities()
|
self:drawActors()
|
||||||
self.scene.camera:detach()
|
self.scene.camera:detach()
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:drawEntities()
|
|
||||||
--l,t,w,h = l or 0, t or 0, w or self.width, h or self.height
|
|
||||||
local visibleThings, len = self.scene.camera:getVisibleEntities()
|
|
||||||
--table.sort(visibleThings, sortByUpdateOrder)
|
|
||||||
|
|
||||||
for i=1, len do
|
|
||||||
visibleThings[i]:draw(dt)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function World:drawMap()
|
function World:drawMap()
|
||||||
-- Du à la manière dont fonctionne STI, on est obligé de récupérer les info
|
-- Du à la manière dont fonctionne STI, on est obligé de récupérer les info
|
||||||
-- de position de camera pour afficher la carte par rapport à ces infos
|
-- de position de camera pour afficher la carte par rapport à ces infos
|
||||||
|
|
Loading…
Reference in New Issue