Yet another broken collision function

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
mabbott
Prole
Posts: 2
Joined: Sun Aug 18, 2013 1:20 am

Yet another broken collision function

Post 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.
Last edited by mabbott on Wed Aug 21, 2013 12:49 am, edited 1 time in total.
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Yet another broken collision function

Post by Jeeper »

Trying to run it gives an error.

http://imgur.com/KhvDs6T


Remember that it is case sensitive.
mabbott
Prole
Posts: 2
Joined: Sun Aug 18, 2013 1:20 am

Re: Yet another broken collision function

Post 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.
Attachments
a tree.love
(488.33 KiB) Downloaded 107 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 8 guests