modules/world: add a way to check collisions

This commit is contained in:
Kazhnuz 2019-05-05 13:01:00 +02:00
parent 977a735608
commit b80566b4ec
2 changed files with 10 additions and 0 deletions

View file

@ -102,6 +102,12 @@ function BaseWorld:moveActor(actor, x, y, filter)
return x, y, {}, 0 return x, y, {}, 0
end end
function BaseWorld:checkCollision(actor, x, y, filter)
-- 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 BaseWorld:queryRect(x, y, w, h) function BaseWorld:queryRect(x, y, w, h)
local query = {} local query = {}
local x2, y2 = x + w, y + h local x2, y2 = x + w, y + h

View file

@ -53,6 +53,10 @@ function World2D:moveActor(actor, x, y, filter)
return self.actors:move(actor, x, y, filter) return self.actors:move(actor, x, y, filter)
end end
function World2D:checkCollision(actor, x, y, filter)
return self.actors:check(actor, x, y, filter)
end
function World2D:queryRect(x, y, w, h) function World2D:queryRect(x, y, w, h)
return self.actors:queryRect(x, y, w, h) return self.actors:queryRect(x, y, w, h)
end end