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 27 to 58 of the MathDotRandom slide presentation helpful.
- Sign up for a free GitHub account
- Then fork this repository
- Open the Lightning.pde file. Copy and paste the code into Processing.
- At the top of the program in Processing, declare 4
int
variablesstartX
,startY
,endX
andendY
. InitializestartX
to 0,startY
to 150,endX
to 0 andendY
to 150 void setup()
needs to set thesize()
,strokeWeight()
andbackground()
of your programvoid 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.- When you are happy with the program, copy and paste it back into GitHub
- You will also 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 to google classroom. You can find more specific instructions with pictures on how to submit your assignment on slides 50 to 52 of the apjavaProcessing slide presentation. Don't hesitate to ask for help if your aren't sure how something is suppose to work.
The steps above are only a suggestion. Your program needs to use 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!
If your program works in Processing but not on GitHub, check this list for possible solutions. If your program still isn't working on GitHub let your instructor know.
Eric
Alex
Tiffany
Kaitlin
Tiffany
Albert
Gabriella
Viva
Jonah
Michelle
Curtis
Allison
Sam
Tyler
Keneth
Alex
Johnny
Kenny
Patrick
Isabela
William
Rachel
Emilio
Megan
Guidong
Eustache
Cassidy
Andrea
Marvin
Winson
Kathy
Owen
Weifeng
Maya
Gohnshein
Winson
Annie
Harry
Ethan
Aiden
Duan
Taylor
Justin
Justine
Jasmine
Kai
Cara
Marlon
Rishi
Johnny
Alexander
Kang
Joaquin
Luna
Edison
Kimia
Connie
Richard
Kazu
George
Annika
Qi
Verena
Yanzhu
Claire
Melanie
Tommy
Ayaka
Phuoc
Madeline
Rafael
Jaqueline
Rameses
Ian
Anna
Allister
Noah
Xinjian
Lucas
Kendrick
Kenneth
Andrew
Kasra
Marvin
Cheryl
Andrew
Austin
Daniel
Ciaran
Lance
Angel
Maanav
Philip
Andy
Jayde
Albert
Jennifer
Diego
Brandon
Jalen
Andy
Jason
Ian
Jocelyn
Eloy
Alexis
Anson
Chris
Annie
Susan
Wen
Frida
Mia
Damien
Jessie
Cindy
Vicky
Eric
Esme
Caitlin
Angel
Henry
Alex
Henry
Jun
Michael
Marvin
David
Jessie
Norton
Iryne
Esther
Branson
Omar
Celina
Anthony
Akira
Dalton
Emma
Yaoquan
Mari
Lily
Sean
Freesia
Alexander
Cappillen
Joshua
Megan
Brendan
Amy
Jae
Angelica
Jackson
Andy
Audrey
Rowan
Ian
Henry
Dylan
Michael
Jennifer
Celena
Gordon
Richard
Nathan
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
Karina
Bruno
Damian
Paolo
William
Alvin
Christina
Haden
Joanne
Irisa
Christopher
Kumiko
Wing
Caitlyn
Breanna
Matthew
Van
Joshua
Edward
Aiden
Andrew
Jeffrey
Eric
Dylan
Mira
Austin
Jason
Ivana
Gary
Emily
William
Stephen
Daniel
Andrew
Luke
Hayden
Jacob
Noella
Caleb
Gabriel
Joyce
Vivian
Lexian
Raina
Rafael
Nicolas
Brian
Stella
Wendy
Joseph
Joshua
Brianna
Justin
Antonio
Caden
David
Darren
Emily
Brennan
Jennifer
Deion
Aaron
Jackie
Christina
Joselino
Nathan
Munkhtushie
Kyle
Noelle
Andy
Audrey
William
Jenna
Ryan
Nathan
Ivy
Gabriel
Pyry
Mika
Sophia
Ethan
Emely
Nate
Koen
Annie
Brayden
Jason
Tobias
Willa
James
Kathleen
Juan
Toby
Ryan
Ryan
Evangeline
Miriam
Ethan
Loren
Sally
Tennyson
Allynaraizel
Alvin
Sonia
AndreiRock
Maxwell
Humphrey
Hannah
Piero
Fiona
Isaac
Karla
Saw
Aiden
Theo
Tara
Maya
Dylan
Nicholas
Samson
Patrick
Diego
Luca
Cuiyin
Laura
Noel
YiYuan
Artiom
Marina
Kevin
Samantha
Charlotte
Joanna
Andy
Victor
Ivan
Kaijun
Michelle
Kyle
Douglas
Daniel
Jerry
Rock
Gage
Angela
Diego
Sandy
KaloonRidge
Robin
Kayla
Justin
Leanna
Philix
Audrey
Emily
Haoheng
Gabriel
Alejandro
Angela
Kelvin
Lily
Aaron
Terrance
Jessica
Grace
Daniil
Matthew
Leanna
Andre
Felicia
Andrew
Calvin
Aaron
Justin
Kyla
Calvin
Alessandra
James
Yuxi
Aaron
Hao
Katie
Benjamin
Matthew
Wanyan
Kaitlyn
Austin
Evan
Xioyi
Damien
Marie-Fleur
Richard
Supath
Amy
Lisa
Liheng
Garvin
Ethan
Ekaterina
Cole
Alice
Raymond
Susanna
Jocelyn
Davyn
Francisco
Roan
Omara
Lucas
Jenny
Justin
Jason
Amiya
Ngoc
Yuki
Niko
Naomi
Caspar
Charlene
Stanley
Ella
Noah
Yasmine
Ruibin
Wingyan
Joseph