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
  • 202,892
  • 27
  • 131
  • 174
nKLN
  • 5
  • 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
  • 48,888
  • 12
  • 60
  • 101