贪吃蛇游戏不工作我的算法有问题吗?

问题描述

    def move(self,increased):

        
        for x in range(len(self.list),-1,-1):

            if x == 0:
 
                if self.direction == "up":
                    self.list[0].y-=20
                elif self.direction == "down":
                    self.list[0].y+=20
                elif self.direction == "left":
                    self.list[0].x -=20
                elif self.direction == "right":
                    self.list[0].x +=20       
                break
            if x == len(self.list) and increased:
                print("hi")
                break
            else:
                self.list[x-1].x,self.list[x-1].y = self.list[x-2].x,self.list[x-2].y


这是我的代码,我的蛇看起来像

like this

。当我只添加 2 个块时它工作正常,但我无法弄清楚我做错了什么,请告诉我我是如何成为一个白痴

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)