-
Notifications
You must be signed in to change notification settings - Fork 0
/
squid_jump.ino
709 lines (597 loc) · 18.5 KB
/
squid_jump.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
// Copyright © 2023 PrimmR
// Licensed under GNU General Public License v3.0
// Squid Jump v1.2
#include <Arduboy2.h>
#include <ArduboyTones.h>
Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);
#include "Structs.hpp"
#include "Sprites.hpp"
#include "Sounds.hpp"
#include "Sums.hpp"
#include "Saves.hpp"
#include <limits.h>
#define MOD(a, b) ((((a) % (b)) + (b)) % (b))
// #define CHAR_WIDTH 6
// #define CHAR_HEIGHT 8
#define CHAR_WIDTH 7
#define CHAR_HEIGHT 6
// Game states
#define GAME_TITLE 0
#define GAME_PLAY 1
// #define GAME_OVER 2
#define GAME_STATUS 3
// #define GAME_CONGRATS 4
#define GAME_PAUSE 5
int gamestate = GAME_TITLE;
#define PAUSE_PADDING 2
// Graphics
int sprite = REGULAR; // Default
#define MAX_X_VELOCITY 1.5
#define X_VELOCITY_DECAY 0.01
#define X_ACCEL 0.1
#define MAX_Y_VELOCITY 12
#define Y_ACCEL 0.1
#define MAX_CHARGE 64
float poisonheight = 128;
#define LEEWAY 8
#define POISON_SPEED 0.25
#define ZAP_UP 84
#define LIFE_SPACING 10
struct Player player = {
(WIDTH - PLAYER_SIZE) / 2,
HEIGHT - 2 * BLOCK_SIZE - PLAYER_SIZE,
0,
0,
true,
0,
0,
0,
0,
false,
1
};
struct Stage stage = { 1, {}, 0, {}, 0, 0, 2 };
struct Zapfish zapfish {
0
};
// Camera
#define CAM_UPPER_BOUNDARY 20 // Positions for which the camera starts to follow
#define CAM_LOWER_BOUNDARY 40
int camerapos = 0; // + moves screen up
// Status
byte lives = 3;
#define EXTRA_LIFE 10000
#define MAX_LIVES 5
uint32_t score = 0;
#define MAX_SCORE 99999
int stagebonus = 0;
int timebonus = 0;
#define MISS 0
#define GOAL 1
#define START 2
#define GAMEOVER 3
#define CONGRATS 4
int status = 0;
int statustimer = 0;
int statustimermax = 0;
bool proceedwithA = false;
uint16_t currentstagetimer = 0;
uint16_t quittimer = 0;
#define LOGO_START 1
#define MENU_SPACING 9
#define MENU_START LOGO_START + LOGO_HEIGHT + 4
#define MENU_COUNT 3
#define ARROW_L_OFFSET 12
#define ARROW_SPACING 2
#define MENU_X (WIDTH - ((4 + 2) * CHAR_WIDTH + ARROW_SPACING * 3 + ARROW_WIDTH)) / 2
int menupos = 0;
byte levelpos = 0;
bool led = true;
byte ledtimer = 0;
#define PLAY 0
#define MUTE 1
#define TOGGLELED 2
// FUNCTIONS
#include "Stages.hpp"
#include "Scripts.hpp"
#include "Status.hpp"
void titleinput() {
if (arduboy.justPressed(UP_BUTTON)) {
menupos--;
}
if (arduboy.justPressed(DOWN_BUTTON)) {
menupos++;
}
if (menupos == PLAY) {
if (arduboy.justPressed(LEFT_BUTTON) && levelpos > 0) {
levelpos--;
}
if (arduboy.justPressed(RIGHT_BUTTON) && (levelpos < 4 && LEVELPOS(levelpos + 1) <= toplevel)) {
levelpos++;
}
}
menupos = MOD(menupos, MENU_COUNT);
if (arduboy.justPressed(A_BUTTON)) {
switch (menupos) {
case PLAY:
ledtimer = 0;
stage.num = 1 + levelpos * 5;
menupos = 0;
levelpos = 0;
startgame();
break;
case MUTE:
arduboy.audio.toggle();
if (arduboy.audio.enabled()) {
sound.tones(powerup_sound);
}
break;
case TOGGLELED:
led = !led;
if (led) {
ledtimer = 30;
// arduboy.digitalWriteRGB(RGB_OFF, RGB_ON, RGB_OFF);
bool r = random(2);
bool g = random(2);
bool b = random(2);
if (r + g + b != 3) {
arduboy.digitalWriteRGB(r, g, b);
} else {
arduboy.digitalWriteRGB(RGB_ON, RGB_ON, RGB_ON);
}
}
break;
}
}
}
void titlescreen() {
titleinput();
if (ledtimer > 0) {
ledtimer--;
} else {
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF);
}
Sprites::drawOverwrite((WIDTH - LOGO_WIDTH) / 2, LOGO_START, Logo, 0);
setcursor(MENU_X, MENU_START);
squidprint("PLAY");
if (levelpos < 2) {
setcursor(MENU_X + 4 * CHAR_WIDTH + 2 * ARROW_SPACING + ARROW_WIDTH + CHAR_WIDTH / 2, MENU_START);
} else {
setcursor(MENU_X + 4 * CHAR_WIDTH + 2 * ARROW_SPACING + ARROW_WIDTH, MENU_START);
}
squidprint(LEVELPOS(levelpos));
if (menupos == PLAY) {
Sprites::drawOverwrite(MENU_X + 4 * CHAR_WIDTH + ARROW_SPACING, MENU_START, ArrowL, !(levelpos > 0));
Sprites::drawOverwrite(MENU_X + (4 + 2) * CHAR_WIDTH + ARROW_SPACING * 3 + ARROW_WIDTH, MENU_START, ArrowR, !(levelpos < 4 && LEVELPOS(levelpos + 1) <= toplevel));
}
// setcursor(MENU_X, MENU_START + MENU_SPACING);
setcursor(COPYRIGHT_WIDTH + CHAR_WIDTH, HEIGHT - CHAR_HEIGHT);
squidprint("HISCORE ");
scoresquidprint(topscore);
Sprites::drawOverwrite((WIDTH - ICON_SIZE) / 2, MENU_START + MENU_SPACING, Sound, arduboy.audio.enabled());
Sprites::drawOverwrite((WIDTH - ICON_SIZE) / 2, MENU_START + MENU_SPACING * 2, LED, led);
Sprites::drawOverwrite(((menupos != 0) ? (WIDTH - ICON_SIZE) / 2 : MENU_X) - ARROW_L_OFFSET, MENU_START - (1 * (menupos == 0)) + MENU_SPACING * menupos, Pointer, 0);
Sprites::drawOverwrite(0, HEIGHT - COPYRIGHT_HEIGHT, Copyright, 0);
}
void startgame() {
lives = 3;
score = 0;
stagebonus = 0;
timebonus = 0;
resetstage();
setupstatus(START);
}
void gameinput() {
if (arduboy.pressed(LEFT_BUTTON) && player.falling) {
if (player.xvelocity > -MAX_X_VELOCITY) {
player.xvelocity -= (X_ACCEL + X_VELOCITY_DECAY) * player.velocitymod * ((player.powerupstate == POWERUP_STAR) ? 1.5 : 1.0);
}
}
if (arduboy.pressed(RIGHT_BUTTON) && player.falling) {
if (player.xvelocity < MAX_X_VELOCITY) {
player.xvelocity += (X_ACCEL + X_VELOCITY_DECAY) * player.velocitymod * ((player.powerupstate == POWERUP_STAR) ? 1.5 : 1.0);
}
}
if (arduboy.pressed(A_BUTTON)) {
if (player.charge < MAX_CHARGE) {
player.charge += player.velocitymod * ((player.powerupstate == POWERUP_JELLY || player.powerupstate == POWERUP_STAR) ? 1.5 : 1.0); // Slightly too hardcoded but oh
} else if (player.charge > MAX_CHARGE) {
player.charge = MAX_CHARGE;
}
} else { // When A Button not pressed
// if (arduboy.justReleased(A_BUTTON)) {
if (player.charge >= MAX_CHARGE / CHARGE_NUM) {
float newvelocity = 4.0 * player.charge / MAX_CHARGE;
if (newvelocity > player.velocity) {
if (!player.falling) {
// player.xvelocity = 0; // True to original but less fun
player.velocity = newvelocity;
player.falling = true;
sound.tones(jump_sound);
} else if (player.powerupstate == POWERUP_JELLY && player.jumpcharge) { // Midair Jump
player.jumpcharge = false;
player.velocity = newvelocity;
player.falling = true;
sound.tones(jump_sound);
}
}
}
player.charge = 0;
}
if (arduboy.justPressed(B_BUTTON)) {
gamestate = GAME_PAUSE;
}
}
// Calculates whether platform would be hit next frame (may fail if collision boxes both 1px)
bool collision(Platform platform, int height) { // Assume that it's always called by player
if (player.velocity <= 0) {
Rect ray = Rect(player.intX() + PLAYER_COLLISION_CUT, player.intY() + PLAYER_SIZE + camerapos, PLAYER_SIZE - 2 * PLAYER_COLLISION_CUT, height);
Rect platformtop = Rect(platform.x, platform.y + camerapos, platform.len * BLOCK_SIZE, 2);
// arduboy.fillRect(player.x, player.y + PLAYER_SIZE + camerapos, PLAYER_SIZE, -1 * height); // Visual
// arduboy.fillRect(platform.x, platform.y + camerapos, platform.len * BLOCK_SIZE, 2); // Visual
return Arduboy2::collide(ray, platformtop);
}
return false;
}
bool powerupcollision(struct Powerup powerup) {
Rect playerbox = Rect(player.intX(), player.intY() + camerapos, PLAYER_SIZE, PLAYER_SIZE);
Rect powerupbox = Rect(powerup.x, powerup.y + camerapos, POWERUP_SIZE, POWERUP_SIZE);
return Arduboy2::collide(playerbox, powerupbox);
}
void physics() {
// Y
if (player.falling) {
player.y -= player.velocity * player.velocitymod;
player.velocity -= Y_ACCEL * player.velocitymod;
} else {
player.velocity = 0;
}
if (player.velocity < -MAX_Y_VELOCITY) {
player.velocity = -MAX_Y_VELOCITY;
}
// for (auto const& plat : stage.platforms) {
for (int i = 0; i < stage.totalplatforms; i++) {
if (player.falling) {
if (!cull(stage.platforms[i])) {
if (collision(stage.platforms[i], -ceil(player.velocity * player.velocitymod))) {
player.y = stage.platforms[i].y - PLAYER_SIZE;
player.falling = false;
player.jumpcharge = true;
player.lastplatform = i;
}
}
} else {
if (!collision(stage.platforms[player.lastplatform], BLOCK_SIZE)) { // If player has been pushed off the platform
player.falling = true;
}
}
}
// X
// Check for player push
if (!player.falling && stage.platforms[player.lastplatform].type == JELLYFISH_PLATFORM) {
if (stage.platforms[player.lastplatform].facingright) {
player.xvelocity = stage.speed / 2.0;
} else {
player.xvelocity = -stage.speed / 2.0;
}
} else if (!player.falling && stage.platforms[player.lastplatform].type == CONVEYOR_PLATFORM) {
// if (arduboy.frameCount % CONVEYOR_SPEED == 0) {
if (stage.platforms[player.lastplatform].facingright) {
player.xvelocity = 1.0 / (5 - stage.speed);
} else {
player.xvelocity = -1.0 / (5 - stage.speed);
}
}
// Velocity applied
if (player.falling || stage.platforms[player.lastplatform].type != REGULAR_PLATFORM) { // Set to 0 when on solid ground
player.x += player.xvelocity;
} else {
player.xvelocity = 0;
}
if (player.xvelocity > 0) { // Decay
player.xvelocity -= X_VELOCITY_DECAY;
} else if (player.xvelocity < 0) {
player.xvelocity += X_VELOCITY_DECAY;
}
if (abs(player.xvelocity) < X_VELOCITY_DECAY) { // Stops tiny pixel movement
player.xvelocity = 0;
}
// Boundaries
if (player.intX() < 0) {
player.x = 0;
player.xvelocity = 0;
} else if (player.intX() + PLAYER_SIZE > WIDTH) {
player.x = WIDTH - PLAYER_SIZE;
player.xvelocity = 0;
}
// Platform movement
for (int k = 0; k < stage.totalplatforms; k++) {
if (stage.platforms[k].type == JELLYFISH_PLATFORM) {
if (stage.platforms[k].facingright) {
stage.platforms[k].x += stage.speed / 2.0;
} else {
stage.platforms[k].x -= stage.speed / 2.0;
}
stage.platforms[k].sprite = stage.platforms[k].facingright;
if (stage.platforms[k].intX() < 0 + BLOCK_SIZE) {
stage.platforms[k].facingright = true;
} else if (stage.platforms[k].intX() + stage.platforms[k].len * BLOCK_SIZE > WIDTH - BLOCK_SIZE) {
stage.platforms[k].facingright = false;
}
} else if (stage.platforms[k].type == CONVEYOR_PLATFORM) {
if (currentstagetimer % (5 - stage.speed) == 0) {
if (stage.platforms[k].facingright) {
if (stage.platforms[k].sprite == 0) {
stage.platforms[k].sprite = 7;
} else {
stage.platforms[k].sprite--;
}
} else {
if (stage.platforms[k].sprite == 7) {
stage.platforms[k].sprite = 0;
} else {
stage.platforms[k].sprite++;
}
}
}
}
}
}
void poison() {
poisonheight -= POISON_SPEED;
if (player.y + PLAYER_SIZE > poisonheight + LEEWAY) {
if (lives > 0) {
lives--;
resetstage();
setupstatus(MISS);
} else {
updatetops();
setupstatus(GAMEOVER);
}
}
}
void zap() {
if (!cullzap(zapfish)) {
Rect playerbox = Rect(player.intX(), player.intY(), PLAYER_SIZE, PLAYER_SIZE);
Rect zapbox = Rect((WIDTH - ZAP_SIZE) / 2, zapfish.y, ZAP_SIZE, ZAP_SIZE);
if (Arduboy2::collide(playerbox, zapbox)) {
nextlevel();
}
}
}
void powerups() {
for (int i = 0; i < stage.totalpowerups; i++) {
if (!cullpup(stage.powerups[i]) && powerupcollision(stage.powerups[i]) && !stage.powerups[i].hidden) {
stage.powerups[i].hidden = true;
sound.tones(powerup_sound);
switch (stage.powerups[i].type) {
case POWERUP_FISH:
player.velocity = 5.5;
player.falling = true;
player.jumpcharge = true;
break;
case POWERUP_JELLY:
player.poweruptimer = POWERUP_TIME;
player.powerupstate = stage.powerups[i].type;
player.velocitymod = 1;
break;
case POWERUP_STAR:
player.poweruptimer = POWERUP_TIME;
player.powerupstate = stage.powerups[i].type;
player.velocitymod = 1.5;
break;
}
}
}
if (player.poweruptimer > 0) {
player.poweruptimer--;
} else {
if (player.powerupstate == POWERUP_STAR && player.velocity > 0 && player.falling) {
player.velocity = 6;
}
player.powerupstate = 0;
player.velocitymod = 1;
}
}
void nextlevel() {
int timemodifier;
if (stage.num < 11) {
stagebonus = 300;
timemodifier = 1;
} else if (stage.num < 21) {
stagebonus = 600;
timemodifier = 2;
} else {
stagebonus = 1000;
timemodifier = 3;
}
if (currentstagetimer < 2400) {
timebonus = ScoreFromFrames(currentstagetimer, timemodifier);
} else {
timebonus = 0;
}
int prevscorelife = score / EXTRA_LIFE;
score += stagebonus + timebonus;
if (score > MAX_SCORE) {
score = MAX_SCORE;
}
int scorelife = score / EXTRA_LIFE;
if (scorelife > prevscorelife && lives < MAX_LIVES) {
lives++;
}
stage.num++;
if (stage.num <= 25) {
resetstage();
setupstatus(GOAL);
} else {
updatetops();
setupstatus(CONGRATS);
}
}
void movecamera() {
// PLayer location on screen player.y + camerapos
// camerapos = (-1 * player.y) + 40;
if (player.intY() + camerapos < CAM_UPPER_BOUNDARY) {
camerapos = -player.intY() + CAM_UPPER_BOUNDARY;
} else if (player.intY() + camerapos > CAM_LOWER_BOUNDARY) {
camerapos = -player.intY() + CAM_LOWER_BOUNDARY;
}
}
bool cull(struct Platform platform) {
return platform.y + camerapos + player.velocity * player.velocitymod > HEIGHT || platform.y + camerapos + BLOCK_SIZE < 0;
}
bool cullpup(struct Powerup powerup) {
return powerup.y + camerapos + player.velocity * player.velocitymod > HEIGHT || powerup.y + camerapos + POWERUP_SIZE < 0;
}
bool cullzap(struct Zapfish zapfish) {
return zapfish.y + camerapos + player.velocity * player.velocitymod > HEIGHT || zapfish.y + camerapos + ZAP_SIZE < 0;
}
bool cullstar(int y) {
return y > HEIGHT || y + STAR_SIZE < 0 || y - camerapos > 48;
}
void drawgame() {
// Background
for (int k = 0; k < NUM_STARS; k++) {
struct Star star = { pgm_read_byte(&stars[k * 3]), pgm_read_byte(&stars[k * 3 + 1]), pgm_read_byte(&stars[k * 3 + 2]) }; // Messy but allows PROGMEM to be used
for (int i = 0; i <= 1; i++) {
int y = star.y + camerapos + stage.staroffset - STAR_WRAP * ((camerapos + stage.staroffset) / STAR_WRAP + i);
if (!cullstar(y)) {
Sprites::drawOverwrite(star.x * 2, y, Star, star.type);
}
}
}
// for (auto& plat : stage.platforms) { // For every platform in platforms
for (int k = 0; k < stage.totalplatforms; k++) {
if (!cull(stage.platforms[k])) {
for (int i = 0; i < stage.platforms[k].len; i++) {
Sprites::drawOverwrite(stage.platforms[k].intX() + i * BLOCK_SIZE, stage.platforms[k].y + camerapos, Block, stage.platforms[k].type + stage.platforms[k].sprite);
}
}
}
for (int i = 0; i < stage.totalpowerups; i++) {
if (!cullpup(stage.powerups[i]) && !stage.powerups[i].hidden) {
Sprites::drawExternalMask(stage.powerups[i].x, stage.powerups[i].y + camerapos, Powerup, Powerup_Mask, stage.powerups[i].type, stage.powerups[i].type);
}
}
if (!cullzap(zapfish)) {
Sprites::drawOverwrite((WIDTH - ZAP_SIZE) / 2, zapfish.y + camerapos, Zap, 0);
}
if (poisonheight + camerapos <= HEIGHT) {
Sprites::drawSelfMasked(0, poisonheight + camerapos, Poison, 0);
}
if (player.charge >= MAX_CHARGE) {
sprite = CHARGE_4;
} else if (player.charge >= MAX_CHARGE / CHARGE_NUM * 2) {
sprite = CHARGE_3;
} else if (player.charge >= MAX_CHARGE / CHARGE_NUM * 1) {
sprite = CHARGE_2;
} else {
sprite = REGULAR;
}
// Draw player
Sprites::drawExternalMask(player.x, player.y + camerapos, Player, Player_Mask, sprite, sprite);
if (player.powerupstate == POWERUP_JELLY || player.powerupstate == POWERUP_STAR) {
Sprites::drawSelfMasked(player.x - 1, player.y - 1 + camerapos, Sparkle, (currentstagetimer % 20) / 10);
}
}
void gameplay() {
currentstagetimer++;
gameinput();
poison();
zap();
powerups();
physics();
movecamera();
if (gamestate == GAME_PLAY || gamestate == GAME_PAUSE) { // Prevents flashes when going to status screen (pause to prevent screen being wiped)
drawgame();
}
}
void updatetops() {
bool saveneeded = false;
if (stage.num > toplevel) {
toplevel = stage.num;
saveneeded = true;
}
if (score > topscore) {
topscore = score;
saveneeded = true;
}
if (saveneeded) {
saveEEPROM();
}
}
void pause() {
if (arduboy.justPressed(B_BUTTON)) {
gamestate = GAME_PLAY;
quittimer = 0;
}
if (arduboy.pressed(UP_BUTTON)) {
quittimer++;
} else {
quittimer = 0;
}
if (quittimer >= 4 * 60) {
updatetops();
setupstatus(GAMEOVER);
quittimer = 0;
} else if (quittimer > 30 && quittimer % 60 >= 0 && quittimer % 60 <= 14) {
if (led) {
arduboy.digitalWriteRGB(RGB_ON, RGB_OFF, RGB_ON);
}
if (quittimer % 60 == 0) {
sound.tones(powerup_sound);
}
} else {
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF);
}
// if (arduboy.justPressed(UP_BUTTON)) {
// lives++;
// } else if (arduboy.justPressed(DOWN_BUTTON)) {
// lives--;
// } else if (arduboy.justPressed(LEFT_BUTTON)) {
// stage.num--;
// } else if (arduboy.justPressed(RIGHT_BUTTON)) {
// stage.num++;
// }
arduboy.fillRect((WIDTH - 6 * CHAR_WIDTH) / 2 - PAUSE_PADDING - 1, (HEIGHT - CHAR_HEIGHT) / 2 - PAUSE_PADDING - 1, CHAR_WIDTH * 6 + 2 * (PAUSE_PADDING + 1), CHAR_HEIGHT + 2 * (PAUSE_PADDING + 1), WHITE);
arduboy.fillRect((WIDTH - 6 * CHAR_WIDTH) / 2 - PAUSE_PADDING, (HEIGHT - CHAR_HEIGHT) / 2 - PAUSE_PADDING, CHAR_WIDTH * 6 + 2 * PAUSE_PADDING, CHAR_HEIGHT + 2 * PAUSE_PADDING, BLACK);
setcursor((WIDTH - 6 * CHAR_WIDTH) / 2, (HEIGHT - CHAR_HEIGHT) / 2);
squidprint("PAUSED");
}
void gameloop() {
switch (gamestate) {
case GAME_TITLE:
titlescreen();
break;
case GAME_PLAY:
gameplay();
break;
case GAME_STATUS:
gamestatus();
break;
case GAME_PAUSE:
pause();
break;
}
}
void setup() {
arduboy.begin();
arduboy.setFrameRate(60);
arduboy.display();
arduboy.initRandomSeed();
arduboy.clear();
initEEPROM();
}
void loop() {
if (!(arduboy.nextFrame())) {
return;
}
setcursor(0, 0);
arduboy.pollButtons();
if (gamestate != GAME_PAUSE) {
arduboy.clear();
}
gameloop();
arduboy.display();
}