little fix
This commit is contained in:
parent
d1b793dd80
commit
48d9217816
1 changed files with 14 additions and 8 deletions
20
main.py
20
main.py
|
@ -14,16 +14,21 @@ def get_debug_text():
|
||||||
screen.blit(debug_text,(0,line_counter*default_font.get_height()))
|
screen.blit(debug_text,(0,line_counter*default_font.get_height()))
|
||||||
|
|
||||||
line_counter = 1
|
line_counter = 1
|
||||||
globalvars =globals()
|
globalvars = globals()
|
||||||
for a in globalvars:
|
for a in globalvars:
|
||||||
text(f"{str(a)} = {str(globalvars[a])}",line_counter)
|
text(f"{str(a)} = {str(globalvars[a])}",line_counter)
|
||||||
line_counter += 1
|
line_counter += 1
|
||||||
|
|
||||||
|
def centered_text(text=str,pos=tuple,color=tuple):
|
||||||
|
text = default_font.render(str(text), True, color)
|
||||||
|
screen.blit(text,(pos[0]-text.get_width()/2,pos[1]))
|
||||||
def get_best_size():
|
def get_best_size():
|
||||||
if screensize[0] <= screensize[1]:
|
if screensize[0] <= screensize[1]:
|
||||||
best = screensize[0]
|
best = screensize[0]
|
||||||
else:
|
else:
|
||||||
best = screensize[1]
|
best = screensize[0]
|
||||||
return best
|
return best
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
screen = pygame.display.set_mode([500,500],pygame.RESIZABLE)
|
screen = pygame.display.set_mode([500,500],pygame.RESIZABLE)
|
||||||
|
@ -32,7 +37,7 @@ default_font = pygame.font.SysFont("sans", 14)
|
||||||
|
|
||||||
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
||||||
winkel = 0
|
winkel = 0
|
||||||
best_radios = (get_best_size())/2-20
|
best_radios = get_best_size()/2-20
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -54,20 +59,21 @@ if __name__ == "__main__":
|
||||||
screensize = pygame.display.get_window_size()
|
screensize = pygame.display.get_window_size()
|
||||||
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
||||||
screen.fill((0,0,0))
|
screen.fill((0,0,0))
|
||||||
best_radios = (get_best_size())/2-20
|
best_radios = get_best_size()/2-20
|
||||||
|
|
||||||
if winkel >= 360 or winkel <= -1:
|
if winkel >= 360 or winkel <= -1:
|
||||||
winkel = 0
|
winkel = 0
|
||||||
a,b = berechne_dreieck(winkel,best_radios)#screensize[0]*screensize[1])
|
a,b = berechne_dreieck(winkel,200)#screensize[0]*screensize[1])
|
||||||
|
|
||||||
end_pos = start_pos[0]+a,start_pos[1]+b
|
end_pos = start_pos[0]+a,start_pos[1]+b
|
||||||
# draw c schwarz
|
# draw c schwarz
|
||||||
pygame.draw.line(screen,(0,0,0),start_pos,end_pos,3)
|
pygame.draw.line(screen,(0,0,0),start_pos,end_pos,3)
|
||||||
|
centered_text("c",(end_pos[0]+10,end_pos[1]+10),(0,0,0))
|
||||||
# draw a rot
|
# draw a rot
|
||||||
pygame.draw.line(screen,(255,0,0),start_pos,(start_pos[0]+a,start_pos[1]),3)
|
pygame.draw.line(screen,(255,0,0),start_pos,(start_pos[0]+a,start_pos[1]),3)
|
||||||
|
centered_text("a",(start_pos[0]+10,start_pos[1]+10),(255,0,0))
|
||||||
# draw b blau
|
# draw b blau
|
||||||
pygame.draw.line(screen,(0,0,255),(start_pos[0]+a,start_pos[1]),(start_pos[0]+a,start_pos[1]+b),3)
|
pygame.draw.line(screen,(0,0,255),(start_pos[0]+a,start_pos[1]),(start_pos[0]+a,start_pos[1]+b),3)
|
||||||
|
centered_text("b",(start_pos[0]+a+10,start_pos[1]+10),(0,0,255))
|
||||||
|
|
||||||
get_debug_text()
|
get_debug_text()
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
Loading…
Reference in a new issue