Page 1 of 1
2D scroller collision [help]
Posted: Fri Nov 23, 2012 3:14 am
by hally
Re: 2D scroller collision [help]
Posted: Fri Nov 23, 2012 4:06 am
by Qcode
Welcome to the forum!
Your collision still isn't working, but I've fixed the error you've been getting. What you were doing was accessing the table by the player x and y. The problem was however, that your map table didn't include tiles for every single pixel on the screen, which it shouldn't. So to fix this you would get the tile that the players coordinates were on. So you would replace line 121 with:
Code: Select all
if map[math.floor(player.y/16) + y][math.floor(player.x/16) + x] == 1 then
The 16 is because you have tiles with width and height of 16.
That'll fix your error.
Hope that helps.
~Qcode
P.S Also next time you should post requests for help in the Support and Development forum, not general.
Re: 2D scroller collision [help]
Posted: Fri Nov 23, 2012 7:15 am
by hally
Oh thanks lol that took me like a couple of seconds to look and then i noticed what you where talking about would have had no clue if you didn't help thank for the help