This commit is contained in:
bʰedoh₂ swé 2024-04-03 19:15:42 +05:00
parent 753022bfb3
commit f077c39130
2 changed files with 17 additions and 5 deletions

View File

@ -1,4 +1,8 @@
try:
from numpy import complex256 from numpy import complex256
except ImportError:
from numpy import complex128 as complex256
def ZeroCheck(cN): def ZeroCheck(cN):
if cN == complex256(complex(0,0)): if cN == complex256(complex(0,0)):
return complex256(complex(1,0)) return complex256(complex(1,0))

16
main.py
View File

@ -1,6 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
try:
from numpy import complex256 from numpy import complex256
except ImportError:
from numpy import complex128 as complex256
print("Warning! Cannot use full precision!")
from time import time_ns, sleep from time import time_ns, sleep
from cmath import exp, pi from cmath import exp, pi
import pygame import pygame
@ -56,7 +60,7 @@ def draw(level,gPlayer,fov,res):
cInt = cLineIntersection(tA,tB,complex256(0),rot) cInt = cLineIntersection(tA,tB,complex256(0),rot)
except ZeroDivisionError: except ZeroDivisionError:
continue continue
rDist = cDist(0,cInt) rDist = cDist(0,cInt) * irot.real
if not (j.isFinite and cBetween(tA,tB,cInt)): if not (j.isFinite and cBetween(tA,tB,cInt)):
continue continue
if cDot(cInt,rot) > 0: if cDot(cInt,rot) > 0:
@ -100,9 +104,13 @@ def mainLoop():
pygame.draw.rect(display,GROUND, (0,360,1280,360)) pygame.draw.rect(display,GROUND, (0,360,1280,360))
n = 0 n = 0
for i in drawn: for i in drawn:
pygame.draw.rect(display,i.color, (n,360 - (cap(i.height) * 360),10,cap(i.height) * 1000)) pygame.draw.rect(display,i.color, (n,(1 - i.height) * 360,8,cap(i.height) * 1280))
n += 8 n += 8
for i in level:
a = complex(Poincare2Klein(MobiusAdd(i.pointA,-gPlayer.cPos)))
b = complex(Poincare2Klein(MobiusAdd(i.pointB,-gPlayer.cPos)))
print(a,b)
pygame.draw.line(display, WHITE, (a.real * 100 + 100, (a.imag * 100 + 200)), (b.real * 100 + 100, (b.imag * 100 + 200)))
font.render_to(display, (8, 8), "cPos: " + str(gPlayer.cPos), (255, 255, 255), (0, 0, 0)) font.render_to(display, (8, 8), "cPos: " + str(gPlayer.cPos), (255, 255, 255), (0, 0, 0))
font.render_to(display, (8, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0)) font.render_to(display, (8, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0))