繁体   English   中英

我做了一个非常简单的 Pygame 零游戏,但是我的 Actor 图像和 screen.clear() 不起作用。 你能帮我解决这个问题吗?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM