forked from taylorwentzel/eclipse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.c
executable file
·73 lines (64 loc) · 2.15 KB
/
draw.c
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
#include "draw.h"
#include "gba.h"
#include "gameBackground.h"
#include "deathScreen.h"
#include <stdio.h>
#include <stdlib.h>
void fullDrawAppState(AppState *state) {
hideSelector();
drawFullScreenImageDMA(gameBackground);
drawShip(state->shipX, state->shipY);
drawSprites();
char buffer[51];
sprintf(buffer, "Score: %d", state->score);
drawString(1, 150, buffer, WHITE);
char buff[51];
sprintf(buff, "Lives: %d", state->lives);
drawString(190, 150, buff, WHITE);
}
void undrawAppState(AppState *state, AppState *next) {
if (state->score != next->score) {
undrawScore(1, 150, BLACK);
}
if (state->lives != next->lives) {
undrawLives(BLACK);
}
}
void drawAppState(AppState *curr, AppState *state) {
for (int i = 0; i < NO_MISSILES; i++) {
if (state->shots[i].mY < 155 && state->shots[i].mY > 0) {
drawMissile(state->shots[i].mX, state->shots[i].mY, YELLOW);
if (state->gameOver) {
undrawMissile(state->shots[i].mX, state->shots[i].mY, deathScreen);
} else {
undrawMissile(state->shots[i].mX, state->shots[i].mY, gameBackground);
}
} else {
clearMissile(state->shots[i].mX, gameBackground);
}
}
//draw score
if (curr->score != state->score || state->gameOver) {
char buffer[51];
sprintf(buffer, "Score: %d", state->score);
drawString(1, 150, buffer, WHITE);
}
//draw lives
if (curr->lives != state->lives || state->gameOver) {
char buff[51];
sprintf(buff, "Lives: %d", state->lives);
drawString(190, 150, buff, WHITE);
}
if (state->justDied || state->gameOver) {
hideShip();
} else {
drawShip(state->shipX, state->shipY);
}
drawEnemy0(state->baddies[0].enemyX, state->baddies[0].enemyY);
drawEnemy1(state->baddies[1].enemyX, state->baddies[1].enemyY);
drawEnemy2(state->baddies[2].enemyX, state->baddies[2].enemyY);
drawEnemy3(state->baddies[3].enemyX, state->baddies[3].enemyY);
drawEnemy4(state->baddies[4].enemyX, state->baddies[4].enemyY);
drawSprites();
delay(1);
}