Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
nasiromar
Date:
Thu Dec 02 06:24:22 2021 +0000
Revision:
11:6cd02a8539d1
Parent:
10:e18685911e84
Child:
12:116a4cc85b16
almost;

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 11:6cd02a8539d1 74 add_goblin(gob_x,gob_y);
nasiromar 11:6cd02a8539d1 75 } else if ( walkYpos == 0) {
nasiromar 11:6cd02a8539d1 76 gob_y++;
nasiromar 11:6cd02a8539d1 77 add_goblin(gob_x,gob_y);
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 11:6cd02a8539d1 98 void npc_speech1()
nasiromar 11:6cd02a8539d1 99 {
nasiromar 11:6cd02a8539d1 100
nasiromar 11:6cd02a8539d1 101 char line1[] = "Salutations:";
nasiromar 11:6cd02a8539d1 102 char line2[] = "Traveler!";
nasiromar 11:6cd02a8539d1 103 horizontal_speech1(line1,line2);
nasiromar 11:6cd02a8539d1 104
nasiromar 11:6cd02a8539d1 105 char line3[] = "Welcome to";
nasiromar 11:6cd02a8539d1 106 char line4[] = "NasLand";
nasiromar 11:6cd02a8539d1 107 horizontal_speech1(line3,line4);
nasiromar 11:6cd02a8539d1 108
nasiromar 11:6cd02a8539d1 109 char line5[] = "I offer a quest";
nasiromar 11:6cd02a8539d1 110 char line6[] = "If thee accept";
nasiromar 11:6cd02a8539d1 111 horizontal_speech1(line5,line6);
nasiromar 11:6cd02a8539d1 112
nasiromar 11:6cd02a8539d1 113 char line7[] = "Excellent!";
nasiromar 11:6cd02a8539d1 114 char line8[] = "I need a dragon";
nasiromar 11:6cd02a8539d1 115 horizontal_speech1(line7,line8);
nasiromar 11:6cd02a8539d1 116
nasiromar 11:6cd02a8539d1 117 char line9[] = "Well not need";
nasiromar 11:6cd02a8539d1 118 char line10[] = "but want DEAD!";
nasiromar 11:6cd02a8539d1 119 horizontal_speech1(line9,line10);
nasiromar 11:6cd02a8539d1 120
nasiromar 11:6cd02a8539d1 121 char line11[] = "so go to the ";
nasiromar 11:6cd02a8539d1 122 char line12[] = "portal next..";
nasiromar 11:6cd02a8539d1 123 horizontal_speech1(line11,line12);
nasiromar 11:6cd02a8539d1 124
nasiromar 11:6cd02a8539d1 125 char line13[] = "Hint: ";
nasiromar 11:6cd02a8539d1 126 char line14[] = "X[20],Y[35]";
nasiromar 11:6cd02a8539d1 127 horizontal_speech1(line13,line14);
nasiromar 10:e18685911e84 128 }
nasiromar 9:cbb9cfb1f6c5 129
nasiromar 11:6cd02a8539d1 130 void npc_speech2()
nasiromar 11:6cd02a8539d1 131 {
nasiromar 9:cbb9cfb1f6c5 132
nasiromar 11:6cd02a8539d1 133 char line1[] = "Welcome Back";
nasiromar 11:6cd02a8539d1 134 char line2[] = "Traveler!";
nasiromar 11:6cd02a8539d1 135 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 136
nasiromar 11:6cd02a8539d1 137 char line3[] = "The Dragon";
nasiromar 11:6cd02a8539d1 138 char line4[] = "has been slain";
nasiromar 11:6cd02a8539d1 139 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 140
nasiromar 11:6cd02a8539d1 141 char line5[] = "You have saved";
nasiromar 11:6cd02a8539d1 142 char line6[] = "NasLand";
nasiromar 11:6cd02a8539d1 143 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 144
nasiromar 11:6cd02a8539d1 145 char line7[] = "Go to Castle";
nasiromar 11:6cd02a8539d1 146 char line8[] = "To collect";
nasiromar 11:6cd02a8539d1 147 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 148
nasiromar 11:6cd02a8539d1 149 char line9[] = "TREASURE";
nasiromar 11:6cd02a8539d1 150 char line10[] = "TREASURE";
nasiromar 11:6cd02a8539d1 151 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 152
nasiromar 11:6cd02a8539d1 153 char line11[] = "Farwell Great ";
nasiromar 11:6cd02a8539d1 154 char line12[] = "Mage...";
nasiromar 11:6cd02a8539d1 155 horizontal_speech1(line11,line12);
nasiromar 7:862062ffca62 156
nasiromar 11:6cd02a8539d1 157 char line13[] = "Hint: ";
nasiromar 11:6cd02a8539d1 158 char line14[] = "X[26],Y[12]";
nasiromar 11:6cd02a8539d1 159 horizontal_speech1(line13,line14);
nasiromar 11:6cd02a8539d1 160 }
nasiromar 9:cbb9cfb1f6c5 161
nasiromar 9:cbb9cfb1f6c5 162
nasiromar 11:6cd02a8539d1 163 void slay_dragon()
nasiromar 11:6cd02a8539d1 164 {
nasiromar 11:6cd02a8539d1 165 char line1[] = "Me!?!";
nasiromar 11:6cd02a8539d1 166 char line2[] = "Dying? at the";
nasiromar 11:6cd02a8539d1 167 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 168
nasiromar 11:6cd02a8539d1 169 char line3[] = "hands of a";
nasiromar 11:6cd02a8539d1 170 char line4[] = "mere MORTAL";
nasiromar 11:6cd02a8539d1 171 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 172
nasiromar 11:6cd02a8539d1 173 char line5[] = "Ahhhhhhhh!";
nasiromar 11:6cd02a8539d1 174 char line6[] = "DIES:(";
nasiromar 11:6cd02a8539d1 175 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 176
nasiromar 11:6cd02a8539d1 177 char line7[] = "CONGRATULATIONS!";
nasiromar 11:6cd02a8539d1 178 char line8[] = "Dragon Slain";
nasiromar 11:6cd02a8539d1 179 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 180
nasiromar 11:6cd02a8539d1 181 char line9[] = "Heres the key!";
nasiromar 11:6cd02a8539d1 182 char line10[] = "Well Done!";
nasiromar 11:6cd02a8539d1 183 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 184
nasiromar 11:6cd02a8539d1 185 }
nasiromar 9:cbb9cfb1f6c5 186
nasiromar 9:cbb9cfb1f6c5 187
nasiromar 11:6cd02a8539d1 188 void init_dung()
nasiromar 11:6cd02a8539d1 189 {
nasiromar 11:6cd02a8539d1 190 Map* dung = set_active_map(1);
nasiromar 11:6cd02a8539d1 191 for(int i = map_width() + 7; i < map_area(); i += 39) {
nasiromar 11:6cd02a8539d1 192 add_chest(i % map_width(), i / map_width());
nasiromar 9:cbb9cfb1f6c5 193 }
nasiromar 11:6cd02a8539d1 194 pc.printf("plants\r\n");
nasiromar 11:6cd02a8539d1 195
nasiromar 11:6cd02a8539d1 196 pc.printf("Adding walls!\r\n");
nasiromar 11:6cd02a8539d1 197 add_castle(0, 0, HORIZONTAL, map_width());
nasiromar 11:6cd02a8539d1 198 add_castle(0, map_height()-1, HORIZONTAL, map_width());
nasiromar 11:6cd02a8539d1 199 add_castle(0, 0, VERTICAL, map_height());
nasiromar 11:6cd02a8539d1 200 add_castle(map_width()-1, 0, VERTICAL, map_height());
nasiromar 11:6cd02a8539d1 201 pc.printf("Walls done!\r\n");
nasiromar 9:cbb9cfb1f6c5 202
nasiromar 9:cbb9cfb1f6c5 203
nasiromar 11:6cd02a8539d1 204 add_portal2(15,21);
nasiromar 11:6cd02a8539d1 205
nasiromar 11:6cd02a8539d1 206 add_dragon(18,9);
nasiromar 9:cbb9cfb1f6c5 207
nasiromar 11:6cd02a8539d1 208 add_goblin(13,14);
nasiromar 11:6cd02a8539d1 209
nasiromar 11:6cd02a8539d1 210 add_goblin(5,10);
nasiromar 9:cbb9cfb1f6c5 211
nasiromar 11:6cd02a8539d1 212 print_map();
nasiromar 9:cbb9cfb1f6c5 213
nasiromar 11:6cd02a8539d1 214 }