我想在屏幕上显示一个圆圈和一个矩形。矩形似乎有效,但圆圈没有。当我运行此代码时,错误是相同的:
TypeError: must be 2-item sequence, not float
代码:
#Game.py
survivor.draw(screen)
Zombie.draw_zombies(screen)
所以这循环回到:
class Zombie(Character):
List = []
def __init__(self, x, y):
Character.__init__(self, x, y)
Zombie.List.append(self)
@staticmethod
def draw_zombies(screen):
for zombie in Zombie.List:
pygame.draw.rect(screen, [210, 24, 77], zombie)
class Survivor(Character):
def __init__(self, x, y):
Character.__init__(self, x, y)
def draw(self, screen):
r = self.width / 2
pygame.draw.circle(screen, [77, 234, 156], (self.x + r), (self.y + r), r)
所以当我运行这个时,我总是得到同样的东西:
TypeError: must be 2-item sequence, not float
我有所有的进口和一切,建议?
答案 0 :(得分:0)
这是我认为你需要的公式:
pygame.draw.circle(screen, (77, 234, 156), (int(self.x + r),int(self.y + r)), int(r))
如果您仍然遇到问题,请将“+”操作到本地var中,然后将int变为<。