Adventure game written for ECE2035 at the Georgia Institute of Technology
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: graphics.cpp
- Revision:
- 2:0876296d9473
- Parent:
- 0:35660d7952f7
- Child:
- 3:289762133fd6
diff -r 399033d39feb -r 0876296d9473 graphics.cpp --- a/graphics.cpp Wed Apr 04 21:11:07 2018 +0000 +++ b/graphics.cpp Tue Apr 17 17:17:20 2018 +0000 @@ -4,12 +4,30 @@ +char heart[122] = "BPPPVBBPPPV" + "PPPPPVPPPPP" + "PPPPPPPPPPP" + "PPPPPPPPPPP" + "PPPPPPPPPPP" + "PPPPPPPPPPP" + "PPPPPPPPPPP" + "PPPPPPPPPPP" + "BPPPPPPPPPV" + "BBBBBBBBBBB" + "BBBBBBBBBBB"; + void draw_player(int u, int v, int key) { uLCD.filled_rectangle(u, v, u+11, v+11, RED); } -#define YELLOW 0xFFFF00 + +void draw_npc(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+11, v+11, YELLOW); +} + + #define BROWN 0xD2691E #define DIRT BROWN void draw_img(int u, int v, const char* img) @@ -23,6 +41,8 @@ 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 if (img[i] == 'P') colors[i] = PINK1; + else if (img[i] == 'V') colors[i] = LIGHTPINK; else colors[i] = BLACK; } uLCD.BLIT(u, v, 11, 11, colors); @@ -37,7 +57,12 @@ void draw_wall(int u, int v) { - uLCD.filled_rectangle(u, v, u+10, v+10, BROWN); + uLCD.filled_rectangle(u, v, u+10, v+10, BLUE); +} + +void draw_door(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+5, v+5, RED); } void draw_plant(int u, int v) @@ -45,20 +70,49 @@ uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); } -void draw_upper_status() +void draw_spike(int u, int v) +{ + uLCD.triangle(u, v, u+10, v+10, u, v+10, PINK1); +} + +#define GRAY 0x9096A0 +void draw_rock(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, GRAY); +} + +void draw_goal(int u, int v) +{ + uLCD.filled_rectangle(u, v, u+10, v+10, BROWN); +} + +void draw_upper_status(int health) { // Draw bottom border of status bar - uLCD.line(0, 9, 127, 9, GREEN); + if (health == 0){ + uLCD.filled_rectangle(health, 9, 127, 0, GREEN); + } else{ + uLCD.filled_rectangle(0, 9, health+10, 0, RED); + } + //draw_img(0, 0, heart); // Add other status info drawing code here + + } -void draw_lower_status() +void draw_lower_status(int x, int y) { + //uLCD.filled_rectangle(0, 128, 128, 110, 0x000000); // Draw top border of status bar - uLCD.line(0, 118, 127, 118, GREEN); + //uLCD.line(0, 118, 127, 118, GREEN); // Add other status info drawing code here + char str[30]; + sprintf(str, "Coord: (%d, %d)", x, y); + uLCD.text_mode(OPAQUE); + uLCD.textbackground_color(BLACK); + uLCD.text_string(str, 0, 15, FONT_7X8, 0xFFFFFF); } void draw_border() @@ -69,4 +123,11 @@ uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right } +void draw_game_over(){ + uLCD.filled_rectangle(0, 128, 128, 0, WHITE); + uLCD.locate(1,5); + uLCD.text_mode(TRANSPARENT); + uLCD.color(BLACK); + uLCD.printf("GAME OVER!"); +}