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

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
interestingtimer
Prole
Posts: 1
Joined: Sun May 03, 2020 9:06 pm

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

Post 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?
Attachments
main.love
(1.52 KiB) Downloaded 132 times
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Hi, welcome to the forums.

The game crashes when one coordinate becomes negative.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests