Yet another broken collision function
Posted: Sun Aug 18, 2013 1:36 am
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:
at 140 of playa.lua or :
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.
Code: Select all
function player:collision(dt)
Code: Select all
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
thank you for reading and any advice on how to make my code better in any way would be appreciated.