Working with loops this week required some creativity. My idea was inspired by Pole Position video game. I drafted up a short animation to understand the loops better. Very few things in Pole Position move, so I knew if I could add some 'moving' striped lines on the side and loop them back and forth I could create that illusion.
I tried a few things before settling on the idea I had,
I thought about creating the stripes by doing a for loop
Issue - Did not allow for me to change the size of each line to create depth(at least from what I know)
Creating a pattern of red squares on one large white rectangle
This was essentially me over complicating the idea so I scraped it.
Finally, I decided to create two shapes, each with alternating stripes design. Shapes Red and Red2.
Once I had the shapes I used a counter to count up nonstop for a continuous loop and the condition for each is if its an even number or not.
If even show shape(red)
Else its odd so show shape(red2)
This was done with the natural looping of draw().
Finally I added in a while loop to move check an integer against the width to be abele to move the car and car details.
Along with the issues above I also had an issue with trying to use a while loop within draw(); For example, if mouseClicked() start moving the lines and car, but it created and infinite loop inside draw() so I never saw the work.
CODE
Rough Draft
Demonstration
Animation made in Procreate Dreams