OtsoSilver

Untitled

Aug 22nd, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #pgzero
  2.  
  3. WIDTH = 600 # Ширина окна
  4. HEIGHT = 300 # Высота окна
  5.  
  6. TITLE = "Инопланетный раннер" # Заголовок окна игры
  7. FPS = 30 # Количество кадров в секунду
  8.  
  9. # Объекты
  10. alien = Actor('alien', (50, 240))
  11. fon = Actor("fon")
  12. box = Actor('box', (550, 265))
  13. bee = Actor('bee', (850, 175))
  14. go = Actor("GO")
  15. game_over = 0
  16.  
  17. def draw():
  18. fon.draw()
  19. alien.draw()
  20. box.draw()
  21. bee.draw()
  22. screen.draw.text('Текст', pos=(10, 10), color="white", fontsize = 24)
  23. if game_over == 1:
  24. go.draw()
  25. screen.draw.text('Нажмите Enter', pos=(170, 150), color="white", fontsize = 36)
  26.  
  27. def update(dt):
  28. global game_over
  29.  
  30. # Движение пчелы
  31. if bee.x > -20:
  32. bee.x = bee.x - 5
  33. else:
  34. bee.x = WIDTH + 20
  35.  
  36. # Движение коробки
  37. if box.x > -20:
  38. box.x = box.x - 5
  39. box.angle = box.angle + 5
  40. else:
  41. box.x = WIDTH + 20
  42.  
  43. # Управление
  44. if keyboard.left or keyboard.a and alien.x > 20:
  45. alien.x = alien.x - 5
  46. alien.image = 'left'
  47. elif keyboard.right or keyboard.d and alien.x < 580:
  48. alien.x = alien.x + 5
  49. alien.image = 'right'
  50. elif keyboard.down or keyboard.s:
  51. alien.image = 'duck'
  52. alien.y = 250
  53. else:
  54. alien.image = 'alien'
  55. if alien.y > 240:
  56. alien.y = 240
  57.  
  58. if game_over == 1 and keyboard.enter:
  59. game_over = 0
  60. alien.pos = (50, 240)
  61. box.pos =(550, 265)
  62. bee.pos = (850, 175)
  63.  
  64.  
  65. # Столкновение
  66. if alien.colliderect(box) or alien.colliderect(bee):
  67. game_over = 1
  68.  
  69. def on_key_down(key):
  70. # Прыжок
  71. if keyboard.space or keyboard.up or keyboard.w:
  72. alien.y = 100
  73. animate(alien, tween='bounce_end', duration=2, y=240)
  74.  
Advertisement
Add Comment
Please, Sign In to add comment