game for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
Sterofin
Date:
Fri Nov 30 05:31:06 2018 +0000
Revision:
4:af9d6e3b8a29
Parent:
2:06c63d567719
Child:
5:a16af8f3fea9
big boi;

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"
Sterofin 2:06c63d567719 4 #define W 0xffffff
Sterofin 2:06c63d567719 5 #define G 0xcccccc
Sterofin 2:06c63d567719 6 #define P 0xb700b7
Sterofin 2:06c63d567719 7 #define R 0xff0015
Sterofin 2:06c63d567719 8 #define N 0x0
Sterofin 2:06c63d567719 9 #define B 0x005dff
Sterofin 2:06c63d567719 10 #define DB 0x592e03
Sterofin 2:06c63d567719 11 #define O 0xff9b38
rconnorlawson 0:35660d7952f7 12
rconnorlawson 0:35660d7952f7 13 void draw_player(int u, int v, int key)
rconnorlawson 0:35660d7952f7 14 {
Sterofin 2:06c63d567719 15 //uLCD.filled_rectangle(u, v, u+11, v+11, RED);
Sterofin 2:06c63d567719 16 int player[121] =
Sterofin 2:06c63d567719 17 {
Sterofin 2:06c63d567719 18 N,N,N,N,P,P,N,N,N,N,N,
Sterofin 2:06c63d567719 19 N,N,N,P,P,W,W,N,N,N,N,
Sterofin 2:06c63d567719 20 N,N,N,P,G,G,G,N,N,N,N,
Sterofin 2:06c63d567719 21 N,N,P,P,W,W,W,N,N,N,N,
Sterofin 2:06c63d567719 22 N,N,P,R,R,B,R,R,N,N,N,
Sterofin 2:06c63d567719 23 N,N,N,R,R,B,R,R,N,N,N,
Sterofin 2:06c63d567719 24 N,N,N,R,R,B,R,R,N,N,N,
Sterofin 2:06c63d567719 25 N,N,N,R,B,B,B,R,N,N,N,
Sterofin 2:06c63d567719 26 N,N,N,R,B,N,B,R,N,N,N,
Sterofin 2:06c63d567719 27 N,N,N,N,B,N,B,N,N,N,N,
Sterofin 2:06c63d567719 28 N,N,N,N,B,N,B,N,N,N,N
Sterofin 2:06c63d567719 29 };
Sterofin 2:06c63d567719 30 uLCD.BLIT(u,v,11,11,&player[0]);
rconnorlawson 0:35660d7952f7 31 }
rconnorlawson 0:35660d7952f7 32
rconnorlawson 0:35660d7952f7 33 #define YELLOW 0xFFFF00
rconnorlawson 0:35660d7952f7 34 #define BROWN 0xD2691E
rconnorlawson 0:35660d7952f7 35 #define DIRT BROWN
rconnorlawson 0:35660d7952f7 36 void draw_img(int u, int v, const char* img)
rconnorlawson 0:35660d7952f7 37 {
rconnorlawson 0:35660d7952f7 38 int colors[11*11];
rconnorlawson 0:35660d7952f7 39 for (int i = 0; i < 11*11; i++)
rconnorlawson 0:35660d7952f7 40 {
rconnorlawson 0:35660d7952f7 41 if (img[i] == 'R') colors[i] = RED;
rconnorlawson 0:35660d7952f7 42 else if (img[i] == 'Y') colors[i] = YELLOW;
rconnorlawson 0:35660d7952f7 43 else if (img[i] == 'G') colors[i] = GREEN;
rconnorlawson 0:35660d7952f7 44 else if (img[i] == 'D') colors[i] = DIRT;
rconnorlawson 0:35660d7952f7 45 else if (img[i] == '5') colors[i] = LGREY;
rconnorlawson 0:35660d7952f7 46 else if (img[i] == '3') colors[i] = DGREY;
rconnorlawson 0:35660d7952f7 47 else colors[i] = BLACK;
rconnorlawson 0:35660d7952f7 48 }
rconnorlawson 0:35660d7952f7 49 uLCD.BLIT(u, v, 11, 11, colors);
rconnorlawson 0:35660d7952f7 50 wait_us(250); // Recovery time!
rconnorlawson 0:35660d7952f7 51 }
rconnorlawson 0:35660d7952f7 52
rconnorlawson 0:35660d7952f7 53 void draw_nothing(int u, int v)
rconnorlawson 0:35660d7952f7 54 {
rconnorlawson 0:35660d7952f7 55 // Fill a tile with blackness
rconnorlawson 0:35660d7952f7 56 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
rconnorlawson 0:35660d7952f7 57 }
rconnorlawson 0:35660d7952f7 58
rconnorlawson 0:35660d7952f7 59 void draw_wall(int u, int v)
rconnorlawson 0:35660d7952f7 60 {
rconnorlawson 0:35660d7952f7 61 uLCD.filled_rectangle(u, v, u+10, v+10, BROWN);
rconnorlawson 0:35660d7952f7 62 }
rconnorlawson 0:35660d7952f7 63
Sterofin 2:06c63d567719 64 void draw_netPortal(int u, int v)
Sterofin 2:06c63d567719 65 {
Sterofin 2:06c63d567719 66 uLCD.filled_rectangle(u, v, u+10, v+10, WHITE);
Sterofin 2:06c63d567719 67 }
Sterofin 2:06c63d567719 68
Sterofin 2:06c63d567719 69 void draw_terminal(int u, int v)
Sterofin 2:06c63d567719 70 {
Sterofin 2:06c63d567719 71 uLCD.filled_rectangle(u, v, u+10, v+10, 0x359aff);
Sterofin 2:06c63d567719 72 }
Sterofin 2:06c63d567719 73
Sterofin 2:06c63d567719 74 void draw_hacked_terminal(int u, int v)
Sterofin 2:06c63d567719 75 {
Sterofin 2:06c63d567719 76 uLCD.filled_rectangle(u, v, u+10, v+10, 0x52ff3f);
Sterofin 2:06c63d567719 77 }
Sterofin 2:06c63d567719 78
rconnorlawson 0:35660d7952f7 79 void draw_plant(int u, int v)
rconnorlawson 0:35660d7952f7 80 {
rconnorlawson 0:35660d7952f7 81 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
rconnorlawson 0:35660d7952f7 82 }
rconnorlawson 0:35660d7952f7 83
Sterofin 2:06c63d567719 84 void draw_door(int u, int v)
Sterofin 2:06c63d567719 85 {
Sterofin 2:06c63d567719 86 uLCD.filled_rectangle(u, v, u+10, v+10, G);
Sterofin 2:06c63d567719 87 }
Sterofin 2:06c63d567719 88
Sterofin 2:06c63d567719 89 void draw_NPC(int u, int v)
Sterofin 2:06c63d567719 90 {
Sterofin 2:06c63d567719 91 //uLCD.filled_rectangle(u, v, u+10, v+10, 0xffb600);
Sterofin 2:06c63d567719 92 int player[121] =
Sterofin 2:06c63d567719 93 {
Sterofin 2:06c63d567719 94 N,N,N,N,DB,DB,DB,N,N,N,N,
Sterofin 2:06c63d567719 95 N,N,N,N,BROWN,BROWN,BROWN,N,N,N,N,
Sterofin 2:06c63d567719 96 N,N,N,N,G,BROWN,G,N,N,N,N,
Sterofin 2:06c63d567719 97 N,N,N,N,DB,DB,DB,N,N,N,
Sterofin 2:06c63d567719 98 N,N,N,W,W,O,W,W,N,N,N,
Sterofin 2:06c63d567719 99 N,N,N,W,W,O,W,W,N,N,N,
Sterofin 2:06c63d567719 100 N,N,N,W,W,O,W,W,N,N,N,
Sterofin 2:06c63d567719 101 N,N,N,W,R,R,R,W,N,N,N,
Sterofin 2:06c63d567719 102 N,N,N,N,R,N,R,N,N,N,N,
Sterofin 2:06c63d567719 103 N,N,N,N,R,N,R,N,N,N,N,
Sterofin 2:06c63d567719 104 N,N,N,N,R,N,R,N,N,N,N
Sterofin 2:06c63d567719 105
Sterofin 2:06c63d567719 106 };
Sterofin 2:06c63d567719 107 uLCD.BLIT(u,v,11,11,&player[0]);
Sterofin 2:06c63d567719 108 }
Sterofin 2:06c63d567719 109
Sterofin 2:06c63d567719 110 void draw_upper_status(int x, int y)
rconnorlawson 0:35660d7952f7 111 {
rconnorlawson 0:35660d7952f7 112 // Draw bottom border of status bar
Sterofin 2:06c63d567719 113 //uLCD.line(0, 9, 127, 9, GREEN);
Sterofin 2:06c63d567719 114 uLCD.locate(0,0);
Sterofin 2:06c63d567719 115 uLCD.printf("(%d,%d)",x,y);
rconnorlawson 0:35660d7952f7 116
rconnorlawson 0:35660d7952f7 117 // Add other status info drawing code here
rconnorlawson 0:35660d7952f7 118 }
rconnorlawson 0:35660d7952f7 119
Sterofin 4:af9d6e3b8a29 120 void draw_lower_status(int money)
rconnorlawson 0:35660d7952f7 121 {
rconnorlawson 0:35660d7952f7 122 // Draw top border of status bar
Sterofin 2:06c63d567719 123 //uLCD.line(0, 118, 127, 118, GREEN);
Sterofin 4:af9d6e3b8a29 124 uLCD.locate(0,118);
Sterofin 4:af9d6e3b8a29 125 uLCD.printf("Credits: %d",money);
rconnorlawson 0:35660d7952f7 126
rconnorlawson 0:35660d7952f7 127 // Add other status info drawing code here
rconnorlawson 0:35660d7952f7 128 }
rconnorlawson 0:35660d7952f7 129
rconnorlawson 0:35660d7952f7 130 void draw_border()
rconnorlawson 0:35660d7952f7 131 {
rconnorlawson 0:35660d7952f7 132 uLCD.filled_rectangle(0, 9, 127, 14, WHITE); // Top
rconnorlawson 0:35660d7952f7 133 uLCD.filled_rectangle(0, 13, 2, 114, WHITE); // Left
rconnorlawson 0:35660d7952f7 134 uLCD.filled_rectangle(0, 114, 127, 117, WHITE); // Bottom
rconnorlawson 0:35660d7952f7 135 uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right
rconnorlawson 0:35660d7952f7 136 }
rconnorlawson 0:35660d7952f7 137
Sterofin 2:06c63d567719 138 void draw_menu_1()
Sterofin 2:06c63d567719 139 {
Sterofin 2:06c63d567719 140 uLCD.locate(1,12);
Sterofin 2:06c63d567719 141 uLCD.text_width(1); //4X size text
Sterofin 2:06c63d567719 142 uLCD.text_height(1);
Sterofin 2:06c63d567719 143 uLCD.color(RED);
Sterofin 2:06c63d567719 144 uLCD.printf(" Press Start ");
Sterofin 2:06c63d567719 145 }
rconnorlawson 0:35660d7952f7 146
Sterofin 2:06c63d567719 147 void draw_menu_2()
Sterofin 2:06c63d567719 148 {
Sterofin 2:06c63d567719 149 uLCD.filled_rectangle(0,90,128,115, 0x0);
Sterofin 2:06c63d567719 150 }
Sterofin 2:06c63d567719 151
Sterofin 2:06c63d567719 152 void draw_boots(int u, int v)
Sterofin 2:06c63d567719 153 {
Sterofin 2:06c63d567719 154 int image[121] =
Sterofin 2:06c63d567719 155 {
Sterofin 2:06c63d567719 156 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 157 0x00,0x00,0x00,0xe8,0xe8,0xe8,0xe8,0xe8,0x00,0x00,0x00,
Sterofin 2:06c63d567719 158 0x00,0x00,0x00,0xe8,0xe8,0xe8,0xe8,0xe8,0x00,0x00,0x00,
Sterofin 2:06c63d567719 159 0x00,0x00,0x00,0x00,0x69,0x69,0x69,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 160 0x00,0x00,0x00,0x00,0x69,0x69,0x69,0xfc,0x69,0x69,0x00,
Sterofin 2:06c63d567719 161 0xe8,0xe8,0xe8,0xe8,0xe8,0x69,0xfc,0x69,0x69,0x69,0x69,
Sterofin 2:06c63d567719 162 0xe8,0xe8,0xe8,0xe8,0xe8,0xfc,0x69,0x69,0x69,0x69,0x69,
Sterofin 2:06c63d567719 163 0x00,0x69,0x69,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 164 0x00,0x69,0x69,0x69,0xfc,0x69,0x69,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 165 0x00,0x69,0x69,0xfc,0x69,0x69,0x69,0x69,0x00,0x00,0x00,
Sterofin 2:06c63d567719 166 0x00,0x69,0xfc,0x69,0x69,0x69,0x69,0x69,0x00,0x00,0x00
Sterofin 2:06c63d567719 167 };
Sterofin 2:06c63d567719 168 uLCD.BLIT(u,v,11,11,&image[0]);
Sterofin 2:06c63d567719 169 }
Sterofin 2:06c63d567719 170
Sterofin 2:06c63d567719 171 void draw_printer(int u, int v)
Sterofin 2:06c63d567719 172 {
Sterofin 2:06c63d567719 173 int image[121] =
Sterofin 2:06c63d567719 174 {
Sterofin 2:06c63d567719 175 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 176 0x00,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x00,
Sterofin 2:06c63d567719 177 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 178 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 179 0x00,0x0a,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 180 0x00,0x0a,0x00,0x00,0x6d,0x6d,0x6d,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 181 0x00,0x0a,0x00,0x00,0x6d,0x6d,0x6d,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 182 0x00,0x0a,0x00,0x00,0x00,0x49,0x00,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 183 0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,
Sterofin 2:06c63d567719 184 0x00,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0xc4,0x00,
Sterofin 2:06c63d567719 185 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
Sterofin 2:06c63d567719 186 };
Sterofin 2:06c63d567719 187 uLCD.BLIT(u,v,11,11,&image[0]);
Sterofin 2:06c63d567719 188 }
Sterofin 2:06c63d567719 189
Sterofin 2:06c63d567719 190 void draw_teleport(int u, int v)
Sterofin 2:06c63d567719 191 {
Sterofin 2:06c63d567719 192 int image[121] =
Sterofin 2:06c63d567719 193 {
Sterofin 2:06c63d567719 194 0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00,
Sterofin 2:06c63d567719 195 0x00,0x2a,0x2a,0xff,0xff,0xff,0xff,0xff,0x2a,0x2a,0x00,
Sterofin 2:06c63d567719 196 0x2a,0x2a,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0x2a,0x2a,
Sterofin 2:06c63d567719 197 0x2a,0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xff,0x2a,
Sterofin 2:06c63d567719 198 0x2a,0xff,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0xe1,0x00,0x2a,
Sterofin 2:06c63d567719 199 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a,
Sterofin 2:06c63d567719 200 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a,
Sterofin 2:06c63d567719 201 0x2a,0xff,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0xff,0x2a,
Sterofin 2:06c63d567719 202 0x2a,0x2a,0xff,0xff,0xe1,0xe1,0xe1,0xff,0xff,0x2a,0x2a,
Sterofin 2:06c63d567719 203 0x00,0x2a,0x2a,0xff,0xe1,0xe1,0xe1,0xff,0x2a,0x2a,0x00,
Sterofin 2:06c63d567719 204 0x00,0x00,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,0x00
Sterofin 2:06c63d567719 205 };
Sterofin 2:06c63d567719 206 uLCD.BLIT(u,v,11,11,&image[0]);
Sterofin 2:06c63d567719 207 }
Sterofin 2:06c63d567719 208
Sterofin 2:06c63d567719 209 void draw_gun(int u, int v)
Sterofin 2:06c63d567719 210 {
Sterofin 2:06c63d567719 211 int image[121] =
Sterofin 2:06c63d567719 212 {
Sterofin 2:06c63d567719 213 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 214 0x00,0x00,0x00,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,
Sterofin 2:06c63d567719 215 0x00,0x00,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00,
Sterofin 2:06c63d567719 216 0x2a,0x2a,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 217 0x2a,0xc0,0x2a,0x00,0x00,0x2a,0x2a,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 218 0x2a,0xc0,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,
Sterofin 2:06c63d567719 219 0x2a,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
Sterofin 2:06c63d567719 220 0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x00,
Sterofin 2:06c63d567719 221 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 222 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
Sterofin 2:06c63d567719 223 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
Sterofin 2:06c63d567719 224 };
Sterofin 2:06c63d567719 225 uLCD.BLIT(u,v,11,11,&image[0]);
Sterofin 2:06c63d567719 226 }