OtsoSilver

Untitled

Aug 22nd, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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. screen.draw.text('Нажмите Enter', pos = (300, 500), color = 'white', fontsize = 24, fontname = 'comic sans')
  25.  
  26. def update(dt):
  27. global game_over
  28. # Движение коробки
  29. if box.x > -20:
  30. box.x = box.x - 5
  31. box.angle = box.angle + 5
  32. else:
  33. box.x = WIDTH + 20
  34.  
  35. if bee.x > -20:
  36. bee.x = bee.x - 5
  37. else:
  38. bee.x = WIDTH + 20
  39.  
  40.  
  41. if keyboard.enter and game_over == 1:
  42. game_over = 0
  43. alien.pos = (50, 240)
  44. box.pos = (550, 265)
  45. bee.pos = (850, 175)
  46. # Управление
  47. if keyboard.left or keyboard.a and alien.x > 20:
  48. alien.x = alien.x - 5
  49. # alien.image = 'left'
  50. elif keyboard.right or keyboard.d and alien.x < 580:
  51. alien.x = alien.x + 5
  52. # alien.image = 'right'
  53. elif keyboard.down or keyboard.s:
  54. # alien.image = 'duck'
  55. alien.y = 250
  56. else:
  57. # alien.image = 'alien'
  58. if alien.y > 240:
  59. alien.y = 240
  60.  
  61. if alien.colliderect(box) or alien.colliderect(bee):
  62. game_over = 1
  63. # alien.image = 'hurt'
  64.  
  65. def on_key_down(key):
  66. # Прыжок
  67. if keyboard.space or keyboard.up or keyboard.w:
  68. alien.y = 100
  69. animate(alien, tween='bounce_end', duration=2, y=240)
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment