scenes/levels: remove world.entities

This commit is contained in:
Kazhnuz 2019-05-30 19:36:58 +02:00
parent d7ff2066ab
commit 5ff324f5b0
1 changed files with 16 additions and 14 deletions

View File

@ -1,9 +1,10 @@
local World = Object:extend()
local World2D = require "core.modules.world.world2D"
local World = World2D:extend()
local Obj = require "scenes.levels.entities"
local Sti = require "libs.sti"
local Bump = require "libs.bump"
-- INIT FUNCTIONS
-- All functions to init the world and the map
@ -12,7 +13,7 @@ function World:new(scene, mapfile)
self.scene = scene
self.map = Sti("assets/maps/" .. mapfile .. ".lua")
self.obj = Obj
self.entities = Bump.newWorld(50)
self:initActors()
self.backcolor = self.map.backgroundcolor or {0, 0, 0}
self.activeObjects = 0
@ -91,31 +92,32 @@ function World:addCollision(x, y, w, h, name)
self.obj.Collision(self.scene, x, y, w, h, name)
end
-- ENTITY MANAGEMENT FUNCTIONS
-- All BUMP2D wrappers
-- ENTITY MANAGEMENT COMPABILITY FUNCTIONS
-- Wrapper arround new function names
function World:addEntity(entity)
return self.entities:add(entity, entity.x, entity.y, entity.w, entity.h)
print("WARNING: World:addEntity is replaced by World:registerActor")
return self:registerActor(entity)
end
function World:moveEntity(entity, x, y, filter)
return self.entities:move(entity, x, y, filter)
print("WARNING: World:moveEntity is replaced by World:moveActor")
return self:moveActor(entity, x, y, filter)
end
function World:removeEntity(entity)
return self.entities:remove(entity)
end
function World:queryRect(x, y, w, h)
return self.entities:queryRect(x, y, w, h)
print("WARNING: World:removeEntity is replaced by World:removeActor")
return self:removeActor(entity)
end
function World:countEntities()
return self.entities:countItems()
print("WARNING: World:removeEntity is replaced by World:countActors")
return self:countActors()
end
function World:getEntities()
return self.entities:getItems()
print("WARNING: World:getEntities is replaced by World:getActors")
return self:getActors()
end
-- MAP FUNCTIONS