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_img = pygame.image.load('fpbs1.png').convert()
- bird_rect = bird_img.get_rect()
- bh = bird_rect.height
- bw = bird_rect.width
- bird = pygame.Rect(40,40, bw, bh)
- 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)
- grav_scale = 0.3
- a_speed = 0
- hop_count = 0
- is_jump = False
- running = True
- GO = False
- 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:
- is_jump = True
- hop_count = 0
- if GO == False:
- if is_jump:
- hop_count += 1
- bird.y -= 6
- if hop_count == 5:
- a_speed = 0
- is_jump = False
- else:
- a_speed += grav_scale
- bird.y += a_speed
- if bird.top <= 0 or bird.bottom >=HEIGHT:
- GO = True
- screen.fill(SKY)
- screen.blit(bird_img, (bird.left, bird.top))
- else:
- screen.blit(game_over_text, (80,120))
- clock.tick(FPS)
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement