Reputation: 3
Whenever I run this code, it stops right before the screen.blit
while still looping, printing the 'debug3'
over and over.
It doesn't even recognize that the screen is not defined, and my intention is for it to run the screen.blit
.
...
playermove = 5
walkL=pygame.image.load("files/sprites/walkL.png")
walkR=pygame.image.load("files/sprites/walkR.png")
currentSprite = walkL
#single sprite size (width, height)
h=128
w=57
numImages = 4
#counter
cImage=0
class Player:
def animation(self):
global cImage,numImages,currentSprite,playerRect,w,h
if (cImage>=numImages-1):
cImage=0
else:
cImage+=1
print('debug3')
screen.blit(currentSprite,playerRect, (cImage*w,0,w,h))
while True:
player.animation()
Upvotes: 0
Views: 73
Reputation: 36
If you look at your else statement, you need to indent the 'print' call to line up with 'cImage += 1'.
----snippet from code example----
if (cImage>=numImages-1):
cImage=0
else:
cImage+=1
print('debug3')
------- end code snippet---------------
Upvotes: 2