forked from APCSLowell/SampleAssignmentSimple
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsnowV4.pde
163 lines (143 loc) · 3.66 KB
/
snowV4.pde
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.util.Iterator;
ArrayList<Flake> myList;
void setup() {
size(800, 400);
myList=new ArrayList<Flake>();
myList.add(new Hour5());
myList.add(new Hour5());
myList.add(new Hour5());
myList.add(new Hour6());
myList.add(new Hour6());
myList.add(new Hour6());
}
void draw() {
background(125);
frameRate(8);
Iterator<Flake> it = myList.iterator();
while (it.hasNext()) {
Flake f = it.next();
f.display();
f.addPhysics();
f.somethingSpecial();
if (f.isDead()) {
f.snow();
}
}
}
interface Flake {
void snow(); //resets flake
void display(); //flake identity, ellipse
void addPhysics(); //Velocity, acceleration, location (experiement with these!)
void somethingSpecial();
boolean isDead(); //snow at bottom of screen(will be provided, but can be changed!)
}
class Hour5 implements Flake {
PVector velocity;
PVector location;
PVector acceleration;
float lifespan;
float diameter = random(5, 10);
PFont mono;//for something special!
Hour5() {
location = new PVector(random(-3, 800), random(-3, 20));
velocity = new PVector(random(-.22, .22), 5);
acceleration = new PVector(0, 0.001);
lifespan=255;
mono = createFont("GloriaHallelujah.ttf", 22);
//mono = createFont("https://fonts.googleapis.com/css?family=Courgette", 22);
}
Hour5(int x, int y) {
}
void snow() {
location.y=random(-2, 10);
location.x=random(width);
lifespan=255;
}
void display() {
lifespan -= 3.0;
noStroke();
smooth();
fill(random(250, 255), random(250, 255), random(250, 255), lifespan);
if (location.y>height||location.y<-30) {
location.y=random(0, 40);
}
if (location.x>width||location.x<-30) {
location.x=random(0, 800);
}
text("Hour5", location.x+30, location.y);
ellipse(location.x, location.y, diameter, diameter);
}
boolean isDead() {
if (lifespan < 0.0) {
return true;
} else {
return false;
}
}
void addPhysics() {
PVector gravity = new PVector(random(0, 2), random(0, 20));
acceleration=PVector.random2D();
velocity.add(acceleration);
location.add(velocity);
location.add(gravity);
}
void somethingSpecial() {
textFont(mono);
text("somethingSpecial:", 12, 60);
}
}
class Hour6 implements Flake {
PVector velocity;
PVector location;
PVector acceleration;
float lifespan;
float diameter = random(5, 10);
PFont mont;//for something special!
Hour6() {
location = new PVector(random(-3, 800), random(-3, 20));
velocity = new PVector(random(-.22, .22), 5);
acceleration = new PVector(0, 0.001);
lifespan=255;
mont = createFont("Dekko-Regular.ttf", 32);
// mont = createFont("https://fonts.googleapis.com/css?family=Sigmar+One", 32);
}
Hour6(int x, int y) {
}
void snow() {
location.y=random(-2, 10);
location.x=random(width);
lifespan=255;
}
void display() {
lifespan -= 3.0;
noStroke();
smooth();
fill(random(100, 255), 0, 0, lifespan);
if (location.y>height||location.y<-30) {
location.y=random(0, 40);
}
if (location.x>width||location.x<-30) {
location.x=random(0, 800);
}
text("Hour6", location.x+30, location.y);
ellipse(location.x, location.y, diameter, diameter);
}
boolean isDead() {
if (lifespan < 0.0) {
return true;
} else {
return false;
}
}
void addPhysics() {
PVector gravity = new PVector(random(0, 2), random(0, 20));
acceleration=PVector.random2D();
velocity.add(acceleration);
location.add(velocity);
location.add(gravity);
}
void somethingSpecial() {
textFont(mont);
text("GoogleFonts!", 12, 100);
}
}