Skip to content

An AP Computer Science A programming assignment for Mr. Simon's APCSA course at Lowell High School, San Francisco, USA

Notifications You must be signed in to change notification settings

EmmaB3/Lightning

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightning

One way to simulate lightning is with a random walk. In this assignment you will create a program that uses a random walk to seemingly shoot lightning from one side of the screen to the other every time the mouse is pressed. You may find sides 192 to 202 of the apjavaProcessing slide presentation and the Math.random worksheet helpful. Here are some steps to get you started:

  1. Start by forking this repository.
  2. Open the Lightning.pde file. You'll need to add some code At the top of the program, declare 4 int variables startX, startY, endX and endY. Initialize startX to 0, startY to 150, endX to 0 and endY to 150
  3. void setup() needs to set the strokeWeight() and background() of your applet
  4. void draw() needs to do two things:
    -set the stroke()color of the lightning bolt to some random value using Math.random()
    -a while loop that repeats the following until the endX is off the screen:
    1. set endX to startX plus a random integer from 0 to 9
    2. set endY to startY plus a random integer from -9 to 9
    3. draw a line() with endpoints startX,startY,endX,endY
    4. set startX equal to endX
    5. set startY equal to endY
  5. void mousePressed() needs to set startX,startY,endX,endY back to their original values.
  6. You will need to modify index.html to customize your website with it's own title, headline and footer. When you are happy with your program, push your finished project up to GitHub
  7. The final step is to submit the URL for your website to google classroom. Don't hesitate to ask for help if your aren't sure how something is suppose to work.

Program requirements

Your program needs to create a random walk using Math.random() for all random numbers in the assignment. Other than that, your lightning program doesn't have to work or look like any other. Have fun and be creative!

Samples of Student Work

Lily
James
Gordon
Donald
Emma
Vincent
Jeffrey
Emily
Warren
Prescott
Jing
Oona
Natalie
Rolland
Emil
Chris
Lilith
Wilson
Jeffrey
Sarah
Emily
Andrew
Mandy
Kelly
Albert
Clarisse
Tatyana
Chanel
Scott
Andrew
Athena
Alexander
Mariann
Jonathan
Bryce
Connie
Triston
Chloe
Jasmine
Ben
Justin
Jeffrey
Jack
Kelvin

About

An AP Computer Science A programming assignment for Mr. Simon's APCSA course at Lowell High School, San Francisco, USA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.6%
  • Other 0.4%