-
Notifications
You must be signed in to change notification settings - Fork 1
/
Zuthsrah.ino
129 lines (110 loc) · 2.65 KB
/
Zuthsrah.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
#include <SPI.h>
#include <EEPROM.h>
#include "Arduboy.h"
#include "bitmaps.h"
#include "Character.h"
#include "Weapons.h"
#include "Starz.h"
#include "Enemies.h"
bool gameState = 1;
uint8_t i = 0;
Arduboy display;
Weapons weapon;
Enemies enemy;
Starz starz;
Character belknar( Rect{32, 64 , 8, 8});
void setup() {
SPI.begin();
display.start();
display.setTextSize(1);
display.clearDisplay();
//intro bitmap
introFade();
//display.tunes.playScore(score);
}
void loop() {
if (!(display.nextFrame())) {
return;
}
if (gameState) {
// count frames
weapon.countFrames++;
//active background starz
starz.activate(&display);
// disply kill count
killCountDisplay (belknar.killCount);
// enable directions to be implemented
belknar.enableMovement(&belknar, &display, ship);
// enable weapon system (at least A BUTTON for now)
belknar.activateWeapons( &display, bomb);
// initalize attack phases
enemy.initEnemies(&enemy.level, &weapon, &enemy, i, &belknar, &display, star, &gameState);
display.display();
display.clearDisplay();
} else {
gameOver();
}
if (!display.tunes.playing()) {
//display.tunes.playScore(score);
}
}
//isimple intro bitmap with fade effect
void introFade() {
display.clearDisplay();
display.drawBitmap(1, 1, mreData, 128, 64, WHITE);
display.display();
delay(2000);
for (int x = 15; x < 140; x++ ) {
for (int y = 0; y < 64; y++) {
display.drawPixel(x, y, 0);
}
display.display();
delay(5);
}
delay(1000);
display.clearDisplay();
}
void killCountDisplay(unsigned short x) {
display.setCursor(64, 5);
display.print(x);
}
void killCountDisplayGM(uint8_t x) {
display.setCursor(58, 50);
display.print(x);
}
void gameOver() {
display.tunes.stopScore();
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 22);
display.write('G');
display.setCursor(15, 22);
display.write('A');
display.setCursor(30, 22);
display.write('M');
display.setCursor(45, 22);
display.write('E');
display.setCursor(70, 22);
display.write('O');
display.setCursor(85, 22);
display.write('V');
display.setCursor(100, 22);
display.write('E');
display.setCursor(115, 22);
display.write('R');
killCountDisplayGM(belknar.killCount);
display.display();
resetGame();
}
void resetGame(){
if (display.pressed(A_BUTTON) && display.pressed(B_BUTTON )){ // press A+B to start new game
gameState = 1;
belknar.killCount = 0;
Enemies newEnemy;
enemy = newEnemy;
Character newBelknar( Rect{32, 64 , 8, 8});
newBelknar.killCount = 0;
belknar = newBelknar;
display.setTextSize(1);
}
}