forked from bedohswe/p3he
Compare commits
No commits in common. "3b2359aa410fd91873426988efcd3a54bcdf448c" and "e1010930b5e76112f2f804695ca4d9b4787711c8" have entirely different histories.
3b2359aa41
...
e1010930b5
20
main.py
20
main.py
@ -7,7 +7,6 @@ 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 *
|
||||
@ -57,13 +56,15 @@ 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:
|
||||
continue
|
||||
if cDot(rot,MobiusAdd(cInt,-gPlayer.cPos)) > 0:
|
||||
continue
|
||||
rDist = MobiusDist(cInt,gPlayer.cPos)*1.1
|
||||
rDist = MobiusDist(cInt,gPlayer.cPos)
|
||||
if not (j.isFinite and cBetween(j.pointA,j.pointB,cInt)):
|
||||
continue
|
||||
if (1 - m.height) > rDist:
|
||||
@ -83,7 +84,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(acos(gPlayer.cRot.real) / pi * 180), font_fg, font_bg)[0]
|
||||
cRot_surf = font.render("cRot: " + str(gPlayer.cRot), font_fg, font_bg)[0]
|
||||
|
||||
return fps_surf, cPos_surf, cRot_surf
|
||||
|
||||
@ -105,11 +106,13 @@ def mainLoop():
|
||||
wall_buffer = []
|
||||
|
||||
while True:
|
||||
#framestart = time_ns()
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
return True
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_r:
|
||||
if event.key == pygame.K_q:
|
||||
gPlayer.cRot *= -1
|
||||
if event.key == pygame.K_F3:
|
||||
debugInfo = not debugInfo
|
||||
@ -126,17 +129,14 @@ 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]:
|
||||
gPlayer += GyroVector(OFFSET * gPlayer.cRot, 1)
|
||||
|
||||
display.fill(WHITE)
|
||||
drawn = draw(level,gPlayer,PI/4,320)
|
||||
#pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0)
|
||||
drawn = draw(level,gPlayer,PI/2,320)
|
||||
pygame.draw.rect(display,SKY, (0,0,1280,360))
|
||||
pygame.draw.rect(display,GROUND, (0,360,1280,360))
|
||||
n = 0
|
||||
@ -157,7 +157,9 @@ def mainLoop():
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
#frameend = time_ns()
|
||||
clock.tick()
|
||||
#sleep((frameend-framestart) / F_)
|
||||
return True
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user