python中的函数调用(pygame)

python中的函数调用(pygame),python,pygame,Python,Pygame,我试图将我的代码拆分成函数,我想输入我自己的x和y值。因此,字符可以从输入的值移动。当我试图从函数调用中执行此操作时,什么都没有发生 有什么建议吗 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") m

我试图将我的代码拆分成函数,我想输入我自己的x和y值。因此,字符可以从输入的值移动。当我试图从函数调用中执行此操作时,什么都没有发生

有什么建议吗

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()                

在命令
move(x,y)
中有一个无限循环。这个循环外部更新屏幕的东西永远不会到达,所以看起来什么也没有发生。尝试将命令定义之后的所有内容放入命令中的
循环,而将True设置为
循环。

您应该认真研究您的问题标题。调用函数python(pygame)、函数调用python(pygames)和函数调用python(pygame)并没有真正的帮助:-)