Pygame Wont Let Me Draw A Circle Error argument 3 must be sequence of length 2, not 4

你离开我真会死。 提交于 2021-02-04 07:29:05

问题


I am trying to draw a circle with pygame but I keep getting this error

error  argument 3 must be sequence of length 2, not 4
class circle:
    def __init__(self,x,y,height,width,color):
        self.x =x
        self.y = y
        self.height = height
        self.width  = width
        self.color = color
        self.rect = pygame.Rect(x,y,height,width)
    def draw(self):
        self.rect.topleft = (self.x,self.y)
        pygame.draw.circle(window,self.color,self.rect,20)
circle1 = circle(300,200,20,20,white)

回答1:


The 3rd argument of pygame.draw.circle is the center point of the circle, rather than a rectangle:

pygame.draw.circle(window,self.color,self.rect,20)

pygame.draw.circle(window, self.color, self.rect.center, 20)



回答2:


For pygame circles, you need pygame.Rect(radius,height,width).

The x and y are for rectangles.



来源:https://stackoverflow.com/questions/62601880/pygame-wont-let-me-draw-a-circle-error-argument-3-must-be-sequence-of-length-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!