-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drop.pde
55 lines (48 loc) · 1.16 KB
/
Drop.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
class Drop {
int dropSlotX;
int dropSlotZ;
int posY;
int bpmDrop;
int speed;
String lyric;
Drop (int dropSlotX, int dropSlotY) {
this.dropSlotX = dropSlotX;
this.posY = dropSlotY + (cloudHeight/2) - 10; //cloud (60) + margin (20)
if (lyricSwitch == true){
this.lyric = lyrics[int(random(0,lyrics.length))];
} else{
this.lyric = "";
}
if (dynamicTempo == true){
this.bpmDrop = int(random(bpm, bpm*4));
} else{
this.bpmDrop = bpm;
}
this.dropSlotZ = int(random(0,80));
setSpeed(); //sets speed
}
void fall(){
setSpeed();
posY += speed + (posY/8) * 0.2;
//Draw
strokeWeight(3);
stroke(255);
shapeMode(CENTER);
shape(dropShape,dropSlotX,posY);
text(this.lyric,dropSlotX,posY,dropSlotZ);
}
boolean hitGround(){
if (posY >= height){
posY = 0;
return true;
} else {
return false;
}
}
void setSpeed(){
int getSpeed = int((height/frameRate * (bpmDrop/60))/20);
if (getSpeed > 0) {
speed = int(getSpeed);
}
}
}