Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pgzero
- import random
- WIDTH = 400 # Ширина окна
- HEIGHT = 400 # Высота окна
- TITLE = "Летающая тарелка" # Заголовок окна игры
- FPS = 30 # Количество кадров в секунду
- # Объекты
- tarelka= Actor('tarelka', (50, 385))
- background= Actor("background")
- top = Actor('top', (200, 50))
- bottom = Actor("bottom", (450, 350))
- game_over = 0
- count = 0
- x=random.randint(1,2)
- def draw():
- background.draw()
- tarelka.draw()
- if x ==1:
- top.draw()
- else:
- bottom.draw()
- screen.draw.text(count, pos=(10, 10), color="white", fontsize = 24)
- if game_over == 1:
- # game_over.draw()
- screen.draw.text('Нажмите Enter', pos=(170, 150), color="white", fontsize = 36)
- #функции
- def topa():
- global count
- # Движение стен
- if top.x > -20:
- top.x = top.x - 5
- else:
- top.x = WIDTH + 20
- count = count + 1
- #функция коробки
- def bot():
- global count
- # Движение коробки
- if bottom.x > -20:
- bottom.x = bottom.x - 5
- bottom.angle = bottom.angle + 5
- else:
- bottom.x = WIDTH + 20
- count = count + 1
- def update(dt):
- global game_over
- global count
- if x==1:
- topa()
- else:
- bot()
- def on_key_down(key):
- # Прыжок
- global game_over
- if keyboard.space or keyboard.up or keyboard.w:
- tarelka.y -= 50
- animate(tarelka, tween='bounce_end', duration=2, y=382)
- if game_over == 1 and keyboard.enter:
- game_over = 0
- count = 0
- tarelka.pos = (50, 385)
- top.pos =(200, 50)
- bottom.pos = (450, 350)
- # Столкновение
- if tarelka.colliderect(top) or tarelka.colliderect(bottom):
- game_over = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement