Compare commits

..

No commits in common. "a2447c8f72755408aa554a203deae33f1c8f87a9" and "f077c391302b4f8d86aa284a05ad8a2ad0237003" have entirely different histories.

44
main.py
View File

@ -75,26 +75,12 @@ def cap(rN):
return 0 return 0
return rN return rN
def renderDebugInfo(gPlayer, clock, fontSize = 18):
font = pygame.freetype.Font(None, fontSize)
font_fg = (255, 255, 255)
font_bg = (255, 255, 255, 80)
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]
return fps_surf, cPos_surf, cRot_surf
def mainLoop(): def mainLoop():
gPlayer = GyroVector(0,1) gPlayer = GyroVector(0,1)
display = pygame.display.set_mode((1280,720)) display = pygame.display.set_mode((1280,720))
clock = pygame.time.Clock() font = pygame.freetype.Font(None,18)
fontSize = 18
debugInfo = True
while True: while True:
#framestart = time_ns() framestart = time_ns()
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
@ -111,9 +97,6 @@ def mainLoop():
gPlayer -= GyroVector(OFFSET * gPlayer.cRot, 1) gPlayer -= GyroVector(OFFSET * gPlayer.cRot, 1)
if keys[pygame.K_s]: if keys[pygame.K_s]:
gPlayer += GyroVector(OFFSET * gPlayer.cRot, 1) gPlayer += GyroVector(OFFSET * gPlayer.cRot, 1)
if keys[pygame.K_F3]:
debugInfo = not debugInfo
display.fill(WHITE) display.fill(WHITE)
#pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0) #pygame.draw.rect(display,BLACK, c_tr(Poincare2Klein(gPlayer.cPos) * -100) + (100,100),0)
drawn = draw(level,gPlayer,PI/2,160) drawn = draw(level,gPlayer,PI/2,160)
@ -123,23 +106,18 @@ def mainLoop():
for i in drawn: for i in drawn:
pygame.draw.rect(display,i.color, (n,(1 - i.height) * 360,8,cap(i.height) * 1280)) pygame.draw.rect(display,i.color, (n,(1 - i.height) * 360,8,cap(i.height) * 1280))
n += 8 n += 8
for i in level:
if debugInfo: a = complex(Poincare2Klein(MobiusAdd(i.pointA,-gPlayer.cPos)))
fps_surf, cPos_surf, cRot_surf = renderDebugInfo(gPlayer, clock, fontSize) b = complex(Poincare2Klein(MobiusAdd(i.pointB,-gPlayer.cPos)))
print(a,b)
display.blit(fps_surf, (0, 0)) pygame.draw.line(display, WHITE, (a.real * 100 + 100, (a.imag * 100 + 200)), (b.real * 100 + 100, (b.imag * 100 + 200)))
display.blit(cPos_surf, (0, fps_surf.get_height())) font.render_to(display, (8, 8), "cPos: " + str(gPlayer.cPos), (255, 255, 255), (0, 0, 0))
display.blit(cRot_surf, (0, fps_surf.get_height() + fontSize)) font.render_to(display, (8, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0))
for i in level:
a = complex(Poincare2Klein(MobiusAdd(i.pointA,-gPlayer.cPos)))
b = complex(Poincare2Klein(MobiusAdd(i.pointB,-gPlayer.cPos)))
print(a,b)
pygame.display.update() pygame.display.update()
#frameend = time_ns() frameend = time_ns()
clock.tick() sleep((frameend-framestart) / F_)
#sleep((frameend-framestart) / F_)
return True return True
def main(): def main():