我在 python 和 pygame 中有一個小程序,但是當(dāng)我運行它時,出現(xiàn)以下錯誤:pygame 1.9.6Hello from the pygame community. https://www.pygame.org/contribute.htmlTraceback (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這是錯誤所在的函數(shù):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,800ROWS, COLS = 8,8SQUARE_SIZE = WIDTH/COLS所以我不知道如何得到這個錯誤,也不知道我需要從哪里開始尋找錯誤。這是我的項目的完整代碼 https://pastebin.ubuntu.com/p/DHcRNT6948/
python/pygame 中的類型錯誤 - 浮點數(shù)而不是整數(shù)
呼啦一陣風(fēng)
2023-09-19 17:02:54