We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Apology: I am a beginner, sorry if this has an obvious answer.
I was wondering if there is a way of saving variables during the next loop in 'def draw():'.
def draw(): generate_background() green_rect = randint(1,5) if green_rect == 1: for x, y in get_grid_xy(): green_rect_position = rect(x,y,10,10) green_rect_position else: green_rect_position
What I'm wanting my code to do is generate a green rectangle and keep it at the location its chosen from a predeclared selection of x and y locations stored in 'get_grid_xy()' and to only change to another location if the green_rect value lands on 1. The problem is every time the 'def draw()' loop repeats it deletes the 'green_rect_position' meaning it generates the background and then doesn't generate the green_rect at its old position (if the green_rect doesn't == 1).
Any help would be amazing! Many thanks, Keir