用livewires计算运动

时间:2016-04-10 03:16:53

标签: pygame livewires

所以这是我的问题。我有一个图像,我想在屏幕上连续左右移动。我想每次都显示一个计数。香港专业教育学院试图清理我的代码,然后我搞砸了。我可以帮助我添加我需要添加的内容,以便显示每次图像从屏幕一侧移动到另一侧时的计数吗?我添加了代码。 my code

1 个答案:

答案 0 :(得分:0)

class moving_image(games.Sprite):
    def __init__(self):
        self.counter = 0

    def update(self):
        if self.right > games.screen.width or self.left < 0:
            self.dx = -self.dx
            self.counter += 1