Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. import pygame
  2.  
  3. pygame.init()
  4.  
  5. window = pygame.display.set_mode((400, 442))
  6. screen = pygame.Surface ((400, 442))
  7. gr = pygame.Surface ((400, 442))
  8. pygame.display.set_caption('pacman')
  9. player = pygame.Surface ((20, 20))
  10. zl = pygame.Surface ((20, 20))
  11. zl1 = pygame.Surface ((20, 20))
  12. zl2 = pygame.Surface ((20, 20))
  13.  
  14. x1 = 300
  15. y1 = 300
  16. p_x = 0
  17. p_y = 0
  18. z_x = 210
  19. z_x1 = 190
  20. z_y = 200
  21. z_y1 = 200
  22. z_x2 = 170
  23. z_y2 = 200
  24.  
  25. game_over = False
  26. Yes = True
  27. gr = pygame.image.load('opasno.jpg')
  28. icon = pygame.image.load('images.jpg')
  29. player.set_colorkey((255, 255, 255))
  30. icon.set_colorkey((255, 255, 255))
  31. zl2.set_colorkey((255, 255, 255))
  32. zl1.set_colorkey((255, 255, 255))
  33. zl.set_colorkey((255, 255, 255))
  34. img = pygame.image.load('fk.gif')
  35. img1 = pygame.image.load('pk.jpg')
  36. pr1 = pygame.image.load('or.png')
  37. pr2 = pygame.image.load('pink.png')
  38. prall = pygame.image.load('blue.png')
  39. pygame.Surface.get_alpha
  40. while not game_over:
  41. for event in pygame.event.get():
  42. if event.type == pygame.QUIT:
  43. game_over = True
  44. pygame.quit()
  45.  
  46. if event.type == pygame.KEYDOWN:
  47. if event.key == pygame.K_LEFT:
  48. p_x = -1
  49. p_y = 0
  50. elif event.key == pygame.K_RIGHT:
  51. p_x = 1
  52. p_y = 0
  53. elif event.key == pygame.K_UP:
  54. p_y = -1
  55. p_x = 0
  56. elif event.key == pygame.K_DOWN:
  57. p_y = 1
  58. p_x = 0
  59. x1 += p_x
  60. y1 += p_y
  61. if x1 == 374:
  62. p_x = 0
  63. if y1 == 420:
  64. p_y = 0
  65. if x1 == -1:
  66. p_x = 0
  67. if y1 == 0:
  68. p_y = 0
  69.  
  70. if x1 > 375:
  71. p_x -= 1
  72. if y1 > 421:
  73. p_y -= 1
  74. if x1 < -2:
  75. p_x += 1
  76. if y1 < -2:
  77. p_y += 1
  78.  
  79. screen.blit(img1, (0, 0))
  80. pygame.display.set_icon(icon)
  81. zl.blit(pr1, (0, 0))
  82. zl1.blit(pr2, (0, 0))
  83. zl2.blit(prall, (0, 0))
  84. player.blit(img, (0, 0))
  85. screen.blit(player, (x1, y1))
  86. screen.blit(zl, (z_x, z_y))
  87. screen.blit(zl1, (z_x1, z_y1))
  88. screen.blit(zl2, (z_x2, z_y2))
  89. window.blit(screen, (0, 0))
  90. pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement