Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import random
- #Настройки окна
- WIDTH = 500
- HEIGHT = 500
- FPS = 60
- # Цвета
- YELLOW = (255, 255, 0)
- SKY = (133, 193, 233)
- GREEN = (46, 204, 113)
- WHITE = (255, 255, 255)
- #Инициализация
- pygame.init()
- screen = pygame.display.set_mode((WIDTH,HEIGHT))
- clock = pygame.time.Clock()
- # Настройки персонажа
- bird = pygame.Rect(40, 250, 30, 23)
- birdImg = pygame.image.load('fpbs1.png')
- points = 0
- # Шрифты
- font = pygame.font.SysFont('comic sans ms', 30)
- game_over_font = pygame.font.SysFont('comic sans ms', 50)
- game_over_text = game_over_font.render('GAME OVER', 1, WHITE)
- # Падение
- GRAVITY = 0.3
- y_change = 0
- # Прыжок
- isJump = False
- jumpCount = 10
- GO = False
- running = True
- while running:
- screen.fill(SKY)
- for i in pygame.event.get():
- if i.type == pygame.QUIT:
- running = False
- if i.type == pygame.KEYDOWN:
- if i.key == pygame.K_SPACE:
- isJump = True
- hopCount = 0
- if GO:
- screen.blit(game_over_text, (80,120))
- else:
- if isJump:
- hopCount += 1
- bird.top -= 6
- if hopCount == 5:
- y_change = 0
- isJump = False
- else:
- y_change += GRAVITY
- bird.top += y_change
- if bird.top < 0 or bird.bottom > HEIGHT:
- GO = True
- screen.blit(birdImg, (bird.left, bird.top))
- clock.tick(FPS)
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement