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 the PowerPoint sides 142 to 170 of the apjava1.pptx presentation and the Math.random worksheet helpful. Here are some steps to get you started:
- Start by forking this repository.
- Open the Lightning.pde file. You'll need to add some code
At the top of the program, declare 4
int
variablesstartX
,startY
,endX
andendY
. InitializestartX
to 0,startY
to 150,endX
to 0 andendY
to 150 void setup()
needs to set thestrokeWeight()
andbackground()
of your appletvoid draw()
needs to do two things:
-set thestroke()
color of the lightning bolt to some random value usingMath.random()
-awhile
loop that repeats the following until theendX
is off the screen:- set
endX
tostartX
plus a random integer from 0 to 9 - set
endY
tostartY
plus a random integer from -9 to 9 - draw a
line()
with endpointsstartX
,startY
,endX
,endY
- set
startX
equal toendX
- set
startY
equal toendY
- set
void mousePressed()
needs to setstartX
,startY
,endX
,endY
back to their original values.- 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 - The final step is to submit the URL for your website via the "drop box" for the assignment on School Loop. Don't hesitate to ask for help if your aren't sure how something is suppose to work.
Michelle
Janet
Elton
Clovis
Wilson
Edmund
Gina
Gordon
Sophie
Brandon
Amanda
Kevin
Robert
Jenny
Eric
Darren
Sam
Maxwell
Desmond
Michelle
Vivian
Brandon
Jenna
Otto
Lydia
Victor
Ben
Elias
Steven
Andrea
Nicolas
Kenneth
Schuyler
Nghi
Jonathan
Erica
Aaron
Kendra
Heath
Brandon
Oliva
Emily
Joanna
Kirby
Michael
Jun
Makoi
Emma
Andrew
Nicolas
Kyle
Dean
Nathan
Hannah
Yolanda
Colin
Samantha
Jenny
Preston
Thanawat
Ryan
Kenny
Bryan
Andrew
Felix
Steven
Yev
Andrew
Mike
Jalen
Jessica
Kelly
Raymond
Wilson
Bryce
Garvin
Mi-Ka
Tatiana
Karen
Mikayla
Eric
Katie
Joshua