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)