[英]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?
This is the full code for the very bad game example.这是非常糟糕的游戏示例的完整代码。
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()
the screen.clear() isn't working and apple = actor("apple") also isn't working. screen.clear() 不起作用,并且 apple = actor("apple") 也不起作用。 I have no idea why.
我不知道为什么。 Please help me!
请帮我!
try this:尝试这个:
from pgzero.actor import Actor
from pgzero.keyboard import keyboard
not sure if it helps.不确定是否有帮助。
Are you using mu editor or pycharm??您使用的是 mu 编辑器还是 pycharm?
Do you have an apple image in the correct path?你有正确路径中的苹果图像吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.