uff
This commit is contained in:
parent
41d7bb6830
commit
8715af45b4
1 changed files with 44 additions and 9 deletions
53
main copy.py
53
main copy.py
|
@ -6,26 +6,61 @@ def berechne_dreieck(alpha,c):
|
||||||
b = sin(alpha)*c# y
|
b = sin(alpha)*c# y
|
||||||
return a,b
|
return a,b
|
||||||
|
|
||||||
|
def get_debug_text():
|
||||||
|
def text(text,line_counter):
|
||||||
|
debug_text = default_font.render(str(text), True, (0,0,0))
|
||||||
|
screen.blit(debug_text,(0,line_counter*default_font.get_height()))
|
||||||
|
|
||||||
|
line_counter = 1
|
||||||
|
globalvars =globals()
|
||||||
|
for a in globalvars:
|
||||||
|
text(f"{str(a)} = {str(globalvars[a])}",line_counter)
|
||||||
|
line_counter += 1
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
screen = pygame.display.set_mode([500,500])
|
screen = pygame.display.set_mode([500,500],pygame.RESIZABLE)
|
||||||
screensize = pygame.display.get_window_size()
|
screensize = pygame.display.get_window_size()
|
||||||
|
default_font = pygame.font.SysFont("sans", 14)
|
||||||
|
|
||||||
|
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
||||||
|
winkel = 0
|
||||||
|
|
||||||
|
print(berechne_dreieck(45,10))
|
||||||
running = True
|
running = True
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
while running:
|
while running:
|
||||||
|
screen.fill((255,255,255))
|
||||||
|
pressed_keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
|
if pressed_keys[pygame.K_ESCAPE]:
|
||||||
|
exit()
|
||||||
|
if pressed_keys[pygame.K_UP]:
|
||||||
|
winkel += 1
|
||||||
|
if pressed_keys[pygame.K_DOWN]:
|
||||||
|
winkel -= 1
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
exit()
|
exit()
|
||||||
a,b = berechne_dreieck(45,100)
|
if event.type == pygame.WINDOWRESIZED:
|
||||||
# draw a
|
screensize = pygame.display.get_window_size()
|
||||||
pygame.draw.line(screen,(255,0,0),(screensize[0]-10,screensize[1]-10),(0,0))
|
start_pos = screensize[0]/2,screensize[1]/2#(10,screensize[1]-10)
|
||||||
|
screen.fill((0,0,0))
|
||||||
|
if winkel >= 360 or winkel <= -1:
|
||||||
|
winkel = 0
|
||||||
|
a,b = berechne_dreieck(winkel,150)
|
||||||
|
|
||||||
# draw b
|
end_pos = start_pos[0]+a,start_pos[1]+b
|
||||||
pygame.draw.line(screen,(255,0,0),(screensize[0]-10,screensize[1]-10),(0,0))
|
# draw c schwarz
|
||||||
|
pygame.draw.line(screen,(0,0,0),start_pos,end_pos)
|
||||||
|
|
||||||
|
# draw a rot
|
||||||
|
pygame.draw.line(screen,(255,0,0),start_pos,(start_pos[0]+a,start_pos[1]))
|
||||||
|
# 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))
|
||||||
|
|
||||||
|
get_debug_text()
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
clock.tick(60)
|
clock.tick(1)
|
||||||
print(berechne_dreieck(45,100))
|
winkel += 1
|
Loading…
Reference in a new issue