vendredi 17 juillet 2015

Python random colors flickering on object

The following function defines rectangles, their x/y location, width and height, and color. I would like the color to be randomly chosen every time.

def things(thingx, thingy, thingw, thingh, color):
    rand_color = (random.randrange(0,255),random.randrange(0,255),random.randrange(0,255))
    pygame.draw.rect(gameDisplay, rand_color, [thingx, thingy, thingw, thingh])

The current code is causing the program to flicker through every different color. Even if I change the rand_color to a variation of choosing between black and white, the rectangle flickers between black and white. What's happening here?




Aucun commentaire:

Enregistrer un commentaire