Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. import pygame
  2. import math
  3. pygame.init()
  4. size = width, height = 201, 201
  5. a = 35 / 360
  6. speed = 0 # скорость вращения
  7. screen = pygame.display.set_mode(size)
  8. # метод clock.tick() возвращает количество миллисекунд, прошедших с момента последнего вызова
  9. clock = pygame.time.Clock()
  10.  
  11.  
  12. def draw(a):
  13. pygame.draw.circle(screen, (255, 255, 255), (100, 100), 10)
  14. pygame.draw.polygon(screen,
  15. (255, 255, 255), [(100, 100),
  16. (100 + 70 * math.cos(a * 3.14), 100 + 70 * math.sin(a * 3.14)),
  17. (100 + 70 * math.cos((a + 1/6) * 3.14), 100 + 70 * math.sin((a + 1/6) * 3.14))])
  18. a += 120/180
  19. pygame.draw.polygon(screen,
  20. (255, 255, 255), [(100, 100),
  21. (100 + 70 * math.cos(a * 3.14), 100 + 70 * math.sin(a * 3.14)),
  22. (100 + 70 * math.cos((a + 1 / 6) * 3.14),
  23. 100 + 70 * math.sin((a + 1 / 6) * 3.14))])
  24.  
  25. a += 120 / 180
  26. pygame.draw.polygon(screen,
  27. (255, 255, 255), [(100, 100),
  28. (100 + 70 * math.cos(a * 3.14), 100 + 70 * math.sin(a * 3.14)),
  29. (100 + 70 * math.cos((a + 1 / 6) * 3.14),
  30. 100 + 70 * math.sin((a + 1 / 6) * 3.14))])
  31.  
  32.  
  33. running = True
  34. while running:
  35. screen.fill((0, 0, 0))
  36. for event in pygame.event.get():
  37. if event.type == pygame.QUIT:
  38. running = False
  39. # реакция на нажатие мыши
  40. if event.type == pygame.MOUSEBUTTONDOWN:
  41. # изменяем скорость в нужную сторону
  42. if event.button == 3:
  43. speed += 2 / 180
  44. elif event.button == 1:
  45. speed -= 2 / 180
  46. draw(a)
  47. a += speed
  48. pygame.display.flip()
  49. clock.tick(50)
  50. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement