Page 1 of 1

Yet another broken collision function

Posted: Sun Aug 18, 2013 1:36 am
by mabbott
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:

Code: Select all

 function player:collision(dt) 
at 140 of playa.lua or :

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
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.

Re: Yet another broken collision function

Posted: Sun Aug 18, 2013 11:10 am
by Jeeper
Trying to run it gives an error.

http://imgur.com/KhvDs6T


Remember that it is case sensitive.

Re: Yet another broken collision function

Posted: Wed Aug 21, 2013 12:55 am
by mabbott
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.