baseline features - a little buggy
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
graphics.cpp@0:95264f964374, 2021-03-29 (annotated)
- Committer:
- DCchico
- Date:
- Mon Mar 29 21:17:26 2021 -0400
- Revision:
- 0:95264f964374
- Child:
- 1:4421c1e849e9
inital commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DCchico |
0:95264f964374 | 1 | #include "graphics.h" |
DCchico |
0:95264f964374 | 2 | #include "globals.h" |
DCchico |
0:95264f964374 | 3 | |
DCchico |
0:95264f964374 | 4 | #define YELLOW 0xFFFF00 |
DCchico |
0:95264f964374 | 5 | #define GREEN 0x00FF00 |
DCchico |
0:95264f964374 | 6 | #define WHITE 0xFFFFFF |
DCchico |
0:95264f964374 | 7 | #define BLACK 0x000000 |
DCchico |
0:95264f964374 | 8 | #define BROWN 0xD2691E |
DCchico |
0:95264f964374 | 9 | #define DIRT BROWN |
DCchico |
0:95264f964374 | 10 | #define RED 0xFF0000 |
DCchico |
0:95264f964374 | 11 | #define ORANGE 0xFFA500 |
DCchico |
0:95264f964374 | 12 | void draw_img(int u, int v, const char* img) |
DCchico |
0:95264f964374 | 13 | { |
DCchico |
0:95264f964374 | 14 | int colors[11*11]; |
DCchico |
0:95264f964374 | 15 | for (int i = 0; i < 11*11; i++) |
DCchico |
0:95264f964374 | 16 | { |
DCchico |
0:95264f964374 | 17 | if (img[i] == 'R') colors[i] = RED; |
DCchico |
0:95264f964374 | 18 | else if (img[i] == 'Y') colors[i] = YELLOW; |
DCchico |
0:95264f964374 | 19 | else if (img[i] == 'G') colors[i] = GREEN; |
DCchico |
0:95264f964374 | 20 | else if (img[i] == 'D') colors[i] = DIRT; |
DCchico |
0:95264f964374 | 21 | // else if (img[i] == '5') colors[i] = LGREY; |
DCchico |
0:95264f964374 | 22 | // else if (img[i] == '3') colors[i] = DGREY; |
DCchico |
0:95264f964374 | 23 | else colors[i] = BLACK; |
DCchico |
0:95264f964374 | 24 | } |
DCchico |
0:95264f964374 | 25 | uLCD.BLIT(u, v, 11, 11, colors); |
DCchico |
0:95264f964374 | 26 | wait_us(250); // Recovery time! |
DCchico |
0:95264f964374 | 27 | } |
DCchico |
0:95264f964374 | 28 | |
DCchico |
0:95264f964374 | 29 | void draw_player(int u, int v, int key) |
DCchico |
0:95264f964374 | 30 | { |
DCchico |
0:95264f964374 | 31 | uLCD.filled_rectangle(u, v, u+11, v+11, WHITE); |
DCchico |
0:95264f964374 | 32 | } |
DCchico |
0:95264f964374 | 33 | |
DCchico |
0:95264f964374 | 34 | void draw_nothing(boundingBox b) |
DCchico |
0:95264f964374 | 35 | { |
DCchico |
0:95264f964374 | 36 | // Erase a bounding box |
DCchico |
0:95264f964374 | 37 | uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, BLACK); |
DCchico |
0:95264f964374 | 38 | } |
DCchico |
0:95264f964374 | 39 | |
DCchico |
0:95264f964374 | 40 | void draw_bomb(boundingBox b) |
DCchico |
0:95264f964374 | 41 | { |
DCchico |
0:95264f964374 | 42 | // Draw an apple using a filled_rectangle or get creative and use a sprite! |
DCchico |
0:95264f964374 | 43 | uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, RED); |
DCchico |
0:95264f964374 | 44 | } |
DCchico |
0:95264f964374 | 45 | |
DCchico |
0:95264f964374 | 46 | void draw_banana(boundingBox b) |
DCchico |
0:95264f964374 | 47 | { |
DCchico |
0:95264f964374 | 48 | // Draw a banana using a filled_rectangle or get creative and use a sprite! |
DCchico |
0:95264f964374 | 49 | uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, YELLOW); |
DCchico |
0:95264f964374 | 50 | } |
DCchico |
0:95264f964374 | 51 | |
DCchico |
0:95264f964374 | 52 | void draw_orange(boundingBox b) |
DCchico |
0:95264f964374 | 53 | { |
DCchico |
0:95264f964374 | 54 | // Draw an orange using a filled_rectangle or get creative and use a sprite! |
DCchico |
0:95264f964374 | 55 | uLCD.filled_rectangle(b.topLeft.x, b.topLeft.y, b.bottomRight.x, b.bottomRight.y, ORANGE); |
DCchico |
0:95264f964374 | 56 | } |