The code that checks the collision at the moment is this:
Code: Select all
local collisionData = mapManager.getCollisionData(currentMap)
local px1, py1 = p.pos.x, p.pos.y
local px2, py2 = px1 + p.size.x, py1 + p.size.y
for i, obj in pairs(collisionData) do
local bx1, by1 = obj.x, obj.y
local bx2, by2 = bx1 * tileSize, by1 * tileSize
if (px1 < bx2) and (px1 > bx2) and (py1 < by2) and (py1 > by2) then
-- My issue is here, this print line never gets triggered.
print("collides.")
end
end
- "tileSize" is well, the size for tiles, a number.
- "getCollisionData" returns a table containing an X and a Y value for all of the solid objects
- "p" is the player, and like any other object has an X, Y, and size values.
I apologize if I missed out on something, I am very tired of working on collisions
Also, I'd rather make my own system than use bump, for the learning experience mostly. Thanks!