-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLodeRunner_SplashScreen.ino
68 lines (47 loc) · 1.8 KB
/
LodeRunner_SplashScreen.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
#include "src/utils/Arduboy2Ext.h"
static constexpr uint8_t ppotFrames = (1.6 *25); // 1.6s animation loop
// ----------------------------------------------------------------------------
// Initialise state ..
//
void splashScreen_Init() {
gameState = GameState::SplashScreen;
}
// ----------------------------------------------------------------------------
// Handle state updates ..
//
void splashScreen() {
if (arduboy.justPressed(A_BUTTON) || arduboy.justPressed(B_BUTTON)) {
gameState = GameState::Intro;
}
Sprites::drawOverwrite(32, 16, PPOT, 0);
uint8_t p = 0x11; // Default pixel position 0 is hidden in the image
switch (arduboy.frameCount % ppotFrames) {
// 2nd quarter of frames
case (ppotFrames*1/4) ... (ppotFrames*2/4)-1:
p = 0x31; // Move pixel down to position 1
/*-fallthrough*/
// 1st quarter of frames
case 0 ... (ppotFrames*1/4)-1:
// Flash 'Play' arrow by clearing the image
// Overwrite using filled rectangle
arduboy.fillRect(91, 24, 5, 7, BLACK);
break;
// 3rd quarter of frames
case (ppotFrames*2/4) ... (ppotFrames*3/4)-1:
p = 0x51; // Move pixel down to position 2
break;
// 4th quarter of frames
default:
p = 0x91; // Move pixel down to position 3
break;
}
// Draw pixel to represent the tape spooling
// Render directly to the screen buffer
arduboy.sBuffer[52 +(3*WIDTH)] = p; // Values 0x11, 0x31, 0x51, 0x91
// On even steps of pixel movement, update the spindle image
if ((p & 0xA0) == 0) {
// Render directly to the screen buffer
arduboy.sBuffer[45 +(3*WIDTH)] = 0xA5;
arduboy.sBuffer[46 +(3*WIDTH)] = 0x95;
}
}