https://pastein.ru/t/eV

  скопируйте уникальную ссылку для отправки

Загрузка данных


import pygame, random
pygame.init()
win = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Top game")


pygame.mixer.music.load('bkgmsc.mp3')
pygame.mixer.music.play()






walkLeft = [pygame.image.load('left_1.gif'), pygame.image.load('left_2.gif'), pygame.image.load('left_3.gif'), pygame.image.load('left_4.gif'), pygame.image.load('left_5.gif'), pygame.image.load('left_6.gif')]


walkRight = [pygame.image.load('right_1.gif'), pygame.image.load('right_2.gif'), pygame.image.load('right_3.gif'), pygame.image.load('right_4.gif'), pygame.image.load('right_5.gif'), pygame.image.load('right_6.gif')]

background_image = pygame.image.load('bg.jpg')
hero = pygame.image.load('static.gif')
coins = pygame.image.load('coin.gif')

clock = pygame.time.Clock()

list = []
width = 100
height = 100
t = 1000000
size = 100
file = ['block.gif', 'coin.gif']
gravity = 0.001


x = 720
y = 500
width = 40
height = 60
speed = 20
left = False
right = False
animation = 0
count = 0
clock = pygame.time.Clock()
myfont = pygame.font.SysFont('arial', 24)

def c(file):
    list.append([pygame.image.load(file[random.randint(0,1)]), random.randint(width),0-size],5)

def drawWindow():
    global animation
    win.blit(background_image, (0, 0))

    if animation + 1 >= 30:
        animation = 0

    if left:
        win.blit(walkLeft[animation // 5], (x, y))
        animation += 1
    elif right:
        win.blit(walkRight[animation // 5], (x, y))
        animation += 1
    else:
        win.blit(hero, (x, y))

    win.blit(coins, (500,540))
    win.blit(string, (700, 560))
    win.blit(hero, [x, y])

run = True
while run:
    pygame.event.get()
    clock.tick(30)
    for i in range(0, len(list)):
        list[i][2] += list[i][3]
        list[i][3] += gravity

if list[i][2] > height:
    list.pop(i)

    for i in range(0, len(list)):
        win.blit(list[i][0], (list[i][1], list[i][2]))

    if t != 0:
        t -= 1

    else:
        t = 1000000
        c(file)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run - False
    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT] and x > 5:
        x -= speed
        left = True
        right = False
    elif keys[pygame.K_RIGHT] and x < 770 - width - speed:
        x += speed
        left = False
        right = True
    else:
        left = False
        right = False
        animation = 0

    string = myfont.render('Score: ' + str(count), 0, (0, 0, 128))
    drawWindow()

pygame.display.flip
pygame.quit()