Fix merge conflict.

This commit is contained in:
bʰedoh₂ swé 2024-04-03 19:20:04 +05:00
commit afee869fbf

44
main.py
View File

@ -75,12 +75,26 @@ 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))
font = pygame.freetype.Font(None,18) clock = pygame.time.Clock()
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:
@ -97,6 +111,9 @@ 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)
@ -106,18 +123,23 @@ 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:
a = complex(Poincare2Klein(MobiusAdd(i.pointA,-gPlayer.cPos))) if debugInfo:
b = complex(Poincare2Klein(MobiusAdd(i.pointB,-gPlayer.cPos))) fps_surf, cPos_surf, cRot_surf = renderDebugInfo(gPlayer, clock, fontSize)
print(a,b)
pygame.draw.line(display, WHITE, (a.real * 100 + 100, (a.imag * 100 + 200)), (b.real * 100 + 100, (b.imag * 100 + 200))) display.blit(fps_surf, (0, 0))
font.render_to(display, (8, 8), "cPos: " + str(gPlayer.cPos), (255, 255, 255), (0, 0, 0)) display.blit(cPos_surf, (0, fps_surf.get_height()))
font.render_to(display, (8, 26), "cRot: " + str(gPlayer.cRot), (255, 255, 255), (0, 0, 0)) 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.display.update() pygame.display.update()
frameend = time_ns() #frameend = time_ns()
sleep((frameend-framestart) / F_) clock.tick()
#sleep((frameend-framestart) / F_)
return True return True
def main(): def main():