我在 python 和 pygame 中有一个小程序,但是当我运行它时,出现以下错误:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "main.py", line 31, in <module>
main()
File "main.py", line 25, in main
board.draw(WIN)
File "/home/ether/Desktop/checkersai/checker/board.py", line 42, in draw
piece.draw(win)
File "/home/ether/Desktop/checkersai/checker/piece.py", line 32, in draw
pygame.draw.circle(win, GREY, (self.x, self.y), radius + self.OUTLINE)
TypeError: integer argument expected, got float
这是错误所在的函数:
def draw(self, win):
radius = SQUARE_SIZE//2 - self.PADDING
pygame.draw.circle(win, GREY, (self.x, self.y), radius + self.OUTLINE)
pygame.draw.circle(win, self.color, (self.x, self.y), radius)
这些是我使用的变量:
WIDTH, HEIGHT = 800,800
ROWS, COLS = 8,8
SQUARE_SIZE = WIDTH/COLS
所以我不知道如何得到这个错误,也不知道我需要从哪里开始寻找错误。
这是我的项目的完整代码 https://pastebin.ubuntu.com/p/DHcRNT6948/
猛跑小猪
相关分类