-
Notifications
You must be signed in to change notification settings - Fork 0
/
RainDance.pde
148 lines (133 loc) · 3.61 KB
/
RainDance.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
Dancer dancer[] = new Dancer[8];
Dancer menuDancers[] = new Dancer[10];
Dancer loseScreenDancers[] = new Dancer[10];
CloudSet theClouds;
Rain theRain;
Cursor cursor;
Score score;
BirdSet theBirds;
boolean gameWon = false;
boolean gameLost = false;
boolean menuScreenIsOn = true;
boolean loseScreenIsOn = false;
int numDancersDancing = 0;
interface JavaScript{
void audioIsSupported();
void playChirp();
void setNotePlayable();
void setNoteUnplayable();
}
void bindJavascript(JavaScript js){
gameSounds = js;
}
JavaScript gameSounds;
int maxSize = 55;
int minSize = 20;
int birdCount = 0;
void setup(){
frameRate(60);
noCursor();
size(800,600);
for(int i = 0; i < dancer.length; i++){
setNoteUnplayable();
}
cursor = new Cursor();
theClouds = new CloudSet();
for(int i = 0; i < dancer.length; i++){
dancer[i] = new Dancer((int)(Math.random()*800),400,(int)(Math.random()*(maxSize - minSize))+minSize)
}
for(int i = 0; i < menuDancers.length; i++){
menuDancers[i] = new Dancer((int)(Math.random()*800),400,(int)(Math.random()*(maxSize - minSize))+minSize);
menuDancers[i].isDancing = true;
}
for(int i = 0; i < loseScreenDancers.length; i++){
loseScreenDancers[i] = new Dancer((int)(Math.random()*800),400,(int)(Math.random()*(maxSize - minSize))+minSize);
loseScreenDancers[i].isFrowning = true;
loseScreenDancers[i].isCrying = true;
}
theBirds = new BirdSet();
theRain = new Rain();
score = new Score();
smooth();
}
void draw(){
if(menuScreenIsOn){
background(0);
fill(255,255,255);
textFont(createFont("Georgia", 36));
textAlign(CENTER,CENTER);
text("Rain Dance", width/2, height*(1/6));
textFont(createFont("Georgia",24));
if((mouseY > (height*(7/9) - 20))&&(mouseY<height*(7/9)+20)){
fill(0,0,255);
}
textAlign(CENTER,CENTER);
text("Play",width/2,height*(7/9));
fill(255,255,255);
textAlign(LEFT,CENTER);
text("Make it rain before the cloud passes!",width/4,height*(3/9));
text("Hover the mouse over birds to make them sing.",width/4,height*(4/9));
text("If enough birds sing, these guys will be happy!",width/4,height*(5/9));
for(int i = 0; i < menuDancers.length; i++){
menuDancers[i].update();
}
noStroke();
fill(255,255,255);
rect(mouseX,mouseY,5,5);
return;
}
if(loseScreenIsOn){
background(0);
textFont(createFont("Georgia", 36));
textAlign(CENTER,CENTER);
fill(255,255,255);
text("The cloud has left without raining!", width/2, height*(1/6));
if((mouseY > (height*(1/2) - 20))&&(mouseY<height*(1/2)+20)){
fill(0,0,255);
}
text("Play Again",width/2,height*(1/2));
for(int i = 0; i<loseScreenDancers.length; i++){
loseScreenDancers[i].update();
}
fill(255,255,255);
rect(mouseX,mouseY,5,5);
return;
}
background(175,175,200);
theBirds.addBird();
fill(82,151,52);
noStroke();
rect(0, height/1.5, width, height - (height/1.5));
for(int i = 0; i < dancer.length; i++){
dancer[i].update();
}
if(gameWon){
theRain.addRainDrop();
theRain.updateRainDrops();
fill(255,255,255);
textFont(createFont("Georgia", 36));
textAlign(CENTER,CENTER);
text("You Win!!!", width/2, height*(2/6));
if((mouseY > (height*(1/2) - 20))&&(mouseY<height*(1/2)+20)){
fill(0,0,255);
}
text("Play Again",width/2,height*(1/2));
}
theClouds.update();
theBirds.updateBirds();
cursor.update();
score.update();
}
void mousePressed(){
if((mouseY > (height*(7/9) - 20))&&(mouseY<height*(7/9)+20)){
menuScreenIsOn = false;
}
if(loseScreenIsOn || gameWon){
if((mouseY > (height*(1/2) - 20))&&(mouseY<height*(1/2)+20)){
setup();
loseScreenIsOn = false;
gameWon = false;
menuScreenIsOn = true;
}
}
}