From 8e3727c870862be1c407cd3007b7ee88c295b2a4 Mon Sep 17 00:00:00 2001 From: "Daniele Verducci (Slimpenguin)" Date: Thu, 5 Jan 2023 00:22:57 +0100 Subject: [PATCH] Fixed negative angles, colored rays for debugging --- raycaster.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/raycaster.py b/raycaster.py index ddd659a..7eb744e 100755 --- a/raycaster.py +++ b/raycaster.py @@ -137,7 +137,9 @@ class Main: # Cast 60 rays from -30° to +30° (60° viewing angle) 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 dof = 0 # Depth of field @@ -224,7 +226,7 @@ class Main: shortestDist = horizDist # 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 ------