Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
nasiromar
Date:
Wed Dec 01 22:07:24 2021 +0000
Revision:
10:e18685911e84
Parent:
9:cbb9cfb1f6c5
Child:
11:6cd02a8539d1
Walk;

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 10:e18685911e84 9 int currentMap = get_current_map();
nasiromar 10:e18685911e84 10
nasiromar 6:c9695079521d 11
nasiromar 9:cbb9cfb1f6c5 12 void set_npc(int i, int j)
nasiromar 9:cbb9cfb1f6c5 13 {
nasiromar 9:cbb9cfb1f6c5 14 spot->x = i;
nasiromar 9:cbb9cfb1f6c5 15 spot->y = j;
nasiromar 7:862062ffca62 16
nasiromar 9:cbb9cfb1f6c5 17 add_npc(spot->x,spot->y);
nasiromar 7:862062ffca62 18 }
nasiromar 7:862062ffca62 19
nasiromar 7:862062ffca62 20
nasiromar 9:cbb9cfb1f6c5 21
nasiromar 9:cbb9cfb1f6c5 22 void fruit()
nasiromar 9:cbb9cfb1f6c5 23 {
nasiromar 9:cbb9cfb1f6c5 24 char line1[] = "Picked Fruit";
nasiromar 9:cbb9cfb1f6c5 25 char line2[] = "From The Tree";
nasiromar 7:862062ffca62 26 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 27
nasiromar 9:cbb9cfb1f6c5 28 char line3[] = "Fruit Eaten:";
nasiromar 9:cbb9cfb1f6c5 29 char line4[] = "5 HP gained";
nasiromar 7:862062ffca62 30 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 31 }
nasiromar 9:cbb9cfb1f6c5 32
nasiromar 9:cbb9cfb1f6c5 33 void god_modeOn()
nasiromar 9:cbb9cfb1f6c5 34 {
nasiromar 9:cbb9cfb1f6c5 35 char line1[] = "God Mode:";
nasiromar 9:cbb9cfb1f6c5 36 char line2[] = "Activated";
nasiromar 9:cbb9cfb1f6c5 37 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 38 }
nasiromar 9:cbb9cfb1f6c5 39
nasiromar 9:cbb9cfb1f6c5 40 void god_modeOff()
nasiromar 9:cbb9cfb1f6c5 41 {
nasiromar 9:cbb9cfb1f6c5 42 char line1[] = "God Mode:";
nasiromar 9:cbb9cfb1f6c5 43 char line2[] = "Deactivated";
nasiromar 9:cbb9cfb1f6c5 44 horizontal_speech1(line1,line2);
nasiromar 8:fcc333a8f9e1 45 }
nasiromar 7:862062ffca62 46
nasiromar 10:e18685911e84 47 int walkYpos;
nasiromar 10:e18685911e84 48 int walkXpos;
nasiromar 10:e18685911e84 49
nasiromar 10:e18685911e84 50 int npc_x = 9;
nasiromar 10:e18685911e84 51 int npc_y = 9;
nasiromar 9:cbb9cfb1f6c5 52
nasiromar 10:e18685911e84 53 void walk_npc()
nasiromar 10:e18685911e84 54 {
nasiromar 10:e18685911e84 55
nasiromar 10:e18685911e84 56 if(currentMap == 0 ){
nasiromar 10:e18685911e84 57 map_erase(npc_x,npc_y);
nasiromar 10:e18685911e84 58
nasiromar 10:e18685911e84 59
nasiromar 10:e18685911e84 60 if ( npc_y == 8 && npc_x == 9){
nasiromar 10:e18685911e84 61 walkYpos = 0;
nasiromar 10:e18685911e84 62 walkXpos = 1;
nasiromar 10:e18685911e84 63 }
nasiromar 10:e18685911e84 64 else if ( npc_y == 9 && npc_x == 8){
nasiromar 10:e18685911e84 65 walkYpos = 1;
nasiromar 10:e18685911e84 66 walkXpos = 1;
nasiromar 10:e18685911e84 67 }
nasiromar 10:e18685911e84 68 else if ( npc_y == 8 && npc_x == 8){
nasiromar 10:e18685911e84 69 walkYpos = 1;
nasiromar 10:e18685911e84 70 walkXpos = 0;
nasiromar 10:e18685911e84 71 }
nasiromar 10:e18685911e84 72 else if (npc_y ==9 && npc_y == 9) {
nasiromar 10:e18685911e84 73 walkYpos = 0;
nasiromar 10:e18685911e84 74 walkXpos = 0;
nasiromar 10:e18685911e84 75 }
nasiromar 10:e18685911e84 76
nasiromar 10:e18685911e84 77
nasiromar 10:e18685911e84 78 if ( walkYpos == 1 && walkXpos == 0){
nasiromar 10:e18685911e84 79 npc_y++;
nasiromar 10:e18685911e84 80 add_npc(npc_x,npc_y);
nasiromar 10:e18685911e84 81 }
nasiromar 10:e18685911e84 82 else if ( walkYpos == 0 && walkXpos == 0){
nasiromar 10:e18685911e84 83 npc_y--;
nasiromar 10:e18685911e84 84 add_npc(npc_x,npc_y);
nasiromar 10:e18685911e84 85 }
nasiromar 10:e18685911e84 86 else if ( walkYpos == 1 && walkXpos == 1){
nasiromar 10:e18685911e84 87 npc_x++;
nasiromar 10:e18685911e84 88 add_npc(npc_x,npc_y);
nasiromar 10:e18685911e84 89 }
nasiromar 10:e18685911e84 90 else if (walkXpos == 1 && walkYpos == 0){
nasiromar 10:e18685911e84 91 npc_x--;
nasiromar 10:e18685911e84 92 add_npc(npc_x,npc_y);
nasiromar 10:e18685911e84 93 }
nasiromar 10:e18685911e84 94 }
nasiromar 10:e18685911e84 95
nasiromar 10:e18685911e84 96 }
nasiromar 9:cbb9cfb1f6c5 97
nasiromar 9:cbb9cfb1f6c5 98 void no_fruit() {
nasiromar 9:cbb9cfb1f6c5 99 char line1[] = "Player Health:";
nasiromar 9:cbb9cfb1f6c5 100 char line2[] = "Full";
nasiromar 9:cbb9cfb1f6c5 101 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 102
nasiromar 9:cbb9cfb1f6c5 103 char line3[] = "Fruit Dropped:";
nasiromar 9:cbb9cfb1f6c5 104 char line4[] = "0 HP gained";
nasiromar 9:cbb9cfb1f6c5 105 horizontal_speech1(line3,line4);
nasiromar 7:862062ffca62 106 }
nasiromar 9:cbb9cfb1f6c5 107
nasiromar 9:cbb9cfb1f6c5 108 void npc_speech1() {
nasiromar 9:cbb9cfb1f6c5 109
nasiromar 9:cbb9cfb1f6c5 110 char line1[] = "Salutations:";
nasiromar 9:cbb9cfb1f6c5 111 char line2[] = "Traveler!";
nasiromar 9:cbb9cfb1f6c5 112 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 113
nasiromar 9:cbb9cfb1f6c5 114 char line3[] = "Welcome to";
nasiromar 9:cbb9cfb1f6c5 115 char line4[] = "NasLand";
nasiromar 9:cbb9cfb1f6c5 116 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 117
nasiromar 9:cbb9cfb1f6c5 118 char line5[] = "I offer a quest";
nasiromar 9:cbb9cfb1f6c5 119 char line6[] = "If thee accept";
nasiromar 9:cbb9cfb1f6c5 120 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 121
nasiromar 9:cbb9cfb1f6c5 122 char line7[] = "Excellent!";
nasiromar 9:cbb9cfb1f6c5 123 char line8[] = "I need a dragon";
nasiromar 9:cbb9cfb1f6c5 124 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 125
nasiromar 9:cbb9cfb1f6c5 126 char line9[] = "Well not need";
nasiromar 9:cbb9cfb1f6c5 127 char line10[] = "but want DEAD!";
nasiromar 9:cbb9cfb1f6c5 128 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 129
nasiromar 9:cbb9cfb1f6c5 130 char line11[] = "so go to the ";
nasiromar 9:cbb9cfb1f6c5 131 char line12[] = "portal next..";
nasiromar 9:cbb9cfb1f6c5 132 horizontal_speech1(line11,line12);
nasiromar 9:cbb9cfb1f6c5 133
nasiromar 9:cbb9cfb1f6c5 134 char line13[] = "Hint: ";
nasiromar 9:cbb9cfb1f6c5 135 char line14[] = "X[20],Y[35]";
nasiromar 9:cbb9cfb1f6c5 136 horizontal_speech1(line13,line14);
nasiromar 9:cbb9cfb1f6c5 137 }
nasiromar 9:cbb9cfb1f6c5 138
nasiromar 9:cbb9cfb1f6c5 139 void npc_speech2() {
nasiromar 9:cbb9cfb1f6c5 140
nasiromar 9:cbb9cfb1f6c5 141 char line1[] = "Welcome Back";
nasiromar 9:cbb9cfb1f6c5 142 char line2[] = "Traveler!";
nasiromar 9:cbb9cfb1f6c5 143 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 144
nasiromar 9:cbb9cfb1f6c5 145 char line3[] = "The Dragon";
nasiromar 9:cbb9cfb1f6c5 146 char line4[] = "has been slain";
nasiromar 9:cbb9cfb1f6c5 147 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 148
nasiromar 9:cbb9cfb1f6c5 149 char line5[] = "You have saved";
nasiromar 9:cbb9cfb1f6c5 150 char line6[] = "NasLand";
nasiromar 9:cbb9cfb1f6c5 151 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 152
nasiromar 9:cbb9cfb1f6c5 153 char line7[] = "Go to Castle";
nasiromar 9:cbb9cfb1f6c5 154 char line8[] = "To collect";
nasiromar 9:cbb9cfb1f6c5 155 horizontal_speech1(line7,line8);
nasiromar 7:862062ffca62 156
nasiromar 9:cbb9cfb1f6c5 157 char line9[] = "TREASURE";
nasiromar 9:cbb9cfb1f6c5 158 char line10[] = "TREASURE";
nasiromar 9:cbb9cfb1f6c5 159 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 160
nasiromar 9:cbb9cfb1f6c5 161 char line11[] = "Farwell Great ";
nasiromar 9:cbb9cfb1f6c5 162 char line12[] = "Mage...";
nasiromar 9:cbb9cfb1f6c5 163 horizontal_speech1(line11,line12);
nasiromar 9:cbb9cfb1f6c5 164
nasiromar 9:cbb9cfb1f6c5 165 char line13[] = "Hint: ";
nasiromar 9:cbb9cfb1f6c5 166 char line14[] = "X[26],Y[12]";
nasiromar 9:cbb9cfb1f6c5 167 horizontal_speech1(line13,line14);
nasiromar 9:cbb9cfb1f6c5 168 }
nasiromar 9:cbb9cfb1f6c5 169
nasiromar 9:cbb9cfb1f6c5 170
nasiromar 9:cbb9cfb1f6c5 171 void slay_dragon() {
nasiromar 9:cbb9cfb1f6c5 172 char line1[] = "Me!?!";
nasiromar 9:cbb9cfb1f6c5 173 char line2[] = "Dying? at the";
nasiromar 9:cbb9cfb1f6c5 174 horizontal_speech1(line1,line2);
nasiromar 9:cbb9cfb1f6c5 175
nasiromar 9:cbb9cfb1f6c5 176 char line3[] = "hands of a";
nasiromar 9:cbb9cfb1f6c5 177 char line4[] = "mere MORTAL";
nasiromar 9:cbb9cfb1f6c5 178 horizontal_speech1(line3,line4);
nasiromar 9:cbb9cfb1f6c5 179
nasiromar 9:cbb9cfb1f6c5 180 char line5[] = "Ahhhhhhhh!";
nasiromar 9:cbb9cfb1f6c5 181 char line6[] = "DIES:(";
nasiromar 9:cbb9cfb1f6c5 182 horizontal_speech1(line5,line6);
nasiromar 9:cbb9cfb1f6c5 183
nasiromar 9:cbb9cfb1f6c5 184 char line7[] = "CONGRATULATIONS!";
nasiromar 9:cbb9cfb1f6c5 185 char line8[] = "Dragon Slain";
nasiromar 9:cbb9cfb1f6c5 186 horizontal_speech1(line7,line8);
nasiromar 9:cbb9cfb1f6c5 187
nasiromar 9:cbb9cfb1f6c5 188 char line9[] = "Heres the key!";
nasiromar 9:cbb9cfb1f6c5 189 char line10[] = "Well Done!";
nasiromar 9:cbb9cfb1f6c5 190 horizontal_speech1(line9,line10);
nasiromar 9:cbb9cfb1f6c5 191
nasiromar 9:cbb9cfb1f6c5 192 }
nasiromar 9:cbb9cfb1f6c5 193
nasiromar 9:cbb9cfb1f6c5 194
nasiromar 9:cbb9cfb1f6c5 195 int door_open() {
nasiromar 9:cbb9cfb1f6c5 196 return 1;
nasiromar 9:cbb9cfb1f6c5 197 }
nasiromar 9:cbb9cfb1f6c5 198
nasiromar 9:cbb9cfb1f6c5 199
nasiromar 9:cbb9cfb1f6c5 200 void init_dung() {
nasiromar 9:cbb9cfb1f6c5 201 Map* map = set_active_map(1);
nasiromar 9:cbb9cfb1f6c5 202 for(int i = map_width() + 7; i < map_area(); i += 39) {
nasiromar 9:cbb9cfb1f6c5 203 add_chest(i % map_width(), i / map_width());
nasiromar 9:cbb9cfb1f6c5 204 }
nasiromar 9:cbb9cfb1f6c5 205 pc.printf("plants\r\n");
nasiromar 9:cbb9cfb1f6c5 206
nasiromar 9:cbb9cfb1f6c5 207 pc.printf("Adding walls!\r\n");
nasiromar 9:cbb9cfb1f6c5 208 add_castle(0, 0, HORIZONTAL, map_width());
nasiromar 9:cbb9cfb1f6c5 209 add_castle(0, map_height()-1, HORIZONTAL, map_width());
nasiromar 9:cbb9cfb1f6c5 210 add_castle(0, 0, VERTICAL, map_height());
nasiromar 9:cbb9cfb1f6c5 211 add_castle(map_width()-1, 0, VERTICAL, map_height());
nasiromar 9:cbb9cfb1f6c5 212 pc.printf("Walls done!\r\n");
nasiromar 9:cbb9cfb1f6c5 213
nasiromar 9:cbb9cfb1f6c5 214
nasiromar 9:cbb9cfb1f6c5 215 add_portal2(15,21);
nasiromar 9:cbb9cfb1f6c5 216
nasiromar 9:cbb9cfb1f6c5 217 add_dragon(18,9);
nasiromar 9:cbb9cfb1f6c5 218
nasiromar 9:cbb9cfb1f6c5 219
nasiromar 9:cbb9cfb1f6c5 220 print_map();
nasiromar 9:cbb9cfb1f6c5 221
nasiromar 9:cbb9cfb1f6c5 222 }