Fixed negative angles, colored rays for debugging
This commit is contained in:
parent
1736931554
commit
8e3727c870
@ -137,7 +137,9 @@ class Main:
|
|||||||
|
|
||||||
# Cast 60 rays from -30° to +30° (60° viewing angle)
|
# Cast 60 rays from -30° to +30° (60° viewing angle)
|
||||||
for i in range(60):
|
for i in range(60):
|
||||||
rayAngle = playerAngle - (i - 30)*DEGREE_IN_RADIANTS
|
rayAngle = playerAngle + (i - 30)*DEGREE_IN_RADIANTS
|
||||||
|
if rayAngle < 0:
|
||||||
|
rayAngle = 2 * math.pi + rayAngle
|
||||||
|
|
||||||
# Check horizontal lines
|
# Check horizontal lines
|
||||||
dof = 0 # Depth of field
|
dof = 0 # Depth of field
|
||||||
@ -224,7 +226,7 @@ class Main:
|
|||||||
shortestDist = horizDist
|
shortestDist = horizDist
|
||||||
|
|
||||||
# Draw rays in 2D view
|
# Draw rays in 2D view
|
||||||
sdl2.ext.draw.line(self.mapSurface, sdl2.ext.Color(0,0,255,255), (self.player_position["x"], self.player_position["y"], rayX, rayY))
|
sdl2.ext.draw.line(self.mapSurface, sdl2.ext.Color(i*4,0,255,255), (self.player_position["x"], self.player_position["y"], rayX, rayY))
|
||||||
|
|
||||||
|
|
||||||
# ------ Draw 3D view ------
|
# ------ Draw 3D view ------
|
||||||
|
Loading…
Reference in New Issue
Block a user