#-*-coding: utf8-*-
import pygame
import random
pygame.init()
y=0
a=-15

# ----------------------------
# задаем начальное положение колонн
pipe_x = 400
pipe_y = random.randint(-200, 0)
# ----------------------------

size = [800, 600]
screen = pygame.display.set_mode(size)

image = pygame.image.load('flappy.png').convert_alpha()

# ----------------------------
# добавляем рисунок колонны
pipe = pygame.image.load('pipe.png').convert_alpha()
# добавляем перевернутый рисунок колонны
pipe_rot = pygame.transform.rotate(pipe, 180)
# ----------------------------

clock = pygame.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_UP:
            a=-15
    a=a+1
    y=y+a

    # ----------------------------
    # двигаем колонны
    pipe_x -= 2
    # ----------------------------

    # ----------------------------
    # зацикливаем колонны
    if pipe_x < -300:
         pipe_x = 800
    # дополнительное задание: сделать так чтобы колонны 
    # каждый раз появлялись на новой высоте
    # ----------------------------

    screen.fill((200, 100, 0))
    screen.blit(image, (120, y))

    # ----------------------------
    # рисуем колонны, нижняя всегда ровно на 500 ниже чем верхняя
    screen.blit(pipe, (pipe_x, pipe_y + 500))
    screen.blit(pipe_rot, (pipe_x, pipe_y))
    # ----------------------------

    pygame.display.flip()
    clock.tick(30)
pygame.quit()

results matching ""

    No results matching ""