OtsoSilver

Untitled

Aug 22nd, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #pgzero
  2.  
  3. WIDTH = 600 # Ширина окна
  4. HEIGHT = 300 # Высота окна
  5.  
  6. TITLE = "Инопланетный раннер" # Заголовок окна игры
  7. FPS = 30 # Количество кадров в секунду
  8. game_over = 0
  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.  
  16. def draw():
  17. if game_over == 0:
  18. fon.draw()
  19. alien.draw()
  20. box.draw()
  21. bee.draw()
  22. else:
  23. go.draw()
  24.  
  25. def update(dt):
  26. global game_over
  27. # Движение коробки
  28. if box.x > -20:
  29. box.x = box.x - 5
  30. box.angle = box.angle + 5
  31. else:
  32. box.x = WIDTH + 20
  33.  
  34. if bee.x > -20:
  35. bee.x = bee.x - 5
  36. else:
  37. bee.x = WIDTH + 20
  38.  
  39. # Управление
  40. if keyboard.left or keyboard.a and alien.x > 20:
  41. alien.x = alien.x - 5
  42. # alien.image = 'left'
  43. elif keyboard.right or keyboard.d and alien.x < 580:
  44. alien.x = alien.x + 5
  45. # alien.image = 'right'
  46. elif keyboard.down or keyboard.s:
  47. # alien.image = 'duck'
  48. alien.y = 250
  49. else:
  50. # alien.image = 'alien'
  51. if alien.y > 240:
  52. alien.y = 240
  53.  
  54. if alien.colliderect(box) or alien.colliderect(bee):
  55. game_over = 1
  56. alien.image = 'hurt'
  57.  
  58. def on_key_down(key):
  59. # Прыжок
  60. if keyboard.space or keyboard.up or keyboard.w:
  61. alien.y = 100
  62. animate(alien, tween='bounce_end', duration=2, y=240)
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment