-
Notifications
You must be signed in to change notification settings - Fork 2
/
title.cpp
105 lines (86 loc) · 2.18 KB
/
title.cpp
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
#include <Arduino.h>
#include "globals.h"
#include "data.h"
#include "save.h"
#define WHITE_PIXEL_WAIT_TIME 20000
#define REDRAW_TITLE_WAIT_TIME 1000
void drawTitleAndSubtitle()
{
// Get the length of the strings
size_t titleLen = strlen_P(gameTitle);
size_t subTitleLen = strlen_P(gameSubTitle);
// Print game title, large and centered
arduboy.setTextSize(2);
arduboy.setCursor(64 - titleLen*6, 12);
arduboy.print(eps((char *)gameTitle));
// Display game subtitle, small and centered
arduboy.setTextSize(1);
if(GameMode == GAME_MODE_RANDOM) {
arduboy.setCursor(64 - 11*3, 30);
arduboy.print(eps((char *)gameRandom));
} else {
arduboy.setCursor(64 - subTitleLen*3, 30);
arduboy.print(eps((char *)gameSubTitle));
}
}
void displayTitle()
{
unsigned char upPressCount = 0;
unsigned int randomCount;
// Ticks until white pixels draw
short whitePixelDelay = WHITE_PIXEL_WAIT_TIME;
// Ticks until glove logo redraw
short redrawTitleDelay = REDRAW_TITLE_WAIT_TIME;
arduboy.clear();
drawTitleAndSubtitle();
int roomsCleared = getRoomClearPercentage();
// Display room clear count if the player beat at least level 1
if(!GameMode && roomsCleared > 0)
{
arduboy.setCursor(6, 8*6 + 4);
arduboy.print(F("ROOMS CLEARED: "));
arduboy.print(roomsCleared);
arduboy.print("%");
}
// Display copyright on an otherwise fresh file
else
{
arduboy.setCursor(20, scrh-8);
arduboy.print(F("(c) 2016 fuopy"));
}
arduboy.display();
// Wait 1000 ticks
delay(1000);
// Start blanking out the screen
while(true) {
randomCount++;
updateInput();
if(UP_PRESSED){
upPressCount++;
if(upPressCount == 100) {
clearAllRooms();
}
}
// Draw black pixels
arduboy.drawPixel(random(0,128), random(0,64), 0);
// Draw white pixels
if(whitePixelDelay <= 0) {
arduboy.drawPixel(random(0,128), random(0,64), 1);
redrawTitleDelay--;
whitePixelDelay = 10;
whitePixelDelay--;
} else {
whitePixelDelay--;
}
// Redraw title
if(redrawTitleDelay <= 0) {
drawTitleAndSubtitle();
redrawTitleDelay = REDRAW_TITLE_WAIT_TIME;
}
arduboy.display();
if(A_PRESSED) {
randomSeed(random()+randomCount);
break;
}
}
}