Advertisement
Guest User

Untitled

a guest
Nov 24th, 2019
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. import sys, pygame
  2. import time
  3. pygame.init()
  4. import random
  5.  
  6. done=False
  7. finish = False
  8. width = 640
  9. height = 480
  10. x = 0
  11. y = 0
  12. z = 0
  13. speed = 8
  14. screen = pygame.display.set_mode((width,height))
  15. font = pygame.font.SysFont(None, 25)
  16. clock = pygame.time.Clock()
  17. white = (255, 255, 255)
  18. black = (0, 0, 0)
  19. light_gray = (107, 107, 107)
  20. gray = (39, 46, 46)
  21. Jet_on = pygame.image.load("jet on.png")
  22. one = pygame.image.load("1.png")
  23. two = pygame.image.load("2.png")
  24. three = pygame.image.load("3.png")
  25. four = pygame.image.load("4.png")
  26. five = pygame.image.load("5.png")
  27. six = pygame.image.load("6.png")
  28. seven = pygame.image.load("7.png")
  29. eight = pygame.image.load("8.png")
  30. nine = pygame.image.load("9.png")
  31. ten = pygame.image.load("10.png")
  32. list = [one,two,three,four,five,six,seven,eight,nine,ten]
  33.  
  34. def XYZ(msg,color):
  35. screen_text = font.render(msg, True, color)
  36. screen.blit(screen_text, [0,0])
  37.  
  38. while not finish:
  39. image = random.choice(list)
  40. print (image)
  41. time.sleep(5)
  42.  
  43.  
  44. while not done:
  45. for event in pygame.event.get():
  46. if event.type==pygame.QUIT:
  47. done=True
  48. keyPressed=pygame.key.get_pressed()
  49. screen.fill(black)
  50. if keyPressed[pygame.K_UP]:
  51. x-=speed
  52. if keyPressed[pygame.K_DOWN]:
  53. x+=speed
  54. if keyPressed[pygame.K_RIGHT]:
  55. y+=speed
  56. if keyPressed[pygame.K_LEFT]:
  57. y-=speed
  58. pygame.draw.polygon(screen, gray, [(0,0),(width/2,height/2),(0, 480), (0,0)])
  59. pygame.draw.polygon(screen, gray, [(640,0),(width/2,height/2),(640, 480), (640,0)])
  60. pygame.draw.polygon(screen, light_gray, [(0,0),(width/2,height/2),(640, 0), (0,0)])
  61. pygame.draw.polygon(screen, light_gray, [(0,480),(width/2,height/2),(640, 480), (0,480)])
  62. Jet_on = pygame.transform.scale(Jet_on, (160, 120))
  63. rect = Jet_on.get_rect()
  64. screen.blit(Jet_on, (y,x))
  65. XYZ("(x,y,z): "+str(x)+", "+str(y)+", "+str(z), white)
  66. if x>402:
  67. x=402
  68. if x<-10:
  69. x=-10
  70. if y<-3:
  71. y=-2
  72. if y>491:
  73. y=491
  74. image = random.choice(list), (y,x))
  75. rect = image.get_rect()
  76. screen.blit(image, (y,x))
  77. pygame.display.update()
  78. clock.tick(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement