Game For ECE 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: actions.cpp
- Revision:
- 11:6cd02a8539d1
- Parent:
- 10:e18685911e84
- Child:
- 12:116a4cc85b16
diff -r e18685911e84 -r 6cd02a8539d1 actions.cpp --- a/actions.cpp Wed Dec 01 22:07:24 2021 +0000 +++ b/actions.cpp Thu Dec 02 06:24:22 2021 +0000 @@ -6,18 +6,24 @@ MapItem*spot = (MapItem*) malloc(sizeof(MapItem)); -int currentMap = get_current_map(); +int currentMap = get_map(1); -void set_npc(int i, int j) +int door_open() { - spot->x = i; - spot->y = j; - - add_npc(spot->x,spot->y); + return 1; } +void door_locked() +{ + char line1[] = "The Door Is"; + char line2[] = "Locked..."; + horizontal_speech1(line1,line2); + char line3[] = "Find The Key"; + char line4[] = "**Slay Mob**"; + horizontal_speech1(line3,line4); +} void fruit() { @@ -45,178 +51,164 @@ } int walkYpos; -int walkXpos; + -int npc_x = 9; -int npc_y = 9; +int gob_x = 18; +int gob_y = 19; -void walk_npc() +void walk_goblin(int slain) { - - if(currentMap == 0 ){ - map_erase(npc_x,npc_y); - - - if ( npc_y == 8 && npc_x == 9){ + + if(slain != 1 && currentMap == 1) { + map_erase(gob_x,gob_y); + + + if ( gob_y == 18 ) { walkYpos = 0; - walkXpos = 1; - } - else if ( npc_y == 9 && npc_x == 8){ + } else if ( gob_y == 19) { walkYpos = 1; - walkXpos = 1; - } - else if ( npc_y == 8 && npc_x == 8){ - walkYpos = 1; - walkXpos = 0; } - else if (npc_y ==9 && npc_y == 9) { - walkYpos = 0; - walkXpos = 0; - } - + + if ( walkYpos == 1) { + gob_y--; + add_goblin(gob_x,gob_y); + } else if ( walkYpos == 0) { + gob_y++; + add_goblin(gob_x,gob_y); - if ( walkYpos == 1 && walkXpos == 0){ - npc_y++; - add_npc(npc_x,npc_y); - } - else if ( walkYpos == 0 && walkXpos == 0){ - npc_y--; - add_npc(npc_x,npc_y); - } - else if ( walkYpos == 1 && walkXpos == 1){ - npc_x++; - add_npc(npc_x,npc_y); - } - else if (walkXpos == 1 && walkYpos == 0){ - npc_x--; - add_npc(npc_x,npc_y); - } - } - + } + } + else if(slain == 1){ + map_delete(gob_x,gob_y); + } + +} + +void no_fruit() +{ + char line1[] = "Player Health:"; + char line2[] = "Full"; + horizontal_speech1(line1,line2); + + char line3[] = "Fruit Dropped:"; + char line4[] = "0 HP gained"; + horizontal_speech1(line3,line4); +} + +void npc_speech1() +{ + + char line1[] = "Salutations:"; + char line2[] = "Traveler!"; + horizontal_speech1(line1,line2); + + char line3[] = "Welcome to"; + char line4[] = "NasLand"; + horizontal_speech1(line3,line4); + + char line5[] = "I offer a quest"; + char line6[] = "If thee accept"; + horizontal_speech1(line5,line6); + + char line7[] = "Excellent!"; + char line8[] = "I need a dragon"; + horizontal_speech1(line7,line8); + + char line9[] = "Well not need"; + char line10[] = "but want DEAD!"; + horizontal_speech1(line9,line10); + + char line11[] = "so go to the "; + char line12[] = "portal next.."; + horizontal_speech1(line11,line12); + + char line13[] = "Hint: "; + char line14[] = "X[20],Y[35]"; + horizontal_speech1(line13,line14); } - void no_fruit() { - char line1[] = "Player Health:"; - char line2[] = "Full"; - horizontal_speech1(line1,line2); +void npc_speech2() +{ - char line3[] = "Fruit Dropped:"; - char line4[] = "0 HP gained"; - horizontal_speech1(line3,line4); - } - - void npc_speech1() { - - char line1[] = "Salutations:"; - char line2[] = "Traveler!"; - horizontal_speech1(line1,line2); + char line1[] = "Welcome Back"; + char line2[] = "Traveler!"; + horizontal_speech1(line1,line2); - char line3[] = "Welcome to"; - char line4[] = "NasLand"; - horizontal_speech1(line3,line4); - - char line5[] = "I offer a quest"; - char line6[] = "If thee accept"; - horizontal_speech1(line5,line6); + char line3[] = "The Dragon"; + char line4[] = "has been slain"; + horizontal_speech1(line3,line4); - char line7[] = "Excellent!"; - char line8[] = "I need a dragon"; - horizontal_speech1(line7,line8); - - char line9[] = "Well not need"; - char line10[] = "but want DEAD!"; - horizontal_speech1(line9,line10); - - char line11[] = "so go to the "; - char line12[] = "portal next.."; - horizontal_speech1(line11,line12); + char line5[] = "You have saved"; + char line6[] = "NasLand"; + horizontal_speech1(line5,line6); - char line13[] = "Hint: "; - char line14[] = "X[20],Y[35]"; - horizontal_speech1(line13,line14); - } - - void npc_speech2() { + char line7[] = "Go to Castle"; + char line8[] = "To collect"; + horizontal_speech1(line7,line8); - char line1[] = "Welcome Back"; - char line2[] = "Traveler!"; - horizontal_speech1(line1,line2); - - char line3[] = "The Dragon"; - char line4[] = "has been slain"; - horizontal_speech1(line3,line4); + char line9[] = "TREASURE"; + char line10[] = "TREASURE"; + horizontal_speech1(line9,line10); - char line5[] = "You have saved"; - char line6[] = "NasLand"; - horizontal_speech1(line5,line6); - - char line7[] = "Go to Castle"; - char line8[] = "To collect"; - horizontal_speech1(line7,line8); + char line11[] = "Farwell Great "; + char line12[] = "Mage..."; + horizontal_speech1(line11,line12); - char line9[] = "TREASURE"; - char line10[] = "TREASURE"; - horizontal_speech1(line9,line10); - - char line11[] = "Farwell Great "; - char line12[] = "Mage..."; - horizontal_speech1(line11,line12); - - char line13[] = "Hint: "; - char line14[] = "X[26],Y[12]"; - horizontal_speech1(line13,line14); - } + char line13[] = "Hint: "; + char line14[] = "X[26],Y[12]"; + horizontal_speech1(line13,line14); +} - void slay_dragon() { - char line1[] = "Me!?!"; - char line2[] = "Dying? at the"; - horizontal_speech1(line1,line2); +void slay_dragon() +{ + char line1[] = "Me!?!"; + char line2[] = "Dying? at the"; + horizontal_speech1(line1,line2); - char line3[] = "hands of a"; - char line4[] = "mere MORTAL"; - horizontal_speech1(line3,line4); + char line3[] = "hands of a"; + char line4[] = "mere MORTAL"; + horizontal_speech1(line3,line4); - char line5[] = "Ahhhhhhhh!"; - char line6[] = "DIES:("; - horizontal_speech1(line5,line6); + char line5[] = "Ahhhhhhhh!"; + char line6[] = "DIES:("; + horizontal_speech1(line5,line6); - char line7[] = "CONGRATULATIONS!"; - char line8[] = "Dragon Slain"; - horizontal_speech1(line7,line8); + char line7[] = "CONGRATULATIONS!"; + char line8[] = "Dragon Slain"; + horizontal_speech1(line7,line8); - char line9[] = "Heres the key!"; - char line10[] = "Well Done!"; - horizontal_speech1(line9,line10); + char line9[] = "Heres the key!"; + char line10[] = "Well Done!"; + horizontal_speech1(line9,line10); - } +} - int door_open() { - return 1; +void init_dung() +{ + Map* dung = set_active_map(1); + for(int i = map_width() + 7; i < map_area(); i += 39) { + add_chest(i % map_width(), i / map_width()); } + pc.printf("plants\r\n"); + + pc.printf("Adding walls!\r\n"); + add_castle(0, 0, HORIZONTAL, map_width()); + add_castle(0, map_height()-1, HORIZONTAL, map_width()); + add_castle(0, 0, VERTICAL, map_height()); + add_castle(map_width()-1, 0, VERTICAL, map_height()); + pc.printf("Walls done!\r\n"); - void init_dung() { - Map* map = set_active_map(1); - for(int i = map_width() + 7; i < map_area(); i += 39) { - add_chest(i % map_width(), i / map_width()); - } - pc.printf("plants\r\n"); + add_portal2(15,21); + + add_dragon(18,9); - pc.printf("Adding walls!\r\n"); - add_castle(0, 0, HORIZONTAL, map_width()); - add_castle(0, map_height()-1, HORIZONTAL, map_width()); - add_castle(0, 0, VERTICAL, map_height()); - add_castle(map_width()-1, 0, VERTICAL, map_height()); - pc.printf("Walls done!\r\n"); - + add_goblin(13,14); + + add_goblin(5,10); - add_portal2(15,21); - - add_dragon(18,9); + print_map(); - - print_map(); - - } \ No newline at end of file +} \ No newline at end of file