-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.cpp
379 lines (343 loc) · 18.4 KB
/
graphics.cpp
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
#include "graphics.h"
#include "globals.h"
//TODO: Buffer of entire screen and checking whether there was a change pixel-by-pixel
static int player_sprite_right[121] = {
0x000000, 0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000,
0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000,
0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000,
0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000
};
static int player_sprite_left[121];
static int player_sprite_up[121];
static int player_sprite_down[121];
static int player_sprite_with_key[121] = {
0x000000, 0x000000, 0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000,
0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000,
0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000,
0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000,
0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000,
0x000000, 0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0xff00ff, 0x000000, 0x000000, 0x000000
};
static int wall_sprite[121] = {
0x0089ff, 0x0e77d2, 0x0089ff, 0x0089ff, 0x000000, 0x0089ff, 0x0089ff, 0x1d7aec, 0x0089ff, 0x000000, 0x0e77d2,
0x0089ff, 0x0089ff, 0x1d7aec, 0x1d7aec, 0x000000, 0x0089ff, 0x0e77d2, 0x0089ff, 0x0089ff, 0x000000, 0x0089ff,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x0089ff, 0x000000, 0x0089ff, 0x1d7aec, 0x0089ff, 0x0e77d2, 0x000000, 0x0089ff, 0x0e77d2, 0x0089ff, 0x0089ff,
0x0089ff, 0x000000, 0x0089ff, 0x0089ff, 0x0e77d2, 0x0089ff, 0x000000, 0x0089ff, 0x0089ff, 0x1d7aec, 0x0e77d2,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x0089ff, 0x0e77d2, 0x0089ff, 0x0089ff, 0x000000, 0x0089ff, 0x0e77d2, 0x0089ff, 0x1d7aec, 0x000000, 0x0089ff,
0x1d7aec, 0x0089ff, 0x0089ff, 0x0e77d2, 0x000000, 0x0089ff, 0x0089ff, 0x0e77d2, 0x0089ff, 0x000000, 0x1d7aec,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x1d7aec, 0x000000, 0x0e77d2, 0x0089ff, 0x0089ff, 0x1d7aec, 0x000000, 0x0089ff, 0x0e77d2, 0x0089ff, 0x0089ff,
0x0089ff, 0x000000, 0x0089ff, 0x0089ff, 0x0e77d2, 0x0089ff, 0x000000, 0x1d7aec, 0x0089ff, 0x0089ff, 0x0e77d2
};
static int dot_sprite[121] = {
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000,
0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000,
0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};
static int ghost_sprite_red[121] = {
0x000000, 0x000000, 0x000000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0x000000, 0x000000,
0x000000, 0xff0000, 0xff0000, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xff0000, 0xff0000, 0x000000,
0x000000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0x000000,
0xff0000, 0xff0000, 0x000000, 0xffffff, 0xffffff, 0xff0000, 0x000000, 0xffffff, 0xffffff, 0xff0000, 0xff0000,
0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xff0000, 0xff0000, 0xff0000,
0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000,
0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000,
0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000,
0xff0000, 0xff0000, 0xff0000, 0x000000, 0xff0000, 0xff0000, 0xff0000, 0x000000, 0xff0000, 0xff0000, 0xff0000,
0x000000, 0xff0000, 0x000000, 0x000000, 0x000000, 0xff0000, 0x000000, 0x000000, 0x000000, 0xff0000, 0x000000
};
static int ghost_sprite_yellow[121] = {
0x000000, 0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0x000000,
0x000000, 0xffff00, 0xffff00, 0xffffff, 0xffff00, 0xffff00, 0xffff00, 0xffffff, 0xffff00, 0xffff00, 0x000000,
0x000000, 0xffff00, 0xffffff, 0xffffff, 0xffffff, 0xffff00, 0xffffff, 0xffffff, 0xffffff, 0xffff00, 0x000000,
0xffff00, 0xffff00, 0x000000, 0xffffff, 0xffffff, 0xffff00, 0x000000, 0xffffff, 0xffffff, 0xffff00, 0xffff00,
0xffff00, 0xffff00, 0xffff00, 0xffffff, 0xffff00, 0xffff00, 0xffff00, 0xffffff, 0xffff00, 0xffff00, 0xffff00,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00,
0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00, 0xffff00,
0xffff00, 0xffff00, 0xffff00, 0x000000, 0xffff00, 0xffff00, 0xffff00, 0x000000, 0xffff00, 0xffff00, 0xffff00,
0x000000, 0xffff00, 0x000000, 0x000000, 0x000000, 0xffff00, 0x000000, 0x000000, 0x000000, 0xffff00, 0x000000
};
static int ghost_sprite_aqua[121] = {
0x000000, 0x000000, 0x000000, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x000000, 0x000000,
0x000000, 0x00ffff, 0x00ffff, 0xffffff, 0x00ffff, 0x00ffff, 0x00ffff, 0xffffff, 0x00ffff, 0x00ffff, 0x000000,
0x000000, 0x00ffff, 0xffffff, 0xffffff, 0xffffff, 0x00ffff, 0xffffff, 0xffffff, 0xffffff, 0x00ffff, 0x000000,
0x00ffff, 0x00ffff, 0x000000, 0xffffff, 0xffffff, 0x00ffff, 0x000000, 0xffffff, 0xffffff, 0x00ffff, 0x00ffff,
0x00ffff, 0x00ffff, 0x00ffff, 0xffffff, 0x00ffff, 0x00ffff, 0x00ffff, 0xffffff, 0x00ffff, 0x00ffff, 0x00ffff,
0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff,
0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff,
0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff, 0x00ffff,
0x00ffff, 0x00ffff, 0x00ffff, 0x000000, 0x00ffff, 0x00ffff, 0x00ffff, 0x000000, 0x00ffff, 0x00ffff, 0x00ffff,
0x000000, 0x00ffff, 0x000000, 0x000000, 0x000000, 0x00ffff, 0x000000, 0x000000, 0x000000, 0x00ffff, 0x000000
};
static int ghost_sprite_blue[121] = {
0x000000, 0x000000, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x000000,
0x000000, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x000000,
0x000000, 0x0000ff, 0x000000, 0x000000, 0x000000, 0x0000ff, 0x000000, 0x000000, 0x000000, 0x0000ff, 0x000000,
0x0000ff, 0x0000ff, 0xffffff, 0x000000, 0x000000, 0x0000ff, 0xffffff, 0x000000, 0x000000, 0x0000ff, 0x0000ff,
0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff,
0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff,
0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff,
0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff, 0x0000ff,
0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff, 0x000000, 0x0000ff, 0x0000ff, 0x0000ff,
0x000000, 0x0000ff, 0x000000, 0x000000, 0x000000, 0x0000ff, 0x000000, 0x000000, 0x000000, 0x0000ff, 0x000000
};
static int portal_sprite[121] = {
0x000000, 0x000000, 0x000000, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x000000, 0x000000,
0x000000, 0x2008db, 0x2008db, 0x7b6bf3, 0x7b6bf3, 0x7b6bf3, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db, 0x000000,
0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db,
0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db,
0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db,
0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db,
0x7b6bf3, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db,
0x000000, 0x2008db, 0x2008db, 0x2008db, 0x7b6bf3, 0x7b6bf3, 0x7b6bf3, 0x2008db, 0x2008db, 0x2008db, 0x000000,
0x000000, 0x000000, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x2008db, 0x000000, 0x000000, 0x000000
};
static int prize_sprite[121] = {
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffee00, 0xffee00, 0xffee00, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffee00, 0xffee00, 0x000000, 0xffee00, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xff0000, 0xff0000, 0x000000, 0x000000, 0x000000, 0xffee00, 0x000000, 0x000000, 0x000000,
0x000000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0x000000, 0xff0000, 0xff0000, 0x000000, 0x000000, 0x000000,
0x000000, 0xff0000, 0xff0000, 0xff0000, 0xff7e7e, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0x000000, 0x000000,
0x000000, 0x000000, 0xff7e7e, 0xff7e7e, 0x000000, 0xff0000, 0xff0000, 0xff0000, 0xff7e7e, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xff7e7e, 0xff7e7e, 0x000000, 0x000000, 0x000000
};
void draw_player(int u, int v, int key, int dir)
{
switch (dir) {
case 0:
uLCD.BLIT(u, v, 11, 11, player_sprite_right);
break;
case 1:
uLCD.BLIT(u, v, 11, 11, player_sprite_down);
break;
case 2:
uLCD.BLIT(u, v, 11, 11, player_sprite_left);
break;
case 3:
uLCD.BLIT(u, v, 11, 11, player_sprite_up);
break;
}
}
void draw_ghost(int u, int v, int color, int fleeing)
{
if (fleeing) {
uLCD.BLIT(u, v, 11, 11, ghost_sprite_blue);
return;
}
switch (color) {
case 0:
uLCD.BLIT(u, v, 11, 11, ghost_sprite_red);
break;
case 1:
uLCD.BLIT(u, v, 11, 11, ghost_sprite_yellow);
break;
case 2:
uLCD.BLIT(u, v, 11, 11, ghost_sprite_aqua);
break;
}
}
void init_sprites() {
flip_lr(player_sprite_right, player_sprite_left);
transpose(player_sprite_right, player_sprite_down);
flip_ud(player_sprite_down, player_sprite_up);
}
void add_key_to_player() {
copy(player_sprite_with_key, player_sprite_right);
init_sprites();
}
void transpose(int *sprite, int *out)
{
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
out[i*11+j] = sprite[j*11+i];
}
}
}
void flip_lr(int *sprite, int *out)
{
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
out[i*11+10-j] = sprite[i*11+j];
}
}
}
void flip_ud(int *sprite, int *out)
{
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
out[(10-i)*11+j] = sprite[i*11+j];
}
}
}
void copy(int *sprite, int *out) {
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
out[i*11+j] = sprite[i*11+j];
}
}
}
// The following colors are defined in uLCD_4DGL.h:
// WHITE, BLACK, RED, GREEN, BLUE, LGREY, DGREY
#define YELLOW 0xFFFF00
#define BROWN 0xD2691E
#define DIRT BROWN
void draw_img(int u, int v, const char* img)
{
int colors[11*11];
for (int i = 0; i < 11*11; i++)
{
if (img[i] == 'R') colors[i] = RED;
else if (img[i] == 'Y') colors[i] = YELLOW;
else if (img[i] == 'G') colors[i] = GREEN;
else if (img[i] == 'D') colors[i] = DIRT;
else if (img[i] == '5') colors[i] = LGREY;
else if (img[i] == '3') colors[i] = DGREY;
else colors[i] = BLACK;
}
uLCD.BLIT(u, v, 11, 11, colors);
wait_us(250); // Recovery time!
}
void draw_nothing(int u, int v)
{
// Fill a tile with blackness
uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
}
void draw_wall(int u, int v)
{
uLCD.BLIT(u, v, 11, 11, wall_sprite);
}
void draw_dot(int u, int v)
{
//uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
//uLCD.filled_circle(u+5, v+5, 3, WHITE);
uLCD.BLIT(u, v, 11, 11, dot_sprite);
}
void draw_tree(int u, int v)
{
uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
uLCD.pixel(u+5, v+5, WHITE);
}
void draw_portal(int u, int v)
{
uLCD.BLIT(u, v, 11, 11, portal_sprite);
}
void draw_prize(int u, int v) {
uLCD.BLIT(u, v, 11, 11, prize_sprite);
}
void draw_door(int u, int v) {
uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
uLCD.filled_rectangle(u, v+4, u+10, v+6, YELLOW);
}
void draw_upper_status(int x, int y, int isOmni, int map, int power, int fleeing, int questState)
{
// Draw bottom border of status bar
uLCD.line(0, 9, 127, 9, BLUE);
// Add other status info drawing code here
if (isOmni) {
uLCD.filled_rectangle(0, 0, 127, 8, RED);
} else {
uLCD.filled_rectangle(0, 0, 127, 8, BLACK);
}
uLCD.locate(0,0);
uLCD.color(WHITE);
uLCD.set_font(FONT_7X8);
uLCD.text_mode(TRANSPARENT);
uLCD.text_width(1);
uLCD.text_height(1);
if (map == 0)
uLCD.printf("(%D,%D) Power:%D", x, y, power);
else if (map == 1) {
if (questState == 2)
uLCD.printf("(%D,%D) EXIT", x, y);
else if (fleeing)
uLCD.printf("(%D,%D) CHASE %Ds", x, y, fleeing / 10);
else
uLCD.printf("(%D,%D) RUN", x, y);
}
}
void draw_lower_status(int map)
{
// Draw top border of status bar
uLCD.line(0, 118, 127, 118, BLUE);
uLCD.filled_rectangle(0, 119, 127, 127, BLACK);
// Add other status info drawing code here
uLCD.locate(0,15);
uLCD.color(WHITE);
uLCD.set_font(FONT_7X8);
uLCD.text_mode(TRANSPARENT);
uLCD.text_width(1);
uLCD.text_height(1);
uLCD.printf("%S Map", map ? "Quest" : "Main");
}
void draw_border()
{
uLCD.filled_rectangle(0, 9, 127, 14, YELLOW); // Top
uLCD.filled_rectangle(0, 13, 2, 114, YELLOW); // Left
uLCD.filled_rectangle(0, 114, 127, 117, YELLOW); // Bottom
uLCD.filled_rectangle(124, 14, 127, 117, YELLOW); // Right
}
void draw_dead() {
uLCD.text_width(2);
uLCD.text_height(2);
uLCD.color(RED);
uLCD.text_mode(TRANSPARENT);
uLCD.locate(3,2);
uLCD.printf("YOU");
uLCD.locate(3,3);
uLCD.printf("DIED");
uLCD.text_width(1);
uLCD.text_height(1);
uLCD.locate(2,9);
uLCD.printf("RESPAWNING IN");
uLCD.text_mode(OPAQUE);
uLCD.text_width(2);
uLCD.text_height(2);
for (int i = 3; i > 0; i--) {
uLCD.locate(4,5);
uLCD.printf("%D", i);
wait_ms(1000);
}
}
void draw_game_over() {
uLCD.text_width(2);
uLCD.text_height(2);
uLCD.color(GREEN);
uLCD.text_mode(TRANSPARENT);
uLCD.locate(3,2);
uLCD.printf("GAME");
uLCD.locate(3,3);
uLCD.printf("OVER");
}