Game For ECE 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

actions.cpp

Committer:
nasiromar
Date:
2021-12-03
Revision:
16:06a88c0110ff
Parent:
15:05592aaa468c
Child:
18:760dd68e939e

File content as of revision 16:06a88c0110ff:

#include "actions.h"
#include "speech.h"
#include "hardware.h"
#include "globals.h"
#include "map.h"


MapItem*spot = (MapItem*) malloc(sizeof(MapItem));
int currentMap = get_map(0);


int door_open()
{
    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()
{
    char line1[] = "Picked Fruit";
    char line2[] = "From The Tree";
    horizontal_speech1(line1,line2);

    char line3[] = "Fruit Eaten:";
    char line4[] = "5 HP gained";
    horizontal_speech1(line3,line4);
}

void god_modeOn()
{
    char line1[] = "God Mode:";
    char line2[] = "Activated";
    horizontal_speech1(line1,line2);
}

void god_modeOff()
{
    char line1[] = "God Mode:";
    char line2[] = "Deactivated";
    horizontal_speech1(line1,line2);
}


int  walkXpos;

int npc_x = 10;
int npc_y = 5;


void walk_npc()
{

   if(currentMap == 0 && npc_x != 6){
        map_erase(npc_x,npc_y);


        if ( npc_y == 5){
            walkXpos = 1;
            }
        if ( walkXpos == 1){
            npc_x--;
            add_npc(npc_x,npc_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 heal_up()
{
    char line1[] = "Player Health:";
    char line2[] = "Low";
    horizontal_speech1(line1,line2);

    char line3[] = "Hint:";
    char line4[] = "Store or Tree";
    horizontal_speech1(line3,line4);
}

void pick_key()
{
    char line1[] = "Congrats!!";
    char line2[] = "You've slain the";
    horizontal_speech1(line1,line2);

    char line3[] = "Dragon and";
    char line4[] = "completed your";
    horizontal_speech1(line3,line4);
    
    char line5[] = "Quest..";
    char line6[] = "Job Well Done";
    horizontal_speech1(line5,line6);
    
    char line7[] = "Collect Your";
    char line8[] = "Winnings";
    horizontal_speech1(line7,line8);
    
    char line9[] = "Thanks For";
    char line10[] = "Playing My";
    horizontal_speech1(line9,line10);
    
    char line11[] = "Game ;)";
    char line12[] = "-Holiday";
    horizontal_speech1(line11,line12);
}

void mag_up()
{
    char line1[] = "Player Magic:";
    char line2[] = "Low";
    horizontal_speech1(line1,line2);

    char line3[] = "Hint:";
    char line4[] = "Store or Chest";
    horizontal_speech1(line3,line4);
}


void merch_speech1(){
    char line1[] = "Welcome To";
    char line2[] = "The Shop";
    horizontal_speech1(line1,line2);

    char line3[] = "Take a look";
    char line4[] = "My Friend";
    horizontal_speech1(line3,line4);
    }
    
    void merch_speech2(){
    char line1[] = "Thank You";
    char line2[] = "For Shopping";
    horizontal_speech1(line1,line2);

    char line3[] = "Be sure to";
    char line4[] = "Return :)";
    horizontal_speech1(line3,line4);
    }
    
    void cantbuy()
{
    char line1[] = "Not Enough";
    char line2[] = "Funds";
    horizontal_speech1(line1,line2);
}

void drg()
{
    char line1[] = "Dragon Damaged";
    char line2[] = "DHP: -25";
    horizontal_speech2(line1,line2);
}

void frt()
{
    char line1[] = "HP:";
    char line2[] = "+6";
    horizontal_speech2(line1,line2);
}

void elx()
{
    char line1[] = "HP:";
    char line2[] = "+10";
    horizontal_speech2(line1,line2);
}

void poti()
{
    char line1[] = "MP:";
    char line2[] = "+8";
    horizontal_speech2(line1,line2);
}

void npc2_speech1()
{
    char line1[] = "*Twink Twink*";
    char line2[] = "*Twink Twink*";
    horizontal_speech1(line1,line2);

    char line3[] = "Please Save Us";
    char line4[] = "Mighty Hero";
    horizontal_speech1(line3,line4);
}

void npc2_speech2()
{
    char line1[] = "Thank You";
    char line2[] = "For Saving Us";
    horizontal_speech1(line1,line2);

    char line3[] = "We Are Eternally";
    char line4[] = "Grateful";
    horizontal_speech1(line3,line4);
}

void fire_dmg(){
    char line1[] = "*Burn Burn*";
    char line2[] = "*Crackle*";
    horizontal_speech1(line1,line2);

    char line3[] = "Fire Damage:";
    char line4[] = "HP: -2";
    horizontal_speech1(line3,line4);
    }
    
void eye_dmg(){
    char line1[] = "*shake shake*";
    char line2[] = "Recoiled";
    horizontal_speech1(line1,line2);
    
    char line3[] = "Eye Screeched!";
    char line4[] = "The sound hurts";
    horizontal_speech1(line3,line4);
    
    char line5[] = "HP Damage:";
    char line6[] = "HP: -15";
    horizontal_speech1(line5,line6);
    }
    
void gob_dmg(){
    char line1[] = "*shake shake*";
    char line2[] = "Recoiled";
    horizontal_speech1(line1,line2);
    
    char line3[] = "Goblin Attacked";
    char line4[] = "Took Damage";
    horizontal_speech1(line3,line4);

    char line5[] = "HP Damage:";
    char line6[] = "HP: -12";
    horizontal_speech1(line5,line6);
    }
    

    
    void potion(){
    char line1[] = "Potion:";
    char line2[] = "Selected";
    horizontal_speech1(line1,line2);

    char line3[] = "MP increase";
    char line4[] = "MP: +5";
    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 npc_speech2()
{

    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 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 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);
}


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 line5[] = "Ahhhhhhhh!";
    char line6[] = "DIES:(";
    horizontal_speech1(line5,line6);

    char line7[] = "CONGRATULATIONS!";
    char line8[] = "Dragon Slain";
    horizontal_speech1(line7,line8);

    char line9[] = "Heres the key!";
    char line10[] = "Well Done!";
    horizontal_speech1(line9,line10);

}

void money_chest()
{
    char line1[] = "Chest Open:";
    char line2[] = "Oh La La $$";
    horizontal_speech1(line1,line2);

    char line3[] = "Money Gained:";
    char line4[] = "+$2";
    horizontal_speech1(line3,line4);
}


void init_dung()
{
    Map* dung = set_active_map(1);
    
    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());

    add_chest(10,16);
    add_chest(17,17);
    add_chest(14,7);
    add_chest(9,3);
    add_chest(5,6);
    add_chest(12,11);
    add_chest(2,18);

    add_portal2(10,2);

    add_dragon(15,9);

    add_goblin(5,7,ENEMY2);
    
    add_goblin(10,10,ENEMY1);
    
    add_eye(15,15);

    print_map();

}