如何使图像平滑移动到不同位置?

时间:2018-12-24 13:56:25

标签: python pygame

我正在做一个简单的游戏,当按下空格键时,玩家必须移动到下一个位置。这样可行!

现在,我想使玩家从一个位置移动到另一个位置。不知道如何做到这一点,我是Python的新手。我正在使用pygame btw。

在此代码上方,我有很多职位。

while not done:
    # Check gebeurtenissen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE:
                print("Knop: Spatie")

                worp = random.randint(1,5)
                print(worp)
                posities[beurt] += worp

                if posities[beurt] >= 55:
                    posities[beurt] = 55
                else:
                    if beurt == 0:
                        beurt = 1
                    else:
                        beurt = 0
            elif event.key == pygame.K_BACKSPACE:
                print("Knop: Backspace")
                beurt = 0
                posities[beurt] = 0
                beurt = 1
                posities[beurt] = 0
                beurt = 0
                worp = 0


    # Teken de graphics
    screen.fill((200,255,200))
    bordrect = bord.get_rect()
    screen.blit(bord,bordrect)

    speler1_x = vakjes[posities[0]] [0]
    speler1_y = vakjes[posities[0]] [1]
    speler1_kleur = (0,0,255)
    speler1 = pygame.image.load("player1.png")
    screen.blit(speler1,(speler1_x - 30, speler1_y - 30))


    speler2_x = vakjes[posities[1]] [0] + 3
    speler2_y = vakjes[posities[1]] [1] + 3
    speler2_kleur = (0,255,0)
    speler2 = pygame.image.load("player2.png")
    screen.blit(speler2,(speler2_x - 15, speler2_y -25))

0 个答案:

没有答案