为什么我使用pygame会出现溢出错误?

时间:2018-02-21 17:50:52

标签: python pygame overflow

我收到错误:

Traceback (most recent call last):
  File "C:/Users/xxxx/PycharmProjects/Snake/Snake.py", line 138, in <module>
    pygame.gfxdraw.aacircle(playSurface, blue, (pos[0], pos[1]), 10, 10)
OverflowError: signed short integer is greater than maximum

Process finished with exit code 1

这是第138行:

pygame.gfxdraw.aacircle(playSurface, blue, (pos[0], pos[1]), 10, 10)

为什么会这样?

2 个答案:

答案 0 :(得分:0)

在实施时间范围内的改进时,我发生了同样的事情,但是发现回溯不能准确识别问题的根源。经过一番挖掘后,在填充rect.move()之前,在可计算的范围内解决速度时,问题得以解决。

答案 1 :(得分:0)

Pygame的gfxdraw模块的aacircle参数与draw的{​​{1}}参数不同。

The official reference gives:

circle

您要将行改写为

aacircle(surface, x, y, r, color) -> None

请注意,抗锯齿的圆没有宽度,因此最终的pygame.gfxdraw.aacircle(playSurface, (pos[0], pos[1]), 10, blue) 一词丢失了。