forked from Press-Play-On-Tape/LayingPipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplash.ino
181 lines (124 loc) · 5.85 KB
/
Splash.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#define ANIMATION_DELAY_SHORT 20
/* ----------------------------------------------------------------------------
* Render the Splash screen.
*
* The pipes are rendered one-by-one to simulate the laying of pipe. The
* rendering function allows the user to press the A button to skip past the
* animations or the B button to toggle sounds.
*/
void drawSplash() {
bool skipSplash = false;
arduboy.clear();
sprites.drawOverwrite(120, 56, (arduboy.audio.enabled() ? sound_icon : no_sound_icon), frame);
arduboy.display();
skipSplash = splashAnimation(112, 0, logo_straight_TB_noflange, frame, skipSplash);
skipSplash = splashAnimation(112, 16, logo_elbow_TL, frame, skipSplash);
skipSplash = splashAnimation(96, 16, logo_elbow_TR, frame, skipSplash);
skipSplash = splashAnimation(96, 0, logo_elbow_LB, frame, skipSplash);
skipSplash = splashAnimation(80, 0, logo_straight_LR_noflange, frame, skipSplash);
skipSplash = splashAnimation(64, 0, logo_straight_LR, frame, skipSplash);
skipSplash = splashAnimation(48, 0, logo_elbow_RB, frame, skipSplash);
skipSplash = splashAnimation(48, 16, logo_straight_TB_noflange, frame, skipSplash);
skipSplash = splashAnimation(48, 32, logo_elbow_TR, frame, skipSplash);
skipSplash = splashAnimation(64, 32, logo_elbow_LB, frame, skipSplash);
skipSplash = splashAnimation(64, 48, logo_straight_TB_noflange, frame, skipSplash);
skipSplash = splashDelay(200, skipSplash);
skipSplash = splashAnimation(0, 0, logo_straight_TB_noflange, frame, skipSplash);
skipSplash = splashAnimation(0, 16, logo_straight_TB, frame, skipSplash);
skipSplash = splashAnimation(0, 32, logo_elbow_TR, frame, skipSplash);
skipSplash = splashAnimation(16, 32, logo_straight_LR, frame, skipSplash);
skipSplash = splashAnimation(32, 32, logo_elbow_TL, frame, skipSplash);
skipSplash = splashAnimation(32, 16, logo_elbow_RB, frame, skipSplash);
skipSplash = splashAnimation(48, 16, logo_cross_underlap_hflange, frame, skipSplash);
skipSplash = splashAnimation(64, 16, logo_straight_LR_noflange, frame, skipSplash);
skipSplash = splashAnimation(80, 16, logo_elbow_LB, frame, skipSplash);
skipSplash = splashAnimation(80, 32, logo_elbow_TR, frame, skipSplash);
skipSplash = splashAnimation(96, 32, logo_straight_LR, frame, skipSplash);
skipSplash = splashAnimation(112, 32, logo_straight_LR_noflange, frame, skipSplash);
skipSplash = splashDelay(200, skipSplash);
skipSplash = splashAnimation(0, 0, logo_cross_underlap, frame, skipSplash);
skipSplash = splashAnimation(16, 0, logo_elbow_LB, frame, skipSplash);
skipSplash = splashAnimation(16, 16, logo_straight_TB, frame, skipSplash);
skipSplash = splashAnimation(16, 32, logo_cross_overlap_hflange, frame, skipSplash);
skipSplash = splashAnimation(16, 48, logo_elbow_TR, frame, skipSplash);
skipSplash = splashAnimation(32, 48, logo_straight_LR, frame, skipSplash);
skipSplash = splashAnimation(48, 48, logo_straight_LR_noflange, frame, skipSplash);
skipSplash = splashAnimation(64, 48, logo_cross_underlap_hflange, frame, skipSplash);
skipSplash = splashAnimation(80, 48, logo_straight_LR_noflange, frame, skipSplash);
skipSplash = splashAnimation(96, 48, logo_elbow_LB, frame, skipSplash);
skipSplash = splashDelay(200, skipSplash);
if (!skipSplash) {
arduboy.fillRect(19, 18, 92, 30, BLACK);
drawHorizontalDottedLine(20, 110, 19);
drawHorizontalDottedLine(20, 110, 46);
sprites.drawOverwrite(23, 21, logo, frame);
arduboy.display();
splashWaitForever();
}
gameState = STATE_LEVEL_SELECT;
}
/* ----------------------------------------------------------------------------
* Render the a single pipe animation.
*
* The pipes are rendered one-by-one to simulate the laying of pipe. The
* rendering function allows the user to press the A button to skip past the
* animations or the B button to toggle sounds.
*/
bool splashAnimation(byte x, byte y, const uint8_t *bitmap, uint8_t frame, bool skip) {
if (skip) return true;
int i = ANIMATION_DELAY_SHORT;
sprites.drawOverwrite(x, y, bitmap, frame);
arduboy.display();
playSplashTune();
while (i >= 0) {
arduboy.pollButtons();
if (arduboy.justPressed(A_BUTTON)) { return true; }
if (arduboy.justPressed(B_BUTTON)) {
toggleSoundSettings();
sprites.drawOverwrite(120, 56, (arduboy.audio.enabled() ? sound_icon : no_sound_icon), frame);
arduboy.display();
}
arduboy.delayShort(15);
i--;
}
return false;
}
/* ----------------------------------------------------------------------------
* Delay the screen for a period of time.
*
* The delay can be cancelled by clicking either the A button. Clicking the
* B button will toggle the sound on or off.
*/
bool splashDelay(int delayLength, bool skip) {
if (skip) return true;
while (delayLength >= 0) {
arduboy.pollButtons();
if (arduboy.justPressed(A_BUTTON)) { return true; }
if (arduboy.justPressed(B_BUTTON)) {
toggleSoundSettings();
sprites.drawOverwrite(120, 56, (arduboy.audio.enabled() ? sound_icon : no_sound_icon), frame);
arduboy.display();
}
arduboy.delayShort(5);
delayLength--;
}
return false;
}
/* ----------------------------------------------------------------------------
* Delay the screen for ever.
*
* The delay can be cancelled by clicking either the A button. Clicking the
* B button will toggle the sound on or off.
*/
void splashWaitForever() {
while (true) {
arduboy.pollButtons();
if (arduboy.justPressed(A_BUTTON)) { break; }
if (arduboy.justPressed(B_BUTTON)) {
toggleSoundSettings();
sprites.drawOverwrite(120, 56, (arduboy.audio.enabled() ? sound_icon : no_sound_icon), frame);
arduboy.display();
}
arduboy.delayShort(5);
}
}