Page 1 of 1

Trying to make a Raycaster. Issues with angles and list indexing

Posted: Sun May 03, 2020 9:15 pm
by interestingtimer
I'm trying to implement this tutorial by permadi into Love2d https://permadi.com/1996/05/ray-casting ... -contents/.
Right now I'm on part 7 and attempting to implement the detection of intersections with horizontal gridlines. I've drawn the map grid and the player's first ray and it appears to work for certain angles, but while rotating it reaches a point when the game crashes with the "Attempt to index a nil value" error message.

Also, at 15 degrees, the detection does not work at all and the ray stops before it even reaches a wall. I've sat here for a day but I can't find any way to prevent these two errors. How do I fix it?

Re: Trying to make a Raycaster. Issues with angles and list indexing

Posted: Fri May 08, 2020 5:03 pm
by pgimeno
Hi, welcome to the forums.

The game crashes when one coordinate becomes negative.