[英]I'm trying to create my version of pacman with pygame. How can I replace the white moving square with my image of the main character?
[英]How can i stop my square from moving in pygame?
我喜欢你解决这个问题的方法,但我觉得有更好的方法。 您可以设置一个等于蛇移动方向的变量,例如direction = "right"
。 然后,每一帧,您都可以移动当前设置的方向并检查新的用户输入,如下所示:
# Move your snake - You know how to do this, right?
for event in pygame.event.get():
if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
direction = "right"
# Continue for all four directions
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.