Hi github community! I would like to ask your helpfor solving this problem of mine. I need to develop a game using only functions (NO CLASSES). I already manage to run the game but the animations or sprites do not update as they should. What am I doing wrong? 

Here’s the code:

import pygame  
WIDTH =800   
pygame.display.set_caption("Nico's worst adventure")  
window = pygame.display.set_mode((WIDTH, HEIGHT))  
#Color #R #G #B  
White = (255, 255, 255)
Black = (0, 0, 0)
Red = (255, 0, 0)
Blue = (0, 0, 255)

x =50  
y =425  
imageWidth =64  
vel =5 #Velocity of movement  
isJumping =False   
jumpCount =10   
left =False   
right =False   
walkCount =0   
#Image port  
walkRight = [pygame.image.load('Nico right(1).png'), pygame.image.load('Nico right(2).png'), pygame.image.load('Nico right(3).png'), pygame.image.load('Nico right(4).png')]
walkLeft = [pygame.image.load('Nico left(1).png'), pygame.image.load('Nico left(2).png'), pygame.image.load('Nico left(3).png'), pygame.image.load('Nico left(4).png')]
still = pygame.image.load('Nico still.png')
backgorund = pygame.image.load('Fondo.png')

def drawCharacter():
global walkCount  
window.blit(backgorund, (0,0))  
if walkCount +1 >=12:  
walkCount =0   
if left:
window.blit(walkLeft[walkCount//3], (x, y))
walkCount +=1  
elif right:
window.blit(walkRight[walkCount//3], (x, y))
walkCount +=1  
window.blit(still, (x, y))


def draw():
global imageWidth
global WIDTH
global x  
global y  
global vel  
global jumpCount  
global isJumping  
clock = pygame.time.Clock()  
play =True   
 #Main loop  
while play:  
for eventin pygame.event.get():  
if event.type == pygame.QUIT:  
play =False   
key = pygame.key.get_pressed()  
if key[pygame.K_LEFT]and x > vel:  
x -= vel
left =True  
right =False  
 elif key[pygame.K_RIGHT]and x < WIDTH - imageWidth - vel:  
x += vel
right =True  
left =False  
right =False  
left =False  
walkCount =0   
if not(isJumping):  
if key[pygame.K_SPACE]:
isJumping =True  
right =False  
left =False  
walkCount =0  
if jumpCount >= -10:  
neg =1   
if jumpCount <0:
neg = -1  
y -= (jumpCount **2) *0.5 * neg  
jumpCount -=1  
isJumping =False  
jumpCount =10  



I can try to solve your problem, but i need the resources, the images for example. Can you link the repository of this project?

If as you say the “sprites do not update” then it means two possibilities.

  1. Your sprite updates are not working as desired. E.g. something is wrong with your walkcount or sprite lookup logic so things don’t change. You can verify this with the debugger or forcing a walkcount loop.

  2. The changes you are making are not getting pushed to the screen. You’ll need to verify that you are updating the screen correctly.