PyGame中的图像移动

时间:2017-01-30 09:48:05

标签: python pygame

所以我使用PyGame将BlackJack游戏作为学校项目的一部分。我想添加卡片的动画"从甲板上出来"。我环顾四周,找不到任何适合我的东西。

我的问题是卡片图像每次移动时都会显示,而不是一张图像移动到新的坐标系列。它的作用是当我只希望一个图像自己移动时,显示相同图像的10个。什么是让图像从起点移动到终点而不是在每一组新坐标上显示的最佳方式?

以下是我感兴趣的代码:

def userCalculationsDisplay(gamestate):
    for i in range(0,len(gamestate.UsersCardsList)):
        image = pygame.image.load(gamestate.PlayingCards[gamestate.UsersCardsList[i]])
        image = pygame.transform.scale(x2, (100, 150))
        printTest(gamestate)
        gamestate.MovingImageXCoordinate = (550)
        gamestate.MovingImageYCoordinate = (300)
        gamestate.x_change = 0
        gamestate.y_change = 0
        listOfCoordinatesToMoveCard = []
        for j in range(0, 10):
                gamestate.x_change = -10
                gamestate.y_change = 10
                gamestate.MovingImageXCoordinate += gamestate.x_change
                gamestate.MovingImageYCoordinate += gamestate.y_change
                windowSize.blit(image, (gamestate.MovingImageXCoordinate, gamestate.MovingImageYCoordinate))
                pygame.display.flip()
    printTest(gamestate)
    gamestate.userTotal = calculations(gamestate)
    if gamestate.userTotal > 21:
        drawFunction(48, "BUST!", colours.Black, 130, 360)
        gamestate.isPlayerFinished=True
        gamestate.isPlayerBust=True
        gamestate.standButtonAvailable=False
        gamestate.isGameFinished=True
    else:
        pass

    drawFunction(28, "Your card total is " + str(gamestate.userTotal), colours.Black, 130, 480)

0 个答案:

没有答案