forked from APCSLowell/Lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightning.pde
More file actions
48 lines (47 loc) · 1.01 KB
/
Copy pathLightning.pde
File metadata and controls
48 lines (47 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int startX = 150;
int startY = 0;
int endX = 150;
int endY = 0;
void setup()
{
size(300,300);
strokeWeight(2);
background(0);
}
void draw()
{
noStroke();
//clouds for the thunderstorm
fill(255);
for (int x=100; x<=200; x+=10)
ellipse (x, 20, 40, 40);
for (int x=110; x<+190; x+=10)
ellipse (x, 30, 40, 40);
//fading effect for thunder and ghost
fill (0, 20);
rect(0, 0, 300, 300);
//the use of Math.random() to create random lightning
endX = startX + (int)(Math.random()*19) - 9;
endY = startY + (int)(Math.random()*10);
stroke(255, 255, 0);
line(startX, startY, endX, endY);
startX = endX;
startY = endY;
}
void mousePressed()
{
startX = 150;
startY = 0;
endX = 150;
endY = 0;
//Ghost that appears when you click
fill((int)(Math.random()*256), (int)(Math.random()*256), (int)(Math.random()*256));
noStroke();
ellipse(150,150, 40, 40);
rect(135, 160, 30, 60);
fill(0);
ellipse(140, 150, 5, 5);
ellipse(160, 150, 5, 5);
ellipse(150, 170, 10, 20);
redraw();
}