diff --git a/raycaster.py b/raycaster.py index 99025ba..04f1e2b 100755 --- a/raycaster.py +++ b/raycaster.py @@ -134,9 +134,9 @@ class Main: # Casts rays for raycasting playerAngle = self.player_position["r"] - # Cast 100 rays from -0,5 rads to +0,5 rads (about 60° viewing angle) - for i in range(100): - rayAngle = playerAngle + (i/100) - 0.5 + # Cast one ray for every window pixel, from -0,5 rads to +0,5 rads (about 60° viewing angle) + for i in range(RAYCAST_WIN_WIDTH): + rayAngle = playerAngle + (i/RAYCAST_WIN_WIDTH) - 0.5 if rayAngle < 0: rayAngle = math.pi * 2 + rayAngle if rayAngle > math.pi * 2: @@ -245,8 +245,7 @@ class Main: color = sdl2.ext.Color(200,200,200,255) # Draw line - for x in range(i*15, i*15+15): - sdl2.ext.draw.line(self.raycastSurface, color, (x, int(lineOffset), x, int(lineOffset + lineHeight))) + sdl2.ext.draw.line(self.raycastSurface, color, (i, int(lineOffset), i, int(lineOffset + lineHeight))) def dist(self, ax, ay, bx, by): return math.sqrt((bx-ax)*(bx-ax) + (by-ay)*(by-ay))