Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
nasiromar
Date:
Fri Dec 03 08:45:49 2021 +0000
Revision:
14:7225da81314a
Parent:
13:798a4dd14c7e
Child:
15:05592aaa468c
NasLand Almost Done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nasiromar 6:c9695079521d 1 #include "actions.h"
nasiromar 6:c9695079521d 2 #include "speech.h"
nasiromar 6:c9695079521d 3 #include "hardware.h"
nasiromar 6:c9695079521d 4 #include "globals.h"
nasiromar 7:862062ffca62 5 #include "map.h"
nasiromar 6:c9695079521d 6
nasiromar 6:c9695079521d 7
nasiromar 9:cbb9cfb1f6c5 8 MapItem*spot = (MapItem*) malloc(sizeof(MapItem));
nasiromar 11:6cd02a8539d1 9 int currentMap = get_map(1);
nasiromar 10:e18685911e84 10
nasiromar 6:c9695079521d 11
nasiromar 11:6cd02a8539d1 12 int door_open()
nasiromar 9:cbb9cfb1f6c5 13 {
nasiromar 11:6cd02a8539d1 14 return 1;
nasiromar 7:862062ffca62 15 }
nasiromar 7:862062ffca62 16
nasiromar 11:6cd02a8539d1 17 void door_locked()
nasiromar 11:6cd02a8539d1 18 {
nasiromar 11:6cd02a8539d1 19 char line1[] = "The Door Is";
nasiromar 11:6cd02a8539d1 20 char line2[] = "Locked...";
nasiromar 11:6cd02a8539d1 21 horizontal_speech1(line1,line2);
nasiromar 7:862062ffca62 22
nasiromar 11:6cd02a8539d1 23 char line3[] = "Find The Key";
nasiromar 11:6cd02a8539d1 24 char line4[] = "**Slay Mob**";
nasiromar 11:6cd02a8539d1 25 horizontal_speech1(line3,line4);
nasiromar 11:6cd02a8539d1 26 }
nasiromar 9:cbb9cfb1f6c5 27
nasiromar 9:cbb9cfb1f6c5 28 void fruit()
nasiromar 9:cbb9cfb1f6c5 29 {
nasiromar 9:cbb9cfb1f6c5 30 char line1[] = "Picked Fruit";
nasiromar 9:cbb9cfb1f6c5 31 char line2[] = "From The Tree";
nasiromar 7:862062ffca62 32 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 33
nasiromar 9:cbb9cfb1f6c5 34 char line3[] = "Fruit Eaten:";
nasiromar 9:cbb9cfb1f6c5 35 char line4[] = "5 HP gained";
nasiromar 7:862062ffca62 36 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 37 }
nasiromar 9:cbb9cfb1f6c5 38
nasiromar 9:cbb9cfb1f6c5 39 void god_modeOn()
nasiromar 9:cbb9cfb1f6c5 40 {
nasiromar 9:cbb9cfb1f6c5 41 char line1[] = "God Mode:";
nasiromar 9:cbb9cfb1f6c5 42 char line2[] = "Activated";
nasiromar 9:cbb9cfb1f6c5 43 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 44 }
nasiromar 9:cbb9cfb1f6c5 45
nasiromar 9:cbb9cfb1f6c5 46 void god_modeOff()
nasiromar 9:cbb9cfb1f6c5 47 {
nasiromar 9:cbb9cfb1f6c5 48 char line1[] = "God Mode:";
nasiromar 9:cbb9cfb1f6c5 49 char line2[] = "Deactivated";
nasiromar 9:cbb9cfb1f6c5 50 horizontal_speech1(line1,line2);
nasiromar 8:fcc333a8f9e1 51 }
nasiromar 7:862062ffca62 52
nasiromar 10:e18685911e84 53 int walkYpos;
nasiromar 11:6cd02a8539d1 54
nasiromar 10:e18685911e84 55
nasiromar 11:6cd02a8539d1 56 int gob_x = 18;
nasiromar 11:6cd02a8539d1 57 int gob_y = 19;
nasiromar 9:cbb9cfb1f6c5 58
nasiromar 11:6cd02a8539d1 59 void walk_goblin(int slain)
nasiromar 10:e18685911e84 60 {
nasiromar 11:6cd02a8539d1 61
nasiromar 11:6cd02a8539d1 62 if(slain != 1 && currentMap == 1) {
nasiromar 11:6cd02a8539d1 63 map_erase(gob_x,gob_y);
nasiromar 11:6cd02a8539d1 64
nasiromar 11:6cd02a8539d1 65
nasiromar 11:6cd02a8539d1 66 if ( gob_y == 18 ) {
nasiromar 10:e18685911e84 67 walkYpos = 0;
nasiromar 11:6cd02a8539d1 68 } else if ( gob_y == 19) {
nasiromar 10:e18685911e84 69 walkYpos = 1;
nasiromar 10:e18685911e84 70 }
nasiromar 11:6cd02a8539d1 71
nasiromar 11:6cd02a8539d1 72 if ( walkYpos == 1) {
nasiromar 11:6cd02a8539d1 73 gob_y--;
nasiromar 13:798a4dd14c7e 74 add_goblin(gob_x,gob_y,ENEMY1);
nasiromar 11:6cd02a8539d1 75 } else if ( walkYpos == 0) {
nasiromar 11:6cd02a8539d1 76 gob_y++;
nasiromar 13:798a4dd14c7e 77 add_goblin(gob_x,gob_y,ENEMY1);
nasiromar 10:e18685911e84 78
nasiromar 11:6cd02a8539d1 79 }
nasiromar 11:6cd02a8539d1 80 }
nasiromar 11:6cd02a8539d1 81 else if(slain == 1){
nasiromar 11:6cd02a8539d1 82 map_delete(gob_x,gob_y);
nasiromar 11:6cd02a8539d1 83 }
nasiromar 11:6cd02a8539d1 84
nasiromar 11:6cd02a8539d1 85 }
nasiromar 11:6cd02a8539d1 86
nasiromar 11:6cd02a8539d1 87 void no_fruit()
nasiromar 11:6cd02a8539d1 88 {
nasiromar 11:6cd02a8539d1 89 char line1[] = "Player Health:";
nasiromar 11:6cd02a8539d1 90 char line2[] = "Full";
nasiromar 11:6cd02a8539d1 91 horizontal_speech1(line1,line2);
nasiromar 11:6cd02a8539d1 92
nasiromar 11:6cd02a8539d1 93 char line3[] = "Fruit Dropped:";
nasiromar 11:6cd02a8539d1 94 char line4[] = "0 HP gained";
nasiromar 11:6cd02a8539d1 95 horizontal_speech1(line3,line4);
nasiromar 11:6cd02a8539d1 96 }
nasiromar 11:6cd02a8539d1 97
nasiromar 14:7225da81314a 98 void merch_speech1(){
nasiromar 14:7225da81314a 99 char line1[] = "Welcome To";
nasiromar 14:7225da81314a 100 char line2[] = "The Shop";
nasiromar 14:7225da81314a 101 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 102
nasiromar 14:7225da81314a 103 char line3[] = "Take a look";
nasiromar 14:7225da81314a 104 char line4[] = "My Friend";
nasiromar 14:7225da81314a 105 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 106 }
nasiromar 14:7225da81314a 107
nasiromar 14:7225da81314a 108 void merch_speech2(){
nasiromar 14:7225da81314a 109 char line1[] = "Thank You";
nasiromar 14:7225da81314a 110 char line2[] = "For Shopping";
nasiromar 14:7225da81314a 111 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 112
nasiromar 14:7225da81314a 113 char line3[] = "Be sure to";
nasiromar 14:7225da81314a 114 char line4[] = "Return :)";
nasiromar 14:7225da81314a 115 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 116 }
nasiromar 14:7225da81314a 117
nasiromar 14:7225da81314a 118 void cantbuy()
nasiromar 14:7225da81314a 119 {
nasiromar 14:7225da81314a 120 char line1[] = "Not Enough";
nasiromar 14:7225da81314a 121 char line2[] = "Funds";
nasiromar 14:7225da81314a 122 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 123 }
nasiromar 14:7225da81314a 124
nasiromar 14:7225da81314a 125 void frt()
nasiromar 14:7225da81314a 126 {
nasiromar 14:7225da81314a 127 char line1[] = "HP:";
nasiromar 14:7225da81314a 128 char line2[] = "+6";
nasiromar 14:7225da81314a 129 horizontal_speech2(line1,line2);
nasiromar 14:7225da81314a 130 }
nasiromar 14:7225da81314a 131
nasiromar 14:7225da81314a 132 void elx()
nasiromar 14:7225da81314a 133 {
nasiromar 14:7225da81314a 134 char line1[] = "HP:";
nasiromar 14:7225da81314a 135 char line2[] = "+10";
nasiromar 14:7225da81314a 136 horizontal_speech2(line1,line2);
nasiromar 14:7225da81314a 137 }
nasiromar 14:7225da81314a 138
nasiromar 14:7225da81314a 139 void poti()
nasiromar 14:7225da81314a 140 {
nasiromar 14:7225da81314a 141 char line1[] = "MP:";
nasiromar 14:7225da81314a 142 char line2[] = "+8";
nasiromar 14:7225da81314a 143 horizontal_speech2(line1,line2);
nasiromar 14:7225da81314a 144 }
nasiromar 14:7225da81314a 145
nasiromar 14:7225da81314a 146 void npc2_speech()
nasiromar 14:7225da81314a 147 {
nasiromar 14:7225da81314a 148 char line1[] = "*Twink Twink*";
nasiromar 14:7225da81314a 149 char line2[] = "*Twink Twink*";
nasiromar 14:7225da81314a 150 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 151
nasiromar 14:7225da81314a 152 char line3[] = "Please save us";
nasiromar 14:7225da81314a 153 char line4[] = "Mighty Hero";
nasiromar 14:7225da81314a 154 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 155 }
nasiromar 14:7225da81314a 156
nasiromar 14:7225da81314a 157 void fire_dmg(){
nasiromar 14:7225da81314a 158 char line1[] = "*Burn Burn*";
nasiromar 14:7225da81314a 159 char line2[] = "*Crackle*";
nasiromar 14:7225da81314a 160 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 161
nasiromar 14:7225da81314a 162 char line3[] = "Fire Damage:";
nasiromar 14:7225da81314a 163 char line4[] = "HP: -2";
nasiromar 14:7225da81314a 164 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 165 }
nasiromar 14:7225da81314a 166
nasiromar 14:7225da81314a 167 void eye_dmg(){
nasiromar 14:7225da81314a 168 char line1[] = "*shake shake*";
nasiromar 14:7225da81314a 169 char line2[] = "Recoiled";
nasiromar 14:7225da81314a 170 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 171
nasiromar 14:7225da81314a 172 char line3[] = "Eye Screeched!";
nasiromar 14:7225da81314a 173 char line4[] = "The sound hurts";
nasiromar 14:7225da81314a 174 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 175
nasiromar 14:7225da81314a 176 char line5[] = "HP Damage:";
nasiromar 14:7225da81314a 177 char line6[] = "HP: -15";
nasiromar 14:7225da81314a 178 horizontal_speech1(line5,line6);
nasiromar 14:7225da81314a 179 }
nasiromar 14:7225da81314a 180
nasiromar 14:7225da81314a 181 void gob_dmg(){
nasiromar 14:7225da81314a 182 char line1[] = "*shake shake*";
nasiromar 14:7225da81314a 183 char line2[] = "Recoiled";
nasiromar 14:7225da81314a 184 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 185
nasiromar 14:7225da81314a 186 char line3[] = "Goblin Attacked";
nasiromar 14:7225da81314a 187 char line4[] = "Took Damage";
nasiromar 14:7225da81314a 188 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 189
nasiromar 14:7225da81314a 190 char line5[] = "HP Damage:";
nasiromar 14:7225da81314a 191 char line6[] = "HP: -12";
nasiromar 14:7225da81314a 192 horizontal_speech1(line5,line6);
nasiromar 14:7225da81314a 193 }
nasiromar 14:7225da81314a 194
nasiromar 14:7225da81314a 195
nasiromar 14:7225da81314a 196
nasiromar 14:7225da81314a 197 void potion(){
nasiromar 14:7225da81314a 198 char line1[] = "Potion:";
nasiromar 14:7225da81314a 199 char line2[] = "Selected";
nasiromar 14:7225da81314a 200 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 201
nasiromar 14:7225da81314a 202 char line3[] = "MP increase";
nasiromar 14:7225da81314a 203 char line4[] = "MP: +5";
nasiromar 14:7225da81314a 204 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 205 }
nasiromar 14:7225da81314a 206
nasiromar 14:7225da81314a 207
nasiromar 11:6cd02a8539d1 208 void npc_speech1()
nasiromar 11:6cd02a8539d1 209 {
nasiromar 11:6cd02a8539d1 210
nasiromar 11:6cd02a8539d1 211 char line1[] = "Salutations:";
nasiromar 11:6cd02a8539d1 212 char line2[] = "Traveler!";
nasiromar 11:6cd02a8539d1 213 horizontal_speech1(line1,line2);
nasiromar 11:6cd02a8539d1 214
nasiromar 11:6cd02a8539d1 215 char line3[] = "Welcome to";
nasiromar 11:6cd02a8539d1 216 char line4[] = "NasLand";
nasiromar 11:6cd02a8539d1 217 horizontal_speech1(line3,line4);
nasiromar 11:6cd02a8539d1 218
nasiromar 11:6cd02a8539d1 219 char line5[] = "I offer a quest";
nasiromar 11:6cd02a8539d1 220 char line6[] = "If thee accept";
nasiromar 11:6cd02a8539d1 221 horizontal_speech1(line5,line6);
nasiromar 11:6cd02a8539d1 222
nasiromar 11:6cd02a8539d1 223 char line7[] = "Excellent!";
nasiromar 11:6cd02a8539d1 224 char line8[] = "I need a dragon";
nasiromar 11:6cd02a8539d1 225 horizontal_speech1(line7,line8);
nasiromar 11:6cd02a8539d1 226
nasiromar 11:6cd02a8539d1 227 char line9[] = "Well not need";
nasiromar 11:6cd02a8539d1 228 char line10[] = "but want DEAD!";
nasiromar 11:6cd02a8539d1 229 horizontal_speech1(line9,line10);
nasiromar 11:6cd02a8539d1 230
nasiromar 11:6cd02a8539d1 231 char line11[] = "so go to the ";
nasiromar 11:6cd02a8539d1 232 char line12[] = "portal next..";
nasiromar 11:6cd02a8539d1 233 horizontal_speech1(line11,line12);
nasiromar 11:6cd02a8539d1 234
nasiromar 11:6cd02a8539d1 235 char line13[] = "Hint: ";
nasiromar 11:6cd02a8539d1 236 char line14[] = "X[20],Y[35]";
nasiromar 11:6cd02a8539d1 237 horizontal_speech1(line13,line14);
nasiromar 10:e18685911e84 238 }
nasiromar 9:cbb9cfb1f6c5 239
nasiromar 11:6cd02a8539d1 240 void npc_speech2()
nasiromar 11:6cd02a8539d1 241 {
nasiromar 9:cbb9cfb1f6c5 242
nasiromar 11:6cd02a8539d1 243 char line1[] = "Welcome Back";
nasiromar 11:6cd02a8539d1 244 char line2[] = "Traveler!";
nasiromar 11:6cd02a8539d1 245 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 246
nasiromar 11:6cd02a8539d1 247 char line3[] = "The Dragon";
nasiromar 11:6cd02a8539d1 248 char line4[] = "has been slain";
nasiromar 11:6cd02a8539d1 249 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 250
nasiromar 11:6cd02a8539d1 251 char line5[] = "You have saved";
nasiromar 11:6cd02a8539d1 252 char line6[] = "NasLand";
nasiromar 11:6cd02a8539d1 253 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 254
nasiromar 11:6cd02a8539d1 255 char line7[] = "Go to Castle";
nasiromar 11:6cd02a8539d1 256 char line8[] = "To collect";
nasiromar 11:6cd02a8539d1 257 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 258
nasiromar 11:6cd02a8539d1 259 char line9[] = "TREASURE";
nasiromar 11:6cd02a8539d1 260 char line10[] = "TREASURE";
nasiromar 11:6cd02a8539d1 261 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 262
nasiromar 11:6cd02a8539d1 263 char line11[] = "Farwell Great ";
nasiromar 11:6cd02a8539d1 264 char line12[] = "Mage...";
nasiromar 11:6cd02a8539d1 265 horizontal_speech1(line11,line12);
nasiromar 7:862062ffca62 266
nasiromar 11:6cd02a8539d1 267 char line13[] = "Hint: ";
nasiromar 11:6cd02a8539d1 268 char line14[] = "X[26],Y[12]";
nasiromar 11:6cd02a8539d1 269 horizontal_speech1(line13,line14);
nasiromar 11:6cd02a8539d1 270 }
nasiromar 9:cbb9cfb1f6c5 271
nasiromar 9:cbb9cfb1f6c5 272
nasiromar 11:6cd02a8539d1 273 void slay_dragon()
nasiromar 11:6cd02a8539d1 274 {
nasiromar 11:6cd02a8539d1 275 char line1[] = "Me!?!";
nasiromar 11:6cd02a8539d1 276 char line2[] = "Dying? at the";
nasiromar 11:6cd02a8539d1 277 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 278
nasiromar 11:6cd02a8539d1 279 char line3[] = "hands of a";
nasiromar 11:6cd02a8539d1 280 char line4[] = "mere MORTAL";
nasiromar 11:6cd02a8539d1 281 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 282
nasiromar 11:6cd02a8539d1 283 char line5[] = "Ahhhhhhhh!";
nasiromar 11:6cd02a8539d1 284 char line6[] = "DIES:(";
nasiromar 11:6cd02a8539d1 285 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 286
nasiromar 11:6cd02a8539d1 287 char line7[] = "CONGRATULATIONS!";
nasiromar 11:6cd02a8539d1 288 char line8[] = "Dragon Slain";
nasiromar 11:6cd02a8539d1 289 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 290
nasiromar 11:6cd02a8539d1 291 char line9[] = "Heres the key!";
nasiromar 11:6cd02a8539d1 292 char line10[] = "Well Done!";
nasiromar 11:6cd02a8539d1 293 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 294
nasiromar 11:6cd02a8539d1 295 }
nasiromar 9:cbb9cfb1f6c5 296
nasiromar 14:7225da81314a 297 void money_chest()
nasiromar 14:7225da81314a 298 {
nasiromar 14:7225da81314a 299 char line1[] = "Chest Open:";
nasiromar 14:7225da81314a 300 char line2[] = "Oh La La $$";
nasiromar 14:7225da81314a 301 horizontal_speech1(line1,line2);
nasiromar 14:7225da81314a 302
nasiromar 14:7225da81314a 303 char line3[] = "Money Gained:";
nasiromar 14:7225da81314a 304 char line4[] = "+$2";
nasiromar 14:7225da81314a 305 horizontal_speech1(line3,line4);
nasiromar 14:7225da81314a 306 }
nasiromar 14:7225da81314a 307
nasiromar 9:cbb9cfb1f6c5 308
nasiromar 11:6cd02a8539d1 309 void init_dung()
nasiromar 11:6cd02a8539d1 310 {
nasiromar 11:6cd02a8539d1 311 Map* dung = set_active_map(1);
nasiromar 14:7225da81314a 312
nasiromar 11:6cd02a8539d1 313 add_castle(0, 0, HORIZONTAL, map_width());
nasiromar 11:6cd02a8539d1 314 add_castle(0, map_height()-1, HORIZONTAL, map_width());
nasiromar 11:6cd02a8539d1 315 add_castle(0, 0, VERTICAL, map_height());
nasiromar 11:6cd02a8539d1 316 add_castle(map_width()-1, 0, VERTICAL, map_height());
nasiromar 9:cbb9cfb1f6c5 317
nasiromar 14:7225da81314a 318 add_chest(10,16);
nasiromar 14:7225da81314a 319 add_chest(17,17);
nasiromar 14:7225da81314a 320 add_chest(14,7);
nasiromar 14:7225da81314a 321 add_chest(9,3);
nasiromar 14:7225da81314a 322 add_chest(5,6);
nasiromar 14:7225da81314a 323 add_chest(12,11);
nasiromar 14:7225da81314a 324 add_chest(2,18);
nasiromar 9:cbb9cfb1f6c5 325
nasiromar 12:116a4cc85b16 326 add_portal2(10,2);
nasiromar 11:6cd02a8539d1 327
nasiromar 13:798a4dd14c7e 328 add_dragon(15,9);
nasiromar 9:cbb9cfb1f6c5 329
nasiromar 13:798a4dd14c7e 330 add_goblin(5,7,ENEMY2);
nasiromar 11:6cd02a8539d1 331
nasiromar 13:798a4dd14c7e 332 add_goblin(10,10,ENEMY1);
nasiromar 14:7225da81314a 333
nasiromar 14:7225da81314a 334 add_eye(15,15);
nasiromar 9:cbb9cfb1f6c5 335
nasiromar 11:6cd02a8539d1 336 print_map();
nasiromar 9:cbb9cfb1f6c5 337
nasiromar 11:6cd02a8539d1 338 }