Compare commits
4 Commits
f077c39130
...
a2447c8f72
Author | SHA1 | Date | |
---|---|---|---|
a2447c8f72 | |||
afee869fbf | |||
d834775835 | |||
1b25a258cf |
36
main.py
36
main.py
@ -75,12 +75,26 @@ def cap(rN):
|
||||
return 0
|
||||
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():
|
||||
gPlayer = GyroVector(0,1)
|
||||
display = pygame.display.set_mode((1280,720))
|
||||
font = pygame.freetype.Font(None,18)
|
||||
clock = pygame.time.Clock()
|
||||
fontSize = 18
|
||||
debugInfo = True
|
||||
|
||||
while True:
|
||||
framestart = time_ns()
|
||||
#framestart = time_ns()
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
@ -97,6 +111,9 @@ 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)
|
||||
drawn = draw(level,gPlayer,PI/2,160)
|
||||
@ -106,18 +123,23 @@ def mainLoop():
|
||||
for i in drawn:
|
||||
pygame.draw.rect(display,i.color, (n,(1 - i.height) * 360,8,cap(i.height) * 1280))
|
||||
n += 8
|
||||
|
||||
if debugInfo:
|
||||
fps_surf, cPos_surf, cRot_surf = renderDebugInfo(gPlayer, clock, fontSize)
|
||||
|
||||
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)))
|
||||
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, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0))
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
frameend = time_ns()
|
||||
sleep((frameend-framestart) / F_)
|
||||
#frameend = time_ns()
|
||||
clock.tick()
|
||||
#sleep((frameend-framestart) / F_)
|
||||
return True
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user