forked from bedohswe/p3he
Compare commits
5 Commits
d834775835
...
380b9f96a4
Author | SHA1 | Date | |
---|---|---|---|
380b9f96a4 | |||
42f88ff93b | |||
a2447c8f72 | |||
afee869fbf | |||
f077c39130 |
4
gyro.py
4
gyro.py
@ -1,4 +1,8 @@
|
||||
try:
|
||||
from numpy import complex256
|
||||
except ImportError:
|
||||
from numpy import complex128 as complex256
|
||||
|
||||
def ZeroCheck(cN):
|
||||
if cN == complex256(complex(0,0)):
|
||||
return complex256(complex(1,0))
|
||||
|
18
main.py
18
main.py
@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
try:
|
||||
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 cmath import exp, pi
|
||||
import pygame
|
||||
@ -56,7 +60,7 @@ def draw(level,gPlayer,fov,res):
|
||||
cInt = cLineIntersection(tA,tB,complex256(0),rot)
|
||||
except ZeroDivisionError:
|
||||
continue
|
||||
rDist = cDist(0,cInt)
|
||||
rDist = cDist(0,cInt) * irot.real
|
||||
if not (j.isFinite and cBetween(tA,tB,cInt)):
|
||||
continue
|
||||
if cDot(cInt,rot) > 0:
|
||||
@ -98,6 +102,8 @@ def mainLoop():
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_q:
|
||||
gPlayer.cRot *= -1
|
||||
if event.key == pygame.K_F3:
|
||||
debugInfo = not debugInfo
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_d]:
|
||||
gPlayer.rotate(ROT)
|
||||
@ -107,8 +113,6 @@ def mainLoop():
|
||||
gPlayer -= GyroVector(OFFSET * gPlayer.cRot, 1)
|
||||
if keys[pygame.K_s]:
|
||||
gPlayer += GyroVector(OFFSET * gPlayer.cRot, 1)
|
||||
if keys[pygame.K_F3]:
|
||||
debugInfo = not debugInfo
|
||||
|
||||
display.fill(WHITE)
|
||||
#pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0)
|
||||
@ -117,7 +121,7 @@ def mainLoop():
|
||||
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
||||
n = 0
|
||||
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
|
||||
|
||||
if debugInfo:
|
||||
@ -126,6 +130,10 @@ def mainLoop():
|
||||
display.blit(fps_surf, (0, 0))
|
||||
display.blit(cPos_surf, (0, fps_surf.get_height()))
|
||||
display.blit(cRot_surf, (0, fps_surf.get_height() + fontSize))
|
||||
for i in level:
|
||||
a = complex(Poincare2Klein(MobiusAdd(i.pointA,-gPlayer.cPos)))
|
||||
b = complex(Poincare2Klein(MobiusAdd(i.pointB,-gPlayer.cPos)))
|
||||
pygame.draw.line(display, WHITE, (a.real * 100 + 100, (a.imag * 100 + 200)), (b.real * 100 + 100, (b.imag * 100 + 200)))
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user