0

Can anyone explain why this doesn´t work? Is there a way to make this work or is it just not possible to give the pygame rect function a pre-defined variable with the required arguments?

import pygame

pygame.init()

win = pygame.display.set_mode((1200, 600))
blue = (0, 0, 255)

x = (win, blue, (0, 510, 1200, 190))

pygame.draw.rect(x)

Every time I try the code, it says that the rect function needs at least 3 arguments.

Rabbid76
  • 177,135
  • 25
  • 101
  • 146
nKLN
  • 3
  • 1

1 Answers1

0

In order to call rect with three arguments coming from x, as opposed to one argument which happens to be made up of 3 things, you can do:

pygame.rect( *x )
Scott Hunter
  • 46,905
  • 10
  • 55
  • 92