Skip to content
Permalink
Browse files
1 commit before final touchup
  • Loading branch information
dungranij committed Aug 3, 2020
1 parent 7217dc5 commit 87ba7272c31b48cc4d1dabcc8741b190b26f18f4
Showing 1 changed file with 225 additions and 0 deletions.
225 main.cpp
@@ -0,0 +1,225 @@
#include<iostream>
#include<string>
#include <unistd.h>
#include<stdlib.h>
#include <unistd.h>

using namespace std;
//declaring some imp functions
void Hud();
void Combathud();
void Combat();
void CreateAnimal();
void StepAhed();

//Essential Var which i will use in the entire project
string name = "", explore = "";
int level = 1, Xp = 0, Oxygen = 0, totalOxygen = 0, MaxOxygen = 0, NextLevel = 0, Health = 0, OxygenGas = 0, TotalHealth = 0,heal=0;
int Animal = 0,AnimalLevel = 1,AnimalHealth=0;
string AnimalName[5] = {"Shark","Seal","Whale","Stingray","Piranah"};
string CurrentAnimal = "";
int TotalAnimalHealth = AnimalHealth;


//Some set of function which I will use
void Hud() {

std::cout << " Welcome to the World of Scuba: The Explore " << name << std::endl;
sleep(1);
cout << "Your Details are mention below: " << std::endl;
cout << "Your Oxygen is: " << totalOxygen << std::endl;
cout << "Your Health is: " << TotalHealth << std::endl;
cout << "Your Level is: " << level << std::endl;
StepAhed();
};

void Combathud(){
sleep(1);
system("clear");
cout<<"Name: "<<name<<" Animal Name: "<< CurrentAnimal<<endl;
cout<<"Animal health: "<<TotalAnimalHealth<<" Animal Level: "<<AnimalLevel<<endl;
};

void Combat(){
Combathud();
int playerAttack;
int playerDamage = 8 * level/2;
int animalAttack = 3* AnimalLevel/2;

if (TotalHealth>=1 && AnimalHealth>=1){
cout<<"\n1. Attack ";
cout<<"\n2. Block";
cout<<"\n3. Run\n\n\n";
cin>>playerAttack;

if(playerAttack==1){
// attack
cout<<"You have perform an attack "<<playerDamage<<" to the "<<CurrentAnimal<<endl;
TotalAnimalHealth = AnimalHealth - playerDamage;
sleep(1);
Combat();
if(AnimalHealth>=1){
cout<<"\nAnimal is attacking on you \n";
TotalHealth = TotalHealth - animalAttack;
cout<< "\n you suffered "<<animalAttack<< "hitpoints\n";
// change to function
if(TotalHealth<=0){
TotalHealth = 0;
}
else if(TotalAnimalHealth<=0){
TotalAnimalHealth = 0;
}
sleep(1);
Combat();
}
}
else if(playerAttack==2){
// block
cout<<"\n Now Blocking...";
int i = rand()%100+1;
if(i>=50){
cout<<"\n You blocked the incomming attack...";
heal = level*10 / 2;
cout<<"You have been heal for "<<heal<<endl;
TotalHealth+=heal;
sleep(1);
Combat();
}
else{
cout<<"\n Sorry master you have been failed to block the savage attack ..";
TotalHealth -=animalAttack;
cout<<"Your health is decreases by "<<animalAttack<<endl;
sleep(1);
Combat();
}
}
else if(playerAttack==3){
// run
cout<<"Trying to runaway...";
int x = rand()%100+1;
if(x>=50){
cout<<"\n You successfully runaway...";
Hud();
}
else{
cout<<"\n Sorry master you have been failed to runaway and monster attack on you...";
TotalHealth -=animalAttack;
cout<<"Your health is decreases by "<<animalAttack<<endl;
sleep(1);
Hud();
}
}
else {
std::cout<<"Sorry I didn't expect that Please try again one more time...\n\n";
sleep(1);
Combathud();
}


}
};

void CreateAnimal(){

AnimalHealth = 50;
if (AnimalHealth==0)
{
CreateAnimal();
}

};


void StepAhed() // the use of this function is to move forward in text based game
{
int choice;

std::cout<<"1. Bingo! Let's move forward\n";
std::cout<<"2. It's dangerours time right now so be Realax and chill\n";
std::cout<<"3. Ahhh, It's time to take our Step back..\n\n";
std::cout<<"#........Now please ENTER your Choice........#\n";

std::cin>> choice;
if (choice==1){ //choice is declared on line 6
int temp = rand () % 100 +1; // It will work on probability concepts so each time it will trigger diffrent output
std::cout<<"You are moving forward ...\n";
if (temp>=50){
//Encounter an animal
CreateAnimal(); // this function will assign random animal which is located in hurdle.h
string TempName = AnimalName[rand() % 5];
std::cout<< "A"<<TempName<<" Prepares to fight..\n";
CurrentAnimal = TempName;
sleep(1);
Combat(); // this function will open in fighting.h file
}
std::cout<<"You find nothing intresting\n";
sleep(2);
Hud(); // this function is in initialfile.h
}
else if (choice==2){
std::cout<<"Now you are in your submarine and enjoying Caviar.....\n";
if(TotalHealth<=80){
TotalHealth += 10* level;
}
std::cout<<"Eating Cavir impoves your health by "<< TotalHealth<<endl;
sleep(2);
Hud();
}
else if (choice==3){
int temp = rand () % 100 +1;
std::cout<<"You are moving Backward ...\n";
if (temp>=50){
//Encounter an animal
CreateAnimal();
std::string TempName = AnimalName[rand() % 5];
std::cout<< "A"<<TempName<<" Prepares to fight..\n";
CurrentAnimal = TempName;
sleep(1);
Combat();
}
std::cout<<"You find nothing intresting\n";
sleep(2);
Hud();

}
else{
std::cout<<"Sorry I didn't expect that Please try again one more time...\n\n";
sleep(1);
Hud();
}

};



//main
int main() {
//Pre set defaults
int Oxygen = 100;
int Xp = 0;
int level = 0;
int NextLevel = 50;
int Health = 100;
TotalHealth = Health;
totalOxygen = Oxygen;
MaxOxygen = totalOxygen;

// Grabbing the player details
cout << "Please Enter Your Character Name :" << std::endl;
cin >> name;

//Fancy output checkpoint 1
cout << "Creating the Character." << endl;
sleep(1);
cout << "Creating the Character.." << std::endl;
sleep(1);
cout << "Creating the Character..." << std::endl;
sleep(1);

Hud();


}



0 comments on commit 87ba727

Please sign in to comment.