modules/world: port all actor functions from IP

This commit is contained in:
Kazhnuz 2019-04-07 13:31:25 +02:00
parent 171ff007e9
commit 5365f23c30
1 changed files with 34 additions and 0 deletions

View File

@ -16,10 +16,44 @@ function BaseWorld:registerActor(actor)
table.insert(self.actors, actor)
end
function World:removeActor(actor)
for i,v in ipairs(self.actors) do
if v == actor then
table.remove(self.actors, i)
end
end
end
function World:moveActor(actor, x, y, filter)
self.actors[actor].x = x
self.actors[actor].y = y
-- as the baseworld have no collision function, we return empty collision
-- datas, but from the same type than bump2D will return
return x, y, {}, 0
end
function World:queryRect(x, y, w, h)
local query = {}
local x2, y2 = x + w, y + h
for i,v in ipairs(self.actors) do
if (v.x >= x) and (v.x + v.w >= x1) and
(v.y >= y) and (v.y + v.h >= y1) then
table.insert(query, v)
end
end
return v
end
function BaseWorld:countActors()
return #self.actors
end
function World:getActors()
return self.actors
end
-- UPDATE FUNCTIONS
-- All update functions