Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. import pygame
  2. import time
  3. win = True
  4.  
  5. YELLOW = (255, 255, 224)
  6. BLACK = (0, 0, 0)
  7. pygame.init()
  8. # create screen
  9. screen_width = 1920
  10. screen_height = 1080
  11. screen = pygame.display.set_mode([screen_width, screen_height])
  12. pygame.display.set_caption('Course Work :)')
  13. clock = pygame.time.Clock()
  14. knots = int(140)
  15. rotate = int()
  16. previousspeed = int(1)
  17.  
  18. pitch = int(60)
  19. class Plane(pygame.sprite.Sprite):
  20. def __init__(self):
  21. pygame.sprite.Sprite.__init__(self)
  22. self.rect = pygame.Rect(0, 0, 0, 0)
  23.  
  24. self.image = pygame.image.load("D:\Display.PNG")
  25.  
  26. class pointer(pygame.sprite.Sprite):
  27. def __init__(self,x,y,width,height):
  28. pygame.sprite.Sprite.__init__(self)
  29. self.rect = pygame.Rect(width, height, x, y)
  30.  
  31. self.image = pygame.image.load("D:\\Needle.PNG")
  32.  
  33.  
  34.  
  35.  
  36.  
  37. class needle(pygame.sprite.Sprite):
  38. def __init__(self, color, width, height):
  39. pygame.sprite.Sprite.__init__(self)
  40. self.image = pygame.Surface([width, height])
  41. pygame.draw.rect(self.image, color, [0, 0, width, height])
  42. self.rect = self.image.get_rect()
  43. self.original = self.image
  44.  
  45.  
  46.  
  47.  
  48. all_sprites_list = pygame.sprite.Group()
  49.  
  50.  
  51.  
  52. plane = Plane()
  53. speed = pointer(1,1,-54,113)
  54. all_sprites_list.add(plane)
  55. all_sprites_list.add(speed)
  56.  
  57.  
  58. attitude = needle(YELLOW, 80, 4)
  59. attitude.rect.y = 227
  60. attitude.rect.x = 168
  61. all_sprites_list.add(attitude)
  62.  
  63.  
  64.  
  65. rotcomplete = bool(False)
  66. while win == True:
  67.  
  68.  
  69. if rotate == previousspeed:
  70. pass
  71. else:
  72. speed.image = pygame.transform.rotate(speed.image, -rotate)
  73. rotate = 360 - ( knots * 1.8)
  74. speed.image = pygame.transform.rotate(speed.image, rotate)
  75. previousspeed = rotate
  76.  
  77. clock.tick(100)
  78. all_sprites_list.draw(screen)
  79. all_sprites_list.update()
  80. pygame.display.update()
  81.  
  82.  
  83.  
  84. time.sleep(1)
  85. for event in pygame.event.get():
  86. if event.type == pygame.QUIT:
  87. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement