0

So I'm making a BlackJack Game as part of a school project using PyGame. I want to add the animation of the card "coming out of the deck". I've looked around and haven't been able to find anything that works for me.

My problem is that the card image is displayed every time that it's moved, not one image moving to the new set of coordinates. What it does is display say 10 of the same image when I only want the one image to move on its own. What's the best way to get an image to move from a starting point to a finishing point and not have it displayed at every new set of coordinates?

Here's the code I'm using if you're interested:

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)
Rob
  • 1
  • This is an old question but can you attach a screenshot of what you mean? – Octo Jan 30 '17 at 11:49
  • @Octo [link](https://gyazo.com/44229a7c91b04ff180e42a6308536c6d) hopefully that helps – Rob Jan 30 '17 at 14:39
  • 1
    You need to override the image before you move it. Every time you blit something on the screen it will stay there until overridden by another image, which is why you see 10 images. What you want is to blit the background over the image (thus "deleting" it) before you blit the next one. – Ted Klein Bergman Jan 30 '17 at 15:37
  • as @TedKleinBergman said - you have to clear screen and draw everything again. Or you could redraw only this part where you move card. – furas Jan 30 '17 at 17:58

0 Answers0