From f2319739848c3c8eaa29d6ec750848b147817387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Thu, 4 Apr 2024 21:17:24 +0500 Subject: [PATCH 1/3] Add strafe. --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a3b5ef0..395bd89 100755 --- a/main.py +++ b/main.py @@ -64,7 +64,7 @@ def draw(level,gPlayer,fov,res): continue if cDot(rot,MobiusAdd(cInt,-gPlayer.cPos)) > 0: continue - rDist = MobiusDist(cInt,gPlayer.cPos) + rDist = MobiusDist(cInt,gPlayer.cPos)*1.1 if not (j.isFinite and cBetween(j.pointA,j.pointB,cInt)): continue if (1 - m.height) > rDist: @@ -102,7 +102,7 @@ def mainLoop(): if event.type == pygame.QUIT: return True if event.type == pygame.KEYDOWN: - if event.key == pygame.K_q: + if event.key == pygame.K_r: gPlayer.cRot *= -1 if event.key == pygame.K_F3: debugInfo = not debugInfo @@ -111,6 +111,10 @@ def mainLoop(): gPlayer.rotate(ROT) if keys[pygame.K_a]: gPlayer.rotate(IROT) + if keys[pygame.K_q]: + gPlayer += GyroVector(OFFSET * gPlayer.cRot*I, 1) + if keys[pygame.K_e]: + gPlayer -= GyroVector(OFFSET * gPlayer.cRot*I, 1) if keys[pygame.K_w]: gPlayer -= GyroVector(OFFSET * gPlayer.cRot, 1) if keys[pygame.K_s]: From 983bad10a5cfeebeeca6bdffeb2a95ad4242d64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Thu, 4 Apr 2024 21:32:01 +0500 Subject: [PATCH 2/3] Show angle in degrees. --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 395bd89..e0c5ba8 100755 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ except ImportError: from time import time_ns, sleep from cmath import exp, pi +from math import acos import pygame import pygame.freetype from gyro import * @@ -84,7 +85,7 @@ def renderDebugInfo(gPlayer, clock, fontSize = 18): fps_surf = font.render("FPS: " + str(int(clock.get_fps())), font_fg, font_bg)[0] cPos_surf = font.render("cPos: " + str(gPlayer.cPos), font_fg, font_bg)[0] - cRot_surf = font.render("cRot: " + str(gPlayer.cRot), font_fg, font_bg)[0] + cRot_surf = font.render("cRot: " + str(acos(gPlayer.cRot.real) / pi * 180), font_fg, font_bg)[0] return fps_surf, cPos_surf, cRot_surf From 4c7572208a1d7fc6502a3c1bd496728ca893ebd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Thu, 4 Apr 2024 21:33:14 +0500 Subject: [PATCH 3/3] Remove some comments. --- main.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/main.py b/main.py index e0c5ba8..bb9f892 100755 --- a/main.py +++ b/main.py @@ -57,8 +57,6 @@ def draw(level,gPlayer,fov,res): m = DrawnSegment(0,BLACK) rot = irot**(i-(res/2)) * iprot for j in level: - #tA = MobiusAdd(j.pointA,-gPlayer.cPos) - #tB = MobiusAdd(j.pointB,-gPlayer.cPos) try: # Function "LineIntersection" faults from time to time cInt = MobiusInt(j.pointA,j.pointB,gPlayer.cPos,rot) except ZeroDivisionError: @@ -97,8 +95,6 @@ def mainLoop(): debugInfo = True while True: - #framestart = time_ns() - for event in pygame.event.get(): if event.type == pygame.QUIT: return True @@ -122,7 +118,6 @@ def mainLoop(): gPlayer += GyroVector(OFFSET * gPlayer.cRot, 1) display.fill(WHITE) - #pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0) drawn = draw(level,gPlayer,PI/4,320) pygame.draw.rect(display,SKY, (0,0,1280,360)) pygame.draw.rect(display,GROUND, (0,360,1280,360)) @@ -144,9 +139,7 @@ def mainLoop(): pygame.display.update() - #frameend = time_ns() clock.tick() - #sleep((frameend-framestart) / F_) return True def main():