From b80566b4eccf6133a0cc5359c11dfb84aa36a526 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 5 May 2019 13:01:00 +0200 Subject: [PATCH] modules/world: add a way to check collisions --- gamecore/modules/world/baseworld.lua | 6 ++++++ gamecore/modules/world/world2D.lua | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 844fb17..28ea22e 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -102,6 +102,12 @@ function BaseWorld:moveActor(actor, x, y, filter) return x, y, {}, 0 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) local query = {} local x2, y2 = x + w, y + h diff --git a/gamecore/modules/world/world2D.lua b/gamecore/modules/world/world2D.lua index eeb6899..d63b074 100644 --- a/gamecore/modules/world/world2D.lua +++ b/gamecore/modules/world/world2D.lua @@ -53,6 +53,10 @@ function World2D:moveActor(actor, x, y, filter) return self.actors:move(actor, x, y, filter) end +function World2D:checkCollision(actor, x, y, filter) + return self.actors:check(actor, x, y, filter) +end + function World2D:queryRect(x, y, w, h) return self.actors:queryRect(x, y, w, h) end