From 207bae6e1d7f017a51f77b4fde81652c31fbea49 Mon Sep 17 00:00:00 2001 From: Daniele Verducci Date: Sun, 15 Jan 2023 09:53:09 +0100 Subject: [PATCH] Perspective --- racing-sim.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/racing-sim.py b/racing-sim.py index f5e50ee..5ae455f 100755 --- a/racing-sim.py +++ b/racing-sim.py @@ -97,10 +97,11 @@ class Main: # Draw road for y in range(int(RENDER_HEIGHT/2), RENDER_HEIGHT): + perspectiveMult = (y - RENDER_HEIGHT / 2) / (RENDER_HEIGHT / 2) * 0.8 + 0.2 # Range 0.2 - 1.0 roadWidth = 0.6 - roadWidthPixels = roadWidth * RENDER_WIDTH + roadWidthPixels = roadWidth * RENDER_WIDTH * perspectiveMult roadCenterPixels = (RENDER_WIDTH - roadWidth) / 2 - kerbWidth = KERB_WIDTH * RENDER_WIDTH + kerbWidth = KERB_WIDTH * RENDER_WIDTH * perspectiveMult sdl2.SDL_SetRenderDrawColor(self.renderer, KERB_COLOR[0], KERB_COLOR[1], KERB_COLOR[2], sdl2.SDL_ALPHA_OPAQUE) # Left Kerb