-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoveLive
118 lines (85 loc) · 2.43 KB
/
LoveLive
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
import java.awt.Color;
public class LoveLive{
public static void main(String[] args) {
int x=0, y=0, dx=0, dy=0, score = 0;
boolean updateScore = false;
int missed = 0;
int fallx = 0, fally = 0;
int num = 0;
String text = "";
String user = "";
long startTime =System.currentTimeMillis();
int count = 0;
int level = 0;
Zen.setFont("Helvetica-60");
Zen.setColor(255, 0, 255);
while (Zen.isRunning()) {
fally = 0;//resets the falling numbers to the top of the screen
/*//initially fills background
Zen.setColor(Color.darkGray);
Zen.fillRect(0, 0, Zen.getZenWidth(), Zen.getZenHeight());
//row of numbers
Level.numrow();
*/
//computes random number between 0 and 9
num = (int)(10 * Math.random() - 1);
//falling red numbers
while (fally <= Zen.getZenHeight()){
Zen.setColor(Color.darkGray);
Zen.fillRect(0, 0, Zen.getZenWidth(), Zen.getZenHeight());
Level.numrow();
Zen.setColor(Color.pink);
Zen.drawText("Score: " + score, 10, 60);
Zen.drawText("Lives: "+ (20 - missed), 10, 120);
//Zen.drawText("" + Level.newspeed(count), fallx, fally);
Zen.setColor(Color.red);
text = "" + num;
if (num == 0){
Zen.drawText(text, 540, fally);
}
else{
Zen.drawText(text, 60 * num-60, fally);
}
Zen.setColor(Color.pink);
Level.numrow();
fally+=3;
Zen.flipBuffer();
Zen.sleep(Level.newspeed(count));
//Harshit - change color of falling text when it is in the zone
user = Zen.getEditText();
Zen.setEditText("");
if ((user.equals(text)) && ((fally <= Zen.getZenHeight()/2 + 120) && (fally >= Zen.getZenHeight()/2 + 80))){
updateScore = true;
}
else if (user.equals("") == false){
updateScore = false;
}
}
//clears user string
user = "";
if (updateScore){
score++;
}
else{
missed++;
}
count++;
if (20 - missed == -1){
break;
}
updateScore = false;
//end number fall
Zen.flipBuffer();
Zen.sleep(1);
}//end while
while (Zen.isRunning()){
Zen.setColor(Color.black);
Zen.fillRect(0, 0, Zen.getZenWidth(), Zen.getZenHeight());
Zen.setColor(Color.red);
Zen.drawText("Game Over", Zen.getZenWidth()/2-200, Zen.getZenHeight()/2);
Zen.drawText("Score: " + score, Zen.getZenWidth()/2-200, Zen.getZenHeight()/2 + 80);
Zen.flipBuffer();
Zen.sleep(1);
}
}//end main
}