-
Notifications
You must be signed in to change notification settings - Fork 0
/
whale.ino
192 lines (162 loc) · 4.98 KB
/
whale.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
182
183
184
185
186
187
188
189
190
191
192
#include "xbm.h"
#include <M5StickC.h>
int x = 30;
int y = 30;
bool isLeft = false;
bool mouthopened = false;
bool flapdown = false;
int bubblex = 0;
int bubbley = 0;
int bubblesize = 0;
bool isbubble = false;
bool chewtime = false;
int chewcount = 0;
bool chomp = false;
bool eating = false;
int shrimptick = 0;
int ticks = 0;
int sleeptick = 0;
bool asleep = false;
int offticks = 0;
void setup() {
M5.begin();
M5.Lcd.setRotation(1);
M5.Axp.ScreenBreath(10);
M5.Lcd.fillScreen(TFT_BLACK);
M5.Lcd.setTextSize(2);
M5.Lcd.print(" How's this\n for a rare\n vpet?\n <3\n -joostin");
delay(4000);
M5.Lcd.fillScreen(TFT_BLACK);
}
void loop() {
if(sleeptick > 3000) {
M5.Axp.ScreenBreath(8);
asleep = true;
offticks = offticks + 1;
} else if (!asleep) {
sleeptick = sleeptick + 1;
}
if(ticks < 100){
M5.update();
if (M5.BtnA.wasPressed()) {
if(asleep) {
asleep = false;
sleeptick = 0;
M5.Axp.ScreenBreath(10);
} else {
sleeptick = 0;
if (!eating) {
chewtime = true;
chewcount = 5;
chomp = true;
eating = true;
shrimptick = 4;
}
}
}
delay(10);
ticks = ticks + 1;
} else {
ticks = 0;
if(eating) {
x = x + 4;
if(y > M5.Lcd.height() - (whaleHeight / 2) ) {
y = y + 4;
} else {
y = y - 4;
}
} else {
x = x + ((random(3) - 1)*4);
y = y + ((random(3) - 1)*4);
}
x = max(min(x, M5.Lcd.width() - whaleWidth - shrimpWidth), 0);
y = max(min(y, M5.Lcd.height() - whaleHeight), 0);
/*
whale_r_open_up
whale_r_open_down
whale_r_closed_down
whale_r_closed_up
whale_l_open_up
whale_l_open_down
whale_l_closed_down
whale_l_closed_up
*/
M5.Lcd.fillScreen(BLACK);
if(flapdown) {
if(chewtime && chomp) {
M5.Lcd.drawXBitmap(x, y, whale_r_closed_down, whaleWidth, whaleHeight, TFT_NAVY);
} else {
M5.Lcd.drawXBitmap(x, y, whale_r_open_down, whaleWidth, whaleHeight, TFT_NAVY);
}
flapdown = false;
} else {
if(chewtime && chomp) {
M5.Lcd.drawXBitmap(x, y, whale_r_closed_up, whaleWidth, whaleHeight, TFT_NAVY);
} else {
M5.Lcd.drawXBitmap(x, y, whale_r_open_up, whaleWidth, whaleHeight, TFT_NAVY);
}
flapdown = true;
}
// yeah i know, i'm tired.
if(eating) {
if(shrimptick == 4) {
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimpfill1, shrimpWidth, shrimpHeight, TFT_PINK);
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimp1, shrimpWidth, shrimpHeight, TFT_MAROON);
} else if (shrimptick == 3) {
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimpfill2, shrimpWidth, shrimpHeight, TFT_PINK);
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimp2, shrimpWidth, shrimpHeight, TFT_MAROON);
} else if (shrimptick == 2) {
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimpfill3, shrimpWidth, shrimpHeight, TFT_PINK);
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimp3, shrimpWidth, shrimpHeight, TFT_MAROON);
} else if (shrimptick == 1) {
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimpfill4, shrimpWidth, shrimpHeight, TFT_PINK);
M5.Lcd.drawXBitmap(M5.Lcd.width() - shrimpWidth, (M5.Lcd.height() / 2) - 8, shrimp4, shrimpWidth, shrimpHeight, TFT_MAROON);
}
shrimptick = shrimptick - 1;
if(shrimptick < 1) {
eating = false;
}
}
if(!isbubble){
isbubble = true;
bubblex = x + 70;
bubbley = y - 4;
bubblesize = 1;
}
if(isbubble) {
M5.Lcd.drawCircle(bubblex, bubbley, bubblesize, TFT_BLUE);
bubbley = bubbley - 8;
bubblesize = bubblesize + 1;
bubblesize = min(3, bubblesize);
}
if(bubbley <= -50) {
isbubble = false;
}
if(chewtime) {
chewcount = chewcount - 1;
if(chomp) {
chomp = false;
} else {
chomp = true;
}
}
if(chewtime && chewcount <= 0){
chewtime = false;
// so lazy, sorry.
M5.Lcd.drawXBitmap(x + 58, y + 19, heart, heartWidth, heartHeight, TFT_PINK);
delay(1000);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.drawXBitmap(x, y, whale_r_open_up, whaleWidth, whaleHeight, TFT_NAVY);
delay(1000);
M5.Lcd.drawXBitmap(x + 58, y + 19, heart, heartWidth, heartHeight, TFT_PINK);
delay(1000);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.drawXBitmap(x, y, whale_r_open_up, whaleWidth, whaleHeight, TFT_NAVY);
delay(1000);
M5.Lcd.drawXBitmap(x + 58, y + 19, heart, heartWidth, heartHeight, TFT_PINK);
delay(1000);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.drawXBitmap(x, y, whale_r_open_up, whaleWidth, whaleHeight, TFT_NAVY);
}
}
}