-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.c
94 lines (84 loc) · 2.58 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "draw.h"
#include "gba.h"
#include "logic.h"
#include <stdio.h>
#include "images/title.h"
#include "images/player.h"
#include "images/boss.h"
#include "images/bullet.h"
#include "images/lose.h"
#include "images/laser.h"
void drawTitleScreen(void) {
drawFullScreenImageDMA(title);
}
void drawTitleMessage(void) {
char message1[] = "PRESS ANY KEY";
char message2[] = "TO START";
drawString(HEIGHT / 4, WIDTH / 14, message1, WHITE);
drawString(HEIGHT / 4 + 20, WIDTH / 14, message2, WHITE);
}
void drawGameBackground(void) {
fillScreenDMA(BLUE);
return;
}
void drawLoseScreen(long long score) {
if (score != 0) {
drawFullScreenImageDMA(lose);
char message1[] = "YOU GOT HIT!";
char message2[] = "FINAL SCORE: ";
char fscore[256];
sprintf(fscore, "%lld", score);
drawString(HEIGHT / 2 - 20, WIDTH / 2 - 40, message1, WHITE);
drawString(HEIGHT / 2, WIDTH / 2 - 40, message2, WHITE);
drawCenteredString(HEIGHT / 2 + 20, WIDTH / 2 - 25, 40, 10, fscore, WHITE);
return;
}
}
void drawWinMessage(void) {
char message1[] = "CONGRATULATIONS!";
char message2[] = "YOU SAVED THE UNIVERSE!";
drawCenteredString(HEIGHT / 2 - 20, WIDTH / 2 - 20, 40, 10, message1, WHITE);
drawCenteredString(HEIGHT / 2, WIDTH / 2 - 20, 40, 10, message2, WHITE);
}
void updatePlayer(int nrow, int ncol, int orow, int ocol) {
if (orow != -1) {
drawRectDMA(orow, ocol, PWIDTH, PHEIGHT, BLUE);
}
drawImageDMA(nrow, ncol, PWIDTH, PHEIGHT, player);
}
// There's some bug where the boss leaves a couple pixels behind but apparently it's ok to ignore
void updateBoss(int nrow, int ncol, int orow, int ocol) {
if (orow != -1) {
drawRectDMA(orow, ocol, BWIDTH + 1, BHEIGHT + 1, BLUE);
}
drawImageDMA(nrow, ncol, BWIDTH, BHEIGHT, boss);
}
void updateBullet(int nrow, int ncol, int orow, int ocol) {
if (orow != -1) {
drawRectDMA(orow, ocol, buWIDTH + 1, buHEIGHT + 1, BLUE);
}
if (nrow != -1) {
drawImageDMA(nrow, ncol, buWIDTH, buHEIGHT, bullet);
}
}
void updateLaser(int nrow, int ncol, int orow, int ocol) {
if (orow != -1) {
drawRectDMA(orow, ocol, LWIDTH, LHEIGHT, BLUE);
}
if (nrow != -1) {
drawImageDMA(nrow, ncol, LWIDTH, LHEIGHT, laser);
}
}
void drawDamage(int row, int col) {
drawRectDMA(row, col, 4, 4, BLUE);
}
void drawScore(long long score, long long prevscore) {
char cur[256];
sprintf(cur, "%lld", score); // converting long long to str
if (score != 1) {
char prev[256];
sprintf(prev, "%lld", prevscore);
drawString(5, WIDTH - 30, prev, BLUE);
}
drawString(5, WIDTH - 30, cur, BLACK);
}