-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExitSection.ino
113 lines (111 loc) · 3.65 KB
/
ExitSection.ino
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
// game lost
// wait for pushing "B" to restart game
void startExitSection () {
if (z == 3000) {
M5.Lcd.setCursor(0, 100);
M5.Lcd.setTextColor(M5.Lcd.color565(255, 131, 250));
M5.Lcd.setTextSize(3);
M5.Lcd.println(" VICTORY! ");
M5.Lcd.setCursor(100, 210);
M5.Lcd.setTextColor(M5.Lcd.color565(139, 0, 139));
M5.Lcd.setTextSize(2);
M5.Lcd.println(" play again? ");
while (1) {
// wait for push button
if (M5.BtnB.read()) {
while (1) {
if (!M5.BtnB.read()) {
break;
}
}
M5.Lcd.setCursor(0, 100);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setTextSize(3);
M5.Lcd.println(" VICTORY! ");
M5.Lcd.setCursor(80, 210);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setTextSize(2);
M5.Lcd.println("play again? ");
CollisionDistance = false;
PosAsteroid1 = 40;
StartPointAsteroid1 = 0;
PosAsteroid2 = 140;
StartPointAsteroid2 = 100;
PosAsteroid3 = 60;
StartPointAsteroid3 = 50;
LevelPosPlus = 20;
Level = -3;
CountHit = 0;
M5.Lcd.fillRect(1, 1, 264, 240, BLACK);
M5.Lcd.setRotation(0);
M5.Lcd.setTextSize(3);
M5.Lcd.setCursor(10, 290);
M5.Lcd.setTextColor(RED);
M5.Lcd.print("Score: ");
M5.Lcd.setTextColor(M5.Lcd.color565(117, 117, 117));
M5.Lcd.print(z / 20);
z = 0;
break;
}
}
}
if (CollisionDistance) {
M5.Lcd.setCursor(0, 100);
M5.Lcd.setTextColor(M5.Lcd.color565(255, 131, 250));
M5.Lcd.setTextSize(3);
M5.Lcd.println(" GAME OVER ");
M5.Lcd.setCursor(100, 210);
M5.Lcd.setTextColor(M5.Lcd.color565(139, 0, 139));
M5.Lcd.setTextSize(2);
M5.Lcd.println(" play again? ");
while (1) {
// wait for push button
if (M5.BtnB.read()) {
while (1) {
if (!M5.BtnB.read()) {
break;
}
}
M5.Lcd.setCursor(0, 100);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setTextSize(3);
M5.Lcd.println(" GAME OVER ");
M5.Lcd.setCursor(80, 210);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.setTextSize(2);
M5.Lcd.println("play again? ");
CollisionDistance = false;
PosAsteroid1 = 0;
StartPointAsteroid1 = random(1, TFTW - 2 * Asteroid1W);
PosAsteroid2 = 50;
StartPointAsteroid2 = random(1, TFTW - Asteroid2W - 10);
DifferenceAsteroid1to2 = StartPointAsteroid1 - StartPointAsteroid2;
while ((abs(DifferenceAsteroid1to2) < 22) ) {
StartPointAsteroid2 = random(1, TFTW - Asteroid1W - 10);
DifferenceAsteroid1to2 = StartPointAsteroid1 - StartPointAsteroid2;
}
PosAsteroid3 = 90;
StartPointAsteroid3 = random(1, TFTW - Asteroid3W - 10);
DifferenceAsteroid1to3 = StartPointAsteroid1 - StartPointAsteroid3;
DifferenceAsteroid2to3 = StartPointAsteroid2 - StartPointAsteroid3;
while ((abs(DifferenceAsteroid1to3) < 22) || (abs(DifferenceAsteroid2to3) < 22)) {
StartPointAsteroid3 = random(1, TFTW - Asteroid1W - 10);
DifferenceAsteroid1to3 = StartPointAsteroid1 - StartPointAsteroid3;
DifferenceAsteroid2to3 = StartPointAsteroid2 - StartPointAsteroid3;
}
LevelPosPlus = 20;
Level = -3;
M5.Lcd.fillRect(1, 1, 264, 240, BLACK);
M5.Lcd.setRotation(0);
M5.Lcd.setTextSize(3);
M5.Lcd.setCursor(10, 290);
M5.Lcd.setTextColor(RED);
M5.Lcd.print("Score: ");
M5.Lcd.setTextColor(M5.Lcd.color565(117, 117, 117));
M5.Lcd.print(z / 20);
z = 0;
break;
}
}
}
}