-
Notifications
You must be signed in to change notification settings - Fork 2
/
nonstandard.ino
93 lines (93 loc) · 2.36 KB
/
nonstandard.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
//----------------------------------------------------------------------------
void newgame() {
score=0;
lives=3;
gamelevel=0;
shipx=40;
shotx=-1;
shoty=-1;
deadcounter=-1;
saucers=-1;
for (int i = 0 ; i<4 ; i++) {
invadershotx[i]=-1;
invadershoty[i]=-1;
}
gamestatus="newlevel";
}
//----------------------------------------------------------------------------
void newlevel() {
invaderanz=40;
invaderctr=39;
invaderxr=2;
invaderyr=0;
checkdir=0;
nextxdir=2;
nextydir=0;
yeahtimer=0;
delayBip=0;
invadershottimer=60;
saucertimer=240;
int down=gamelevel*2;
if (gamelevel>8) { down=16; }
for (int i = 0; i < 8 ; i++) {
invaderx[i]=10+i*8;
invaderx[i+8]=10+i*8;
invaderx[i+16]=10+i*8;
invaderx[i+24]=10+i*8;
invaderx[i+32]=10+i*8;
invadery[i]=0+down;
invadery[i+8]=6+down;
invadery[i+16]=12+down;
invadery[i+24]=18+down;
invadery[i+32]=24+down;
invaders[i]=4;
invaders[i+8]=2;
invaders[i+16]=2;
invaders[i+24]=0;
invaders[i+32]=0;
invaderframe[i]=0;
invaderframe[i+8]=0;
invaderframe[i+16]=0;
invaderframe[i+24]=0;
invaderframe[i+32]=0;
}
for (int i=0; i < 4 ; i++) {
bunkers[i]=0;
if (gamelevel>5) { bunkers[i]=-1; }
}
gamestatus="running";
}
//----------------------------------------------------------------------------
void showscore() {
if (infoshow==1 and saucers==-1) {
gb.display.setColor(WHITE);
if (lives>1) { gb.display.drawBitmap(0,0,playership[0]); }
if (lives>2) { gb.display.drawBitmap(9,0,playership[0]); }
gb.display.cursorX=42-2*(score>9)-2*(score>99)-2*(score>999);
gb.display.cursorY=0;
gb.display.print(score);
gb.display.cursorX=72;
gb.display.print(gamelevel+1);
}
}
//----------------------------------------------------------------------------
void nextlevelcheck() {
// increment timer after all invaders killed
if (invaderanz==0) {
yeahtimer=++yeahtimer;
if (yeahtimer>=90) {
gamelevel=++gamelevel;
gamestatus="newlevel";
}
}
}
//----------------------------------------------------------------------------
void handledeath() {
deadcounter=--deadcounter;
if (deadcounter == 0) {
deadcounter=-1;
lives=--lives;
shipx=0;
if (lives == 0) { gamestatus = "gameover"; }
}
}