2 回答

TA贡献1848条经验 获得超2个赞
该方法rect仅接受4个参数,但是您要向其传递6个参数,这就是为什么会出现错误的原因。这里是文档:
pygame.draw.rect()
draw a rectangle shape
rect(Surface, color, Rect, width=0) -> Rect
Draws a rectangular shape on the Surface. The given Rect is the area of the rectangle. The width argument is the thickness to draw the outer edge. If width is zero then the rectangle will be filled.
Keep in mind the Surface.fill() method works just as well for drawing filled rectangles. In fact the Surface.fill() can be hardware accelerated on some platforms with both software and hardware display modes.
你可以看到,只需要Surface,color,Rect和width它有默认值为0。你是做合格6 pygame.draw.rect(window, Color, xpos, ypos, particle_size, particle_size)。您需要传入pygame.Rect(xpos, ypos, particle_size, particle_size)第三个参数,并删除除window和以外的所有其他参数Color。所以它应该看起来像这样:
pygame.draw.rect(window, Color, pygame.Rect(xpos, ypos, particle_size, particle_size)

TA贡献1886条经验 获得超2个赞
如果您查看docs,那么最后一个参数应该是一个Rectangle对象。
在Particle构造函数中,将第一行更改为:
class Particle(object):
def __init__(self, Color, xpos, ypos):
pygame.draw.rect(window, Color, pygame.Rect(xpos, ypos, particle_size, particle_size))
添加回答
举报