I wanted to draw a night scene with several 100 randomly drawn stars (points). I can create the loop that draws the stars, but when I animated a drawing (a car), the process of everything in the draw loop repeating itself constantly redraws the randomly located stars when I want them to stay in the same place. If I draw them outside the draw loop, the background hides them when it runs inside the draw loop.
I have created a partial work around by drawing a blue rectangle where my car passes on the screen, but that still doesn’t work well and I know it’s not the right solution. The only real solution I can think of is somehow creating a .jpg or .png with the stars already on it, but that’s not the solution I want either.
Thanks for looking at it … I had hoped to draw the stars once and then leave them in their originally drawn position … that’s where the problem is because when it draws the background again, I have to draw the stars again and it draws them in a different random position so it looks more like a snowstorm … maybe I need an array that stores the original position of the stars, but I haven’t learned how to do that yet in GameLab if it’s possible. I’ll keep working on it.
I left the random stroke width in the draw loop for the array example to give the stars a twinkle, but you could place those values in an array as well.