game for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: graphics.cpp
- Revision:
- 5:a16af8f3fea9
- Parent:
- 4:af9d6e3b8a29
diff -r af9d6e3b8a29 -r a16af8f3fea9 graphics.cpp --- a/graphics.cpp Fri Nov 30 05:31:06 2018 +0000 +++ b/graphics.cpp Fri Nov 30 08:29:52 2018 +0000 @@ -1,226 +0,0 @@ -#include "graphics.h" - -#include "globals.h" -#define W 0xffffff -#define G 0xcccccc -#define P 0xb700b7 -#define R 0xff0015 -#define N 0x0 -#define B 0x005dff -#define DB 0x592e03 -#define O 0xff9b38 - -void draw_player(int u, int v, int key) -{ - //uLCD.filled_rectangle(u, v, u+11, v+11, RED); - int player[121] = - { - N,N,N,N,P,P,N,N,N,N,N, - N,N,N,P,P,W,W,N,N,N,N, - N,N,N,P,G,G,G,N,N,N,N, - N,N,P,P,W,W,W,N,N,N,N, - N,N,P,R,R,B,R,R,N,N,N, - N,N,N,R,R,B,R,R,N,N,N, - N,N,N,R,R,B,R,R,N,N,N, - N,N,N,R,B,B,B,R,N,N,N, - N,N,N,R,B,N,B,R,N,N,N, - N,N,N,N,B,N,B,N,N,N,N, - N,N,N,N,B,N,B,N,N,N,N - }; - uLCD.BLIT(u,v,11,11,&player[0]); -} - -#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.filled_rectangle(u, v, u+10, v+10, BROWN); -} - -void draw_netPortal(int u, int v) -{ - uLCD.filled_rectangle(u, v, u+10, v+10, WHITE); -} - -void draw_terminal(int u, int v) -{ - uLCD.filled_rectangle(u, v, u+10, v+10, 0x359aff); -} - -void draw_hacked_terminal(int u, int v) -{ - uLCD.filled_rectangle(u, v, u+10, v+10, 0x52ff3f); -} - -void draw_plant(int u, int v) -{ - uLCD.filled_rectangle(u, v, u+10, v+10, GREEN); -} - -void draw_door(int u, int v) -{ - uLCD.filled_rectangle(u, v, u+10, v+10, G); -} - -void draw_NPC(int u, int v) -{ - //uLCD.filled_rectangle(u, v, u+10, v+10, 0xffb600); - int player[121] = - { - N,N,N,N,DB,DB,DB,N,N,N,N, - N,N,N,N,BROWN,BROWN,BROWN,N,N,N,N, - N,N,N,N,G,BROWN,G,N,N,N,N, - N,N,N,N,DB,DB,DB,N,N,N, - N,N,N,W,W,O,W,W,N,N,N, - N,N,N,W,W,O,W,W,N,N,N, - N,N,N,W,W,O,W,W,N,N,N, - N,N,N,W,R,R,R,W,N,N,N, - N,N,N,N,R,N,R,N,N,N,N, - N,N,N,N,R,N,R,N,N,N,N, - N,N,N,N,R,N,R,N,N,N,N - - }; - uLCD.BLIT(u,v,11,11,&player[0]); -} - -void draw_upper_status(int x, int y) -{ - // Draw bottom border of status bar - //uLCD.line(0, 9, 127, 9, GREEN); - uLCD.locate(0,0); - uLCD.printf("(%d,%d)",x,y); - - // Add other status info drawing code here -} - -void draw_lower_status(int money) -{ - // Draw top border of status bar - //uLCD.line(0, 118, 127, 118, GREEN); - uLCD.locate(0,118); - uLCD.printf("Credits: %d",money); - - // Add other status info drawing code here -} - -void draw_border() -{ - uLCD.filled_rectangle(0, 9, 127, 14, WHITE); // Top - uLCD.filled_rectangle(0, 13, 2, 114, WHITE); // Left - uLCD.filled_rectangle(0, 114, 127, 117, WHITE); // Bottom - uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right -} - -void draw_menu_1() -{ - uLCD.locate(1,12); - uLCD.text_width(1); //4X size text - uLCD.text_height(1); - uLCD.color(RED); - uLCD.printf(" Press Start "); -} - -void draw_menu_2() -{ - uLCD.filled_rectangle(0,90,128,115, 0x0); -} - -void draw_boots(int u, int v) -{ - int image[121] = - { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0xe8,0xe8,0xe8,0xe8,0xe8,0x00,0x00,0x00, - 0x00,0x00,0x00,0xe8,0xe8,0xe8,0xe8,0xe8,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x69,0x69,0x69,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x69,0x69,0x69,0xfc,0x69,0x69,0x00, - 0xe8,0xe8,0xe8,0xe8,0xe8,0x69,0xfc,0x69,0x69,0x69,0x69, - 0xe8,0xe8,0xe8,0xe8,0xe8,0xfc,0x69,0x69,0x69,0x69,0x69, - 0x00,0x69,0x69,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x69,0x69,0x69,0xfc,0x69,0x69,0x00,0x00,0x00,0x00, - 0x00,0x69,0x69,0xfc,0x69,0x69,0x69,0x69,0x00,0x00,0x00, - 0x00,0x69,0xfc,0x69,0x69,0x69,0x69,0x69,0x00,0x00,0x00 - }; - uLCD.BLIT(u,v,11,11,&image[0]); -} - -void draw_printer(int u, int v) -{ - int image[121] = - { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x6d,0x6d,0x6d,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x6d,0x6d,0x6d,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x49,0x00,0x00,0x00,0x0a,0x00, - 0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00, - 0x00,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - }; - uLCD.BLIT(u,v,11,11,&image[0]); -} - -void draw_teleport(int u, int v) -{ - int image[121] = - { - 0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00, - 0x00,0x2a,0x2a,0xff,0xff,0xff,0xff,0xff,0x2a,0x2a,0x00, - 0x2a,0x2a,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0x2a,0x2a, - 0x2a,0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff,0x2a, - 0x2a,0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0x00,0x2a, - 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a, - 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a, - 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a, - 0x2a,0x2a,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0x2a,0x2a, - 0x00,0x2a,0x2a,0xff,0xe1,0xe1,0xe1,0xff,0x2a,0x2a,0x00, - 0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00 - }; - uLCD.BLIT(u,v,11,11,&image[0]); -} - -void draw_gun(int u, int v) -{ - int image[121] = - { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00, - 0x00,0x00,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00, - 0x2a,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00,0x00, - 0x2a,0xc0,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00,0x00, - 0x2a,0xc0,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00, - 0x2a,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0, - 0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - }; - uLCD.BLIT(u,v,11,11,&image[0]); -}