Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
rconnorlawson
Date:
Fri Mar 30 17:07:25 2018 +0000
Revision:
0:35660d7952f7
Child:
4:37d3935365f8
Hollowed out shell code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rconnorlawson 0:35660d7952f7 1 #include "graphics.h"
rconnorlawson 0:35660d7952f7 2
rconnorlawson 0:35660d7952f7 3 #include "globals.h"
rconnorlawson 0:35660d7952f7 4
rconnorlawson 0:35660d7952f7 5
rconnorlawson 0:35660d7952f7 6
rconnorlawson 0:35660d7952f7 7 void draw_player(int u, int v, int key)
rconnorlawson 0:35660d7952f7 8 {
rconnorlawson 0:35660d7952f7 9 uLCD.filled_rectangle(u, v, u+11, v+11, RED);
rconnorlawson 0:35660d7952f7 10 }
rconnorlawson 0:35660d7952f7 11
rconnorlawson 0:35660d7952f7 12 #define YELLOW 0xFFFF00
rconnorlawson 0:35660d7952f7 13 #define BROWN 0xD2691E
rconnorlawson 0:35660d7952f7 14 #define DIRT BROWN
rconnorlawson 0:35660d7952f7 15 void draw_img(int u, int v, const char* img)
rconnorlawson 0:35660d7952f7 16 {
rconnorlawson 0:35660d7952f7 17 int colors[11*11];
rconnorlawson 0:35660d7952f7 18 for (int i = 0; i < 11*11; i++)
rconnorlawson 0:35660d7952f7 19 {
rconnorlawson 0:35660d7952f7 20 if (img[i] == 'R') colors[i] = RED;
rconnorlawson 0:35660d7952f7 21 else if (img[i] == 'Y') colors[i] = YELLOW;
rconnorlawson 0:35660d7952f7 22 else if (img[i] == 'G') colors[i] = GREEN;
rconnorlawson 0:35660d7952f7 23 else if (img[i] == 'D') colors[i] = DIRT;
rconnorlawson 0:35660d7952f7 24 else if (img[i] == '5') colors[i] = LGREY;
rconnorlawson 0:35660d7952f7 25 else if (img[i] == '3') colors[i] = DGREY;
rconnorlawson 0:35660d7952f7 26 else colors[i] = BLACK;
rconnorlawson 0:35660d7952f7 27 }
rconnorlawson 0:35660d7952f7 28 uLCD.BLIT(u, v, 11, 11, colors);
rconnorlawson 0:35660d7952f7 29 wait_us(250); // Recovery time!
rconnorlawson 0:35660d7952f7 30 }
rconnorlawson 0:35660d7952f7 31
rconnorlawson 0:35660d7952f7 32 void draw_nothing(int u, int v)
rconnorlawson 0:35660d7952f7 33 {
rconnorlawson 0:35660d7952f7 34 // Fill a tile with blackness
rconnorlawson 0:35660d7952f7 35 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
rconnorlawson 0:35660d7952f7 36 }
rconnorlawson 0:35660d7952f7 37
rconnorlawson 0:35660d7952f7 38 void draw_wall(int u, int v)
rconnorlawson 0:35660d7952f7 39 {
rconnorlawson 0:35660d7952f7 40 uLCD.filled_rectangle(u, v, u+10, v+10, BROWN);
rconnorlawson 0:35660d7952f7 41 }
rconnorlawson 0:35660d7952f7 42
rconnorlawson 0:35660d7952f7 43 void draw_plant(int u, int v)
rconnorlawson 0:35660d7952f7 44 {
rconnorlawson 0:35660d7952f7 45 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
rconnorlawson 0:35660d7952f7 46 }
rconnorlawson 0:35660d7952f7 47
rconnorlawson 0:35660d7952f7 48 void draw_upper_status()
rconnorlawson 0:35660d7952f7 49 {
rconnorlawson 0:35660d7952f7 50 // Draw bottom border of status bar
rconnorlawson 0:35660d7952f7 51 uLCD.line(0, 9, 127, 9, GREEN);
rconnorlawson 0:35660d7952f7 52
rconnorlawson 0:35660d7952f7 53 // Add other status info drawing code here
rconnorlawson 0:35660d7952f7 54 }
rconnorlawson 0:35660d7952f7 55
rconnorlawson 0:35660d7952f7 56 void draw_lower_status()
rconnorlawson 0:35660d7952f7 57 {
rconnorlawson 0:35660d7952f7 58 // Draw top border of status bar
rconnorlawson 0:35660d7952f7 59 uLCD.line(0, 118, 127, 118, GREEN);
rconnorlawson 0:35660d7952f7 60
rconnorlawson 0:35660d7952f7 61 // Add other status info drawing code here
rconnorlawson 0:35660d7952f7 62 }
rconnorlawson 0:35660d7952f7 63
rconnorlawson 0:35660d7952f7 64 void draw_border()
rconnorlawson 0:35660d7952f7 65 {
rconnorlawson 0:35660d7952f7 66 uLCD.filled_rectangle(0, 9, 127, 14, WHITE); // Top
rconnorlawson 0:35660d7952f7 67 uLCD.filled_rectangle(0, 13, 2, 114, WHITE); // Left
rconnorlawson 0:35660d7952f7 68 uLCD.filled_rectangle(0, 114, 127, 117, WHITE); // Bottom
rconnorlawson 0:35660d7952f7 69 uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right
rconnorlawson 0:35660d7952f7 70 }
rconnorlawson 0:35660d7952f7 71
rconnorlawson 0:35660d7952f7 72