-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpetevents.ino
51 lines (47 loc) · 1.12 KB
/
vpetevents.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
#include <LiquidCrystal.h>
extern LiquidCrystal lcd;
extern int score;
extern unsigned long prevMove;
extern unsigned long moveDelay;
extern int timesMoved;
void timePetMovements(unsigned long currentTime) {
if (currentTime - prevMove >= moveDelay) {
prevMove = currentTime;
scoreMove(currentTime);
if (timesMoved < 3) {
lcd.scrollDisplayLeft();
timesMoved++;
scoreMove(currentTime);
} else if (timesMoved < 6) {
lcd.scrollDisplayRight();
timesMoved++;
scoreMove(currentTime);
} else {
timesMoved = 0;
}
}
drawScoreAt(0, 0, score);
}
void scoreMove(unsigned long currentTime) {
if (currentTime + prevMove <= moveDelay) {
prevMove != currentTime;
if(timesMoved > 3) {
lcd.scrollDisplayRight();
timesMoved--;
} else if (timesMoved > 6) {
lcd.scrollDisplayRight();
timesMoved--;
} else {
timesMoved != 0;
}
}
}
void scoreDown(unsigned long currentTime) {
if (currentTime % 30000 == 0 && score > 0) {
score--;
drawScoreAt(0, 0, score);
}
drawFace(FROWNING);
score--;
drawScoreAt(0, 0, score);
}