P2-2 Harris Barton

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
hbarton7
Date:
Wed Nov 25 01:17:39 2020 +0000
Revision:
3:e2fb359d6545
Parent:
2:4947d6a82971
P2-2 Harris Barton;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 2:4947d6a82971 1 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 2:4947d6a82971 2 // The materials provided by the instructor in this course are for
DCchico 2:4947d6a82971 3 // the use of the students currently enrolled in the course.
DCchico 2:4947d6a82971 4 // Copyrighted course materials may not be further disseminated.
DCchico 2:4947d6a82971 5 // This file must not be made publicly available anywhere.
DCchico 2:4947d6a82971 6
DCchico 1:10330bce85cb 7 #include "graphics.h"
DCchico 1:10330bce85cb 8
DCchico 1:10330bce85cb 9 #include "globals.h"
DCchico 1:10330bce85cb 10
hbarton7 3:e2fb359d6545 11 #define YELLOW 0xFFFF00
hbarton7 3:e2fb359d6545 12 #define BROWN 0xD2691E
hbarton7 3:e2fb359d6545 13 #define DIRT BROWN
hbarton7 3:e2fb359d6545 14
hbarton7 3:e2fb359d6545 15 const char head[121] = {
hbarton7 3:e2fb359d6545 16 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 17 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 18 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 19 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 20 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 21 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 22 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 23 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 24 'G','R','R','R','G','G','R','R','R','G','G',
hbarton7 3:e2fb359d6545 25 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 26 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 27 };
hbarton7 3:e2fb359d6545 28
hbarton7 3:e2fb359d6545 29 const char tail[121] = {
hbarton7 3:e2fb359d6545 30 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 31 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 32 'G','Y','Y','Y','G','G','G','Y','Y','Y','G',
hbarton7 3:e2fb359d6545 33 'G','Y','Y','Y','G','G','G','Y','Y','Y','G',
hbarton7 3:e2fb359d6545 34 'G','Y','Y','Y','G','G','G','Y','Y','Y','G',
hbarton7 3:e2fb359d6545 35 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 36 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 37 'G','Y','Y','Y','G','G','Y','Y','Y','G','G',
hbarton7 3:e2fb359d6545 38 'G','Y','Y','Y','G','G','Y','Y','Y','G','G',
hbarton7 3:e2fb359d6545 39 'G','Y','Y','Y','G','G','Y','Y','Y','G','G',
hbarton7 3:e2fb359d6545 40 'G','G','G','G','G','G','G','G','G','G','G',
hbarton7 3:e2fb359d6545 41 };
hbarton7 3:e2fb359d6545 42
hbarton7 3:e2fb359d6545 43 const char poison[121] = {
hbarton7 3:e2fb359d6545 44 'Y','3','3','3','3','3','3','3','3','3','Y',
hbarton7 3:e2fb359d6545 45 '3','Y','3','3','3','3','3','3','3','Y','3',
hbarton7 3:e2fb359d6545 46 '3','3','Y','3','3','3','3','3','Y','3','3',
hbarton7 3:e2fb359d6545 47 '3','3','3','Y','3','3','3','Y','3','3','3',
hbarton7 3:e2fb359d6545 48 '3','3','3','3','Y','3','Y','3','3','3','3',
hbarton7 3:e2fb359d6545 49 '3','3','3','3','3','Y','3','3','3','3','3',
hbarton7 3:e2fb359d6545 50 '3','3','3','3','Y','3','Y','3','3','3','3',
hbarton7 3:e2fb359d6545 51 '3','3','3','Y','3','3','3','Y','3','3','3',
hbarton7 3:e2fb359d6545 52 '3','3','Y','3','3','3','3','3','Y','3','3',
hbarton7 3:e2fb359d6545 53 '3','Y','3','3','3','3','3','3','3','Y','3',
hbarton7 3:e2fb359d6545 54 'Y','3','3','3','3','3','3','3','3','3','Y',
hbarton7 3:e2fb359d6545 55 };
hbarton7 3:e2fb359d6545 56
hbarton7 3:e2fb359d6545 57 const char speedup[121] = {
hbarton7 3:e2fb359d6545 58 '3','3','3','3','3','G','3','3','3','3','3',
hbarton7 3:e2fb359d6545 59 '3','3','3','3','G','3','G','3','3','3','3',
hbarton7 3:e2fb359d6545 60 '3','3','3','G','3','3','3','G','3','3','3',
hbarton7 3:e2fb359d6545 61 '3','3','G','3','3','3','3','3','G','3','3',
hbarton7 3:e2fb359d6545 62 '3','G','3','3','3','3','3','3','3','G','3',
hbarton7 3:e2fb359d6545 63 'G','3','3','3','3','3','3','3','3','3','G',
hbarton7 3:e2fb359d6545 64 '3','3','3','3','3','G','3','3','3','3','3',
hbarton7 3:e2fb359d6545 65 '3','3','3','3','G','3','G','3','3','3','3',
hbarton7 3:e2fb359d6545 66 '3','3','3','G','3','3','3','G','3','3','3',
hbarton7 3:e2fb359d6545 67 '3','3','G','3','3','3','3','3','G','3','3',
hbarton7 3:e2fb359d6545 68 '3','G','3','3','3','3','3','3','3','G','3',
hbarton7 3:e2fb359d6545 69 };
hbarton7 3:e2fb359d6545 70
hbarton7 3:e2fb359d6545 71 const char slowdown[121] = {
hbarton7 3:e2fb359d6545 72 'G','3','3','3','3','3','3','3','3','3','G',
hbarton7 3:e2fb359d6545 73 '3','G','3','3','3','3','3','3','3','G','3',
hbarton7 3:e2fb359d6545 74 '3','3','G','3','3','3','3','3','G','3','3',
hbarton7 3:e2fb359d6545 75 '3','3','3','G','3','3','3','G','3','3','3',
hbarton7 3:e2fb359d6545 76 '3','3','3','3','G','3','G','3','3','3','3',
hbarton7 3:e2fb359d6545 77 '3','3','3','3','3','G','3','3','3','3','3',
hbarton7 3:e2fb359d6545 78 'G','3','3','3','3','3','3','3','3','3','G',
hbarton7 3:e2fb359d6545 79 '3','G','3','3','3','3','3','3','3','G','3',
hbarton7 3:e2fb359d6545 80 '3','3','G','3','3','3','3','3','G','3','3',
hbarton7 3:e2fb359d6545 81 '3','3','3','G','3','3','3','G','3','3','3',
hbarton7 3:e2fb359d6545 82 '3','3','3','3','G','3','G','3','3','3','3',
hbarton7 3:e2fb359d6545 83 };
hbarton7 3:e2fb359d6545 84
hbarton7 3:e2fb359d6545 85 const char decrease_length[121] = {
hbarton7 3:e2fb359d6545 86 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 87 '3','3','3','3','Y','Y','3','3','3','3','3',
hbarton7 3:e2fb359d6545 88 '3','3','3','Y','3','3','Y','Y','Y','3','3',
hbarton7 3:e2fb359d6545 89 '3','3','3','Y','3','3','Y','3','3','3','3',
hbarton7 3:e2fb359d6545 90 '3','3','3','3','Y','Y','3','3','3','3','3',
hbarton7 3:e2fb359d6545 91 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 92 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 93 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 94 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 95 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 96 '3','3','3','3','3','3','3','3','3','3','3',
hbarton7 3:e2fb359d6545 97 };
hbarton7 3:e2fb359d6545 98
hbarton7 3:e2fb359d6545 99 const char random[121] = {
hbarton7 3:e2fb359d6545 100 '5','5','5','5','5','G','5','5','5','5','5',
hbarton7 3:e2fb359d6545 101 '5','5','5','5','G','5','G','5','5','5','5',
hbarton7 3:e2fb359d6545 102 '5','5','5','G','5','5','5','G','5','5','5',
hbarton7 3:e2fb359d6545 103 '5','5','5','5','5','5','5','G','5','5','5',
hbarton7 3:e2fb359d6545 104 '5','5','5','5','5','5','5','G','5','5','5',
hbarton7 3:e2fb359d6545 105 '5','5','5','5','5','5','G','5','5','5','5',
hbarton7 3:e2fb359d6545 106 '5','5','5','5','5','G','5','5','5','5','5',
hbarton7 3:e2fb359d6545 107 '5','5','5','5','5','G','5','5','5','5','5',
hbarton7 3:e2fb359d6545 108 '5','5','5','5','5','G','5','5','5','5','5',
hbarton7 3:e2fb359d6545 109 '5','5','5','5','5','5','5','5','5','5','5',
hbarton7 3:e2fb359d6545 110 '5','5','5','5','5','G','5','5','5','5','5',
hbarton7 3:e2fb359d6545 111 };
hbarton7 3:e2fb359d6545 112
hbarton7 3:e2fb359d6545 113 const char moving[121] = {
hbarton7 3:e2fb359d6545 114 '5','5','5','5','5','D','5','5','5','5','5',
hbarton7 3:e2fb359d6545 115 '5','5','5','5','D','5','D','5','5','5','5',
hbarton7 3:e2fb359d6545 116 '5','5','5','D','5','5','5','D','5','5','5',
hbarton7 3:e2fb359d6545 117 '5','5','5','5','5','5','5','D','5','5','5',
hbarton7 3:e2fb359d6545 118 '5','5','5','5','5','5','5','D','5','5','5',
hbarton7 3:e2fb359d6545 119 '5','5','5','5','5','5','D','5','5','5','5',
hbarton7 3:e2fb359d6545 120 '5','5','5','5','5','D','5','5','5','5','5',
hbarton7 3:e2fb359d6545 121 '5','5','5','5','5','D','5','5','5','5','5',
hbarton7 3:e2fb359d6545 122 '5','5','5','5','5','D','5','5','5','5','5',
hbarton7 3:e2fb359d6545 123 '5','5','5','5','5','5','5','5','5','5','5',
hbarton7 3:e2fb359d6545 124 '5','5','5','5','5','D','5','5','5','5','5',
hbarton7 3:e2fb359d6545 125 };
hbarton7 3:e2fb359d6545 126
hbarton7 3:e2fb359d6545 127 const char invinc[121] = {
hbarton7 3:e2fb359d6545 128 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 129 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 130 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 131 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 132 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 133 'R','R','R','R','R','R','R','R','R','R','R',
hbarton7 3:e2fb359d6545 134 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 135 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 136 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 137 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 138 '3','3','3','3','3','R','3','3','3','3','3',
hbarton7 3:e2fb359d6545 139 };
hbarton7 3:e2fb359d6545 140
hbarton7 3:e2fb359d6545 141 const char megaGoodie[121] = {
hbarton7 3:e2fb359d6545 142 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 143 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 144 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 145 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 146 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 147 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 148 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 149 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 150 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 151 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 152 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
hbarton7 3:e2fb359d6545 153 };
hbarton7 3:e2fb359d6545 154
DCchico 1:10330bce85cb 155 void draw_nothing(int u, int v)
DCchico 1:10330bce85cb 156 {
DCchico 1:10330bce85cb 157 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
DCchico 1:10330bce85cb 158 }
DCchico 1:10330bce85cb 159
DCchico 1:10330bce85cb 160 void draw_img(int u, int v, const char* img)
DCchico 1:10330bce85cb 161 {
DCchico 1:10330bce85cb 162 int colors[11*11];
DCchico 1:10330bce85cb 163 for (int i = 0; i < 11*11; i++)
DCchico 1:10330bce85cb 164 {
DCchico 1:10330bce85cb 165 if (img[i] == 'R') colors[i] = RED;
DCchico 1:10330bce85cb 166 else if (img[i] == 'Y') colors[i] = 0xFFFF00; // Yellow
DCchico 1:10330bce85cb 167 else if (img[i] == 'G') colors[i] = GREEN;
DCchico 1:10330bce85cb 168 else if (img[i] == 'D') colors[i] = 0xD2691E; // "Dirt"
DCchico 1:10330bce85cb 169 else if (img[i] == '5') colors[i] = LGREY; // 50% grey
DCchico 1:10330bce85cb 170 else if (img[i] == '3') colors[i] = DGREY;
DCchico 1:10330bce85cb 171 else colors[i] = BLACK;
DCchico 1:10330bce85cb 172 }
DCchico 1:10330bce85cb 173 uLCD.BLIT(u, v, 11, 11, colors);
DCchico 1:10330bce85cb 174 wait_us(250); // Recovery time!
DCchico 1:10330bce85cb 175 }
DCchico 1:10330bce85cb 176
DCchico 1:10330bce85cb 177 void draw_wall(int u, int v)
DCchico 1:10330bce85cb 178 {
hbarton7 3:e2fb359d6545 179 uLCD.filled_rectangle(u, v, u+10, v+10, LGREY);
DCchico 1:10330bce85cb 180 }
DCchico 1:10330bce85cb 181
DCchico 1:10330bce85cb 182 void draw_plant(int u, int v)
DCchico 1:10330bce85cb 183 {
DCchico 1:10330bce85cb 184 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 185 }
DCchico 1:10330bce85cb 186
DCchico 1:10330bce85cb 187 void draw_goodie(int u, int v)
DCchico 1:10330bce85cb 188 {
hbarton7 3:e2fb359d6545 189 uLCD.filled_rectangle(u, v, u+10, v+10, 0xD2691E); //DIRT
DCchico 1:10330bce85cb 190 }
DCchico 1:10330bce85cb 191
DCchico 1:10330bce85cb 192 void draw_snake_body(int u, int v)
DCchico 1:10330bce85cb 193 {
DCchico 1:10330bce85cb 194 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
DCchico 1:10330bce85cb 195 }
DCchico 1:10330bce85cb 196
DCchico 1:10330bce85cb 197 void draw_snake_head(int u, int v)
DCchico 1:10330bce85cb 198 {
DCchico 1:10330bce85cb 199 //May need to design a snake head sprite
DCchico 1:10330bce85cb 200 //Tile still need to be designed on paper
hbarton7 3:e2fb359d6545 201
DCchico 1:10330bce85cb 202 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
hbarton7 3:e2fb359d6545 203 draw_img(u,v, head);
hbarton7 3:e2fb359d6545 204 // uLCD.filled_rectangle(u+1, v+1, u+3, v+3, RED);
hbarton7 3:e2fb359d6545 205 // uLCD.filled_rectangle(u+7, v+1, u+9, v+3, RED);
hbarton7 3:e2fb359d6545 206 // uLCD.filled_rectangle(u+1, v+7, u+3, v+9, RED);
hbarton7 3:e2fb359d6545 207 // uLCD.filled_rectangle(u+7, v+7, u+9, v+9, RED);
hbarton7 3:e2fb359d6545 208
DCchico 1:10330bce85cb 209 }
DCchico 1:10330bce85cb 210
DCchico 1:10330bce85cb 211 void draw_snake_tail(int u, int v)
DCchico 1:10330bce85cb 212 {
DCchico 1:10330bce85cb 213 //May need to design a snake tail sprite
DCchico 1:10330bce85cb 214 //Tile still need to be designed on paper
hbarton7 3:e2fb359d6545 215
DCchico 1:10330bce85cb 216 uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
hbarton7 3:e2fb359d6545 217 draw_img(u,v, tail);
hbarton7 3:e2fb359d6545 218 // uLCD.filled_rectangle(u+1, v+1, u+3, v+3, 0xFFFF00); //YELLOW
hbarton7 3:e2fb359d6545 219 // uLCD.filled_rectangle(u+7, v+1, u+9, v+3, 0xFFFF00);
hbarton7 3:e2fb359d6545 220 // uLCD.filled_rectangle(u+1, v+7, u+3, v+9, 0xFFFF00);
hbarton7 3:e2fb359d6545 221 // uLCD.filled_rectangle(u+7, v+7, u+9, v+9, 0xFFFF00);
hbarton7 3:e2fb359d6545 222 }
hbarton7 3:e2fb359d6545 223
hbarton7 3:e2fb359d6545 224 void draw_poison(int u, int v) {
hbarton7 3:e2fb359d6545 225 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 226 draw_img(u, v, poison);
hbarton7 3:e2fb359d6545 227 }
hbarton7 3:e2fb359d6545 228
hbarton7 3:e2fb359d6545 229 void draw_speedup(int u, int v) {
hbarton7 3:e2fb359d6545 230 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 231 draw_img(u, v, speedup);
hbarton7 3:e2fb359d6545 232 }
hbarton7 3:e2fb359d6545 233
hbarton7 3:e2fb359d6545 234 void draw_slowdown(int u, int v) {
hbarton7 3:e2fb359d6545 235 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 236 draw_img(u, v, slowdown);
hbarton7 3:e2fb359d6545 237 }
hbarton7 3:e2fb359d6545 238
hbarton7 3:e2fb359d6545 239 void draw_decrease_length(int u, int v) {
hbarton7 3:e2fb359d6545 240 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 241 draw_img(u, v, decrease_length);
hbarton7 3:e2fb359d6545 242 }
hbarton7 3:e2fb359d6545 243
hbarton7 3:e2fb359d6545 244 void draw_random(int u, int v) {
hbarton7 3:e2fb359d6545 245 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 246 draw_img(u, v, random);
hbarton7 3:e2fb359d6545 247 }
hbarton7 3:e2fb359d6545 248
hbarton7 3:e2fb359d6545 249 void draw_moving(int u, int v) {
hbarton7 3:e2fb359d6545 250 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 251 draw_img(u, v, moving);
hbarton7 3:e2fb359d6545 252 }
hbarton7 3:e2fb359d6545 253
hbarton7 3:e2fb359d6545 254 void draw_invinc(int u, int v) {
hbarton7 3:e2fb359d6545 255 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 256 draw_img(u, v, invinc);
hbarton7 3:e2fb359d6545 257 }
hbarton7 3:e2fb359d6545 258 void draw_megaGoodie(int u, int v) {
hbarton7 3:e2fb359d6545 259 uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
hbarton7 3:e2fb359d6545 260 draw_img(u, v, megaGoodie);
DCchico 1:10330bce85cb 261 }
DCchico 1:10330bce85cb 262
DCchico 1:10330bce85cb 263