function calls in python (pygame)
Question: im trying to split my code into functions and i want to input my own values
for x and y. so the character can move from the inputed values. When i try to
do this from the function call, nothing happens.

Any suggestions?

    
    
    import pygame, sys
    from pygame.locals import *
    
    pygame.init()
    
    width,height=(842,595)
    screen = pygame.display.set_mode((width,height),0,32)
    pygame.display.set_caption("game")
    man = pygame.image.load("man.png")
    target = pygame.image.load("star.png")
    
    #setting a background image
    bgimage= pygame.image.load("background.jpg")
    ##image for the jupiter object
    another_target = pygame.image.load("jupiter.gif")
    
    
    x = 100
    y = height-300
    
    another_targetx = 400
    another_targety = 500
    
    #allows movement whilst holding down key.
    
    clock= pygame.time.Clock()
    
    def move(x,y):
        movingX =0
        movingY =0
    
        speedX =0
        speedY=0
        while True:
            pygame.display.update()  
            for event in pygame.event.get():
                if event.type==QUIT:
                    pygame.quit()
                    sys.exit()
                elif event.type==KEYDOWN:
                    if event.key ==K_LEFT:
                        x-=5
                    elif event.key==K_RIGHT:
                        x+=5
                    elif event.key==K_UP:
                        y-=5
                    elif event.key==K_DOWN:
                        y+=5
    
            time_Passed=clock.tick(25)
            time_elapsed_seconds=time_Passed/1000.0
    
            distanceX = time_elapsed_seconds*speedX
            movingX+=distanceX
    
            distanceY=time_elapsed_seconds*speedY
            movingY+=distanceY
    
            x+=movingX
            y+=movingY
            clock.tick(50)
        pygame.display.update()  
    
    move(x,y) 
    screen.blit(bgimage,(0,0))
    screen.blit(man, (x,y))
    screen.blit( another_target,( another_targetx, another_targety))
    screen.blit(target,(200,400))
    pygame.display.update()                
    


Answer: You have an infinite loop within the command `move(x, y)`. The stuff on the
outside of this loop which updates the screen is never reached, so nothing
ever appears to happen. Try putting everything after the command definition
into the `while True` loop inside the command.

