[英]I made a very simple Pygame Zero game, but my Actor image and the screen.clear() is not working. Can you help me fix this?
这是非常糟糕的游戏示例的完整代码。
import pgzrun
from random import randint
from pgzero.builtins import Actor, animate, keyboard
apple = Actor('apple')
def draw():
screen.clear()
apple.draw()
def place_apple():
apple.x = randint(10, 800)
apple.y = randint(10, 600)
def on_mouse_down(pos):
if apple.collidepont(pos):
print("Good shot!")
place_apple()
else:
print("You missed!")
quit()
place_apple()
pgzrun.go()
screen.clear() 不起作用,并且 apple = actor("apple") 也不起作用。 我不知道为什么。 请帮我!
尝试这个:
from pgzero.actor import Actor
from pgzero.keyboard import keyboard
不确定是否有帮助。
您使用的是 mu 编辑器还是 pycharm?
你有正确路径中的苹果图像吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.