mercredi 23 décembre 2015

Randrange dependant on variable - Python

Im trying to make random co-ords for a object spawning onto a canvas(The canvas is the size of the users screen so the range is ever changing.)

random.randint(12.5, int(resX-12.5))

This is the line of code resX being the variable that stores the size of the users screen resolution, 12.5 being the radius of the shape being spawned.

The error i'm getting is that the resX part isn't an integer ValueError: non-integer arg 1 for randrange()

Im not sure if theres a way to use a variable within the random line?




Aucun commentaire:

Enregistrer un commentaire