refactor(levels): remove more replacable functions in World

This commit is contained in:
Kazhnuz 2019-06-17 13:26:36 +02:00
parent 1c29ae0dfa
commit 201cc80d0a
1 changed files with 3 additions and 39 deletions

View File

@ -9,24 +9,7 @@ local Sti = require "libs.sti"
-- All functions to init the world and the map
function World:new(scene, mapfile, actorlist)
self.scene = scene
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()
self.super.new(self, scene, actorlist, mapfile)
end
function World:getStartPosition()
@ -50,21 +33,12 @@ function World:changeActorData(actor)
self.actors:update(actor, actor.x, actor.y, actor.w, actor.h)
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
-- All update functions
function World:update(dt)
self.scene.playermanager:update(dt)
self:updateActors(dt)
self:updateMap(dt)
self.super.update(self, dt)
self.scene.camera:update(dt)
end
@ -78,20 +52,10 @@ function World:draw()
self:drawBackgroundColor()
self.scene.camera:attach()
self:drawMap()
self:drawEntities()
self:drawActors()
self.scene.camera:detach()
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()
-- 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