[英]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.