im trying to implement a simple orthogonal game however ive hit a wall (pun) with the collision detection setup. currently the program is supposed to throw an assert when the character waks into a wall however the wall seems to be located up and to the left of where it should be. My best guesses as to where the error(s) occurs is:
function loadMap(id) --returns map
local map = ATL.Loader.load(id)
local collid = {}
for x = 1, map.width do
collid[x] = {}
for y = 1, map.height do
collid[x][y] = 0 end
end
for x, y, tile in map("1"):iterate() do
if tile.properties.WALL then collid[x][y] = 1
end end
return map, collid
end
located in the file map.lua
thank you for reading and any advice on how to make my code better in any way would be appreciated.
Last edited by mabbott on Wed Aug 21, 2013 12:49 am, edited 1 time in total.
I believe the .love file should run now without crashing. I redesigned my collision however it still doesnt work. im really not sure whats wrong with it.
the overall idea is that the function loadMap() creates a table with the top, bottom, right, and left values for each wall tile. then the player:move() function checks the players bounding box against each of the wall bounding boxes. however it doesnt work right at all.