问题
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