Game For ECE 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: graphics.cpp
- Revision:
- 6:c9695079521d
- Parent:
- 4:37d3935365f8
- Child:
- 7:862062ffca62
--- a/graphics.cpp Tue Oct 12 15:26:32 2021 +0000 +++ b/graphics.cpp Fri Nov 19 22:03:25 2021 +0000 @@ -1,7 +1,13 @@ #include "graphics.h" #include "globals.h" - +#include "main_char.cpp" +#include "chest.cpp" +#include "castle.cpp" +#include "key.cpp" +#include "portal.cpp" +#include "tree.cpp" +#include "npc.cpp" /* In this file put all your graphical functions (don't forget to declare them first in graphics.h). So when you want to draw something use this file. One cool function @@ -12,7 +18,9 @@ void draw_player(int u, int v, int key) { - uLCD.filled_rectangle(u, v, u+11, v+11, RED); + + uLCD.BLIT(u,v,11,11,main_char_arr); + //.filled_rectangle(u, v, u+11, v+11, RED); } #define YELLOW 0xFFFF00 @@ -48,21 +56,54 @@ void draw_plant(int u, int v) { - uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); + uLCD.BLIT(u,v,11,11,tree_arr); +} + +void draw_key(int u, int v) +{ + uLCD.BLIT(u,v,11,11,key_arr); +} + +void draw_npc(int u, int v) +{ + uLCD.BLIT(u,v,11,11,npc_arr); +} + +void draw_portal(int u, int v) +{ + uLCD.BLIT(u,v,11,11,portal_arr); } -void draw_upper_status() +void draw_castle(int u, int v) { + uLCD.BLIT(u,v,11,11,castle_arr); +} + +void draw_chest(int u, int v){ + uLCD.BLIT(u,v,11,11,chest); +} + +void draw_upper_status(int player_x, int player_y) +{ + uLCD.locate(0,0); + uLCD.text_width(1); + uLCD.text_height(1); + uLCD.color(GREEN); + uLCD.printf("X: [%2i] Y: [%2i]",player_x,player_y); + // Draw bottom border of status bar - uLCD.line(0, 9, 127, 9, GREEN); // Add other status info drawing code here } -void draw_lower_status() -{ +void draw_lower_status(int hp, int mp) +{ // Draw top border of status bar - uLCD.line(0, 118, 127, 118, GREEN); + uLCD.locate(0,15); + uLCD.text_width(1); + uLCD.text_height(1); + uLCD.color(GREEN); + uLCD.printf("HP: %3i MP: %3i",hp,mp); // Add other status info drawing code here } @@ -75,4 +116,5 @@ uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right } - + +