Due: Friday 09/20 10:00am

Submission name: w07_lightning

For this assignment, you may want to refer to:

lightning

Make a lightning function

Write drawLightning:

  • Use the following function header: void drawLightning(int x, int y, int numParts)
  • The function should draw numParts connected lines starting at (x, y).
  • Each line should start at the previous (x, y) coordinates and end at random coordinates with the following restrictions:
    • The next x coordinate should be an int in the range [x - 5, x + 5).
    • The next y coordinate should add a random int in the range [y + 5, y + 20).
  • Use a while loop to draw the appropriate number of lines. Do not worry if your lightning bolt goes past the bottom of the screen or doesn’t make it all the way.

Write a setup function

setup should:

  • Set the screen size to 500x500.
  • Run drawLightning at least 5 times.

Optional modifications

  • Play around with stroke and strokeWeight to make better looking lightning bolts.
  • Use random in conjunction with stroke and stokeWeight
  • Add other features to make the image more interesting.
  • If you create an interesting lightning image, save it (as a png or jpeg), and share it on piazza, use the tag nextjourney.