I have been attempting to make a raycast in ICE and I’m stuck on some math. I need to be able to have a for statement that loops through the rays (I’m only doing 7 rays for right now) and in that a line that moves the point forward on the ray. I have a black and white sprite that gets printed on the screen at (0,0) Here is the code I have so far:
Code:
I don’t mind if it doesn’t directly work with ICE because I can change it a bit. Also if there are any question or something is hard to understand please ask (:
Code:
For(Theta,~30,30,10 # 0° is forward and it loops through by 10° so the view is 70° wide
PX->TESTX # reset the start to the player
PY->TESTY # same just the Y cord
Repeat N=10 # repeats until the ray is 10 pixels long
setColor(224) # sets the color of the ray
If getPixel(TESTX, TESTY)!=0 # if the pixel that is tested is not black
setPixel(TESTX, TESTY) # sets the non-black pixels to red to show ray
# moves the point forward on the ray by changing the x and y (what I need help with)
Else # if the pixel is black
Save the point and N to a list # save the point and N to the list for when I draw (going to wait for this)
End
End
End
I don’t mind if it doesn’t directly work with ICE because I can change it a bit. Also if there are any question or something is hard to understand please ask (: