When I make my arguments named in below code, I get the TypeError. If I make the same arguments without specifying the name the code works fine. Both codes are shown below. Code on the top works fine, the one at the bottom gives "TypeError: Argument must be rect style object". The only thing I added was left=
, top=
, width=
and height=
def draw_cell(self, surface):
if self.type == Cell.BODY:
pygame.draw.rect(surface=surface, color=self.color,
rect=pygame.rect.Rect(1 + self.column * SnakeGame.CELL_SIZE_IN_PIXELS,
1 + self.row * SnakeGame.CELL_SIZE_IN_PIXELS,
SnakeGame.CELL_SIZE_IN_PIXELS - 1,
SnakeGame.CELL_SIZE_IN_PIXELS - 1),
width=0, border_radius=0)
def draw_cell(self, surface):
if self.type == Cell.BODY:
pygame.draw.rect(surface=surface, color=self.color,
rect=pygame.rect.Rect(left=1 + self.column * SnakeGame.CELL_SIZE_IN_PIXELS,
top=1 + self.row * SnakeGame.CELL_SIZE_IN_PIXELS,
width=SnakeGame.CELL_SIZE_IN_PIXELS - 1,
height=SnakeGame.CELL_SIZE_IN_PIXELS - 1),
width=0, border_radius=0)