Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dcrawlerproject/endScen.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
251 lines (209 sloc)
7.75 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using tutorail https://www.bing.com/videos/search?q=c%2b%2b+dungeon+game&qpvt=c%2b%2b+dungeon+game&view=detail&mid=FF076C410F43CB92031DFF076C410F43CB92031D&&FORM=VDRVRV | |
// the below code is for end scence of text base game | |
#include<iostream> | |
#include<string> | |
#include<stdio.h> | |
#include<cstdlib> | |
#include"endScen.h" | |
using namespace std; | |
//defining the funtion so I can call it anywhere in the program | |
struct Player // Declare PERSON struct type | |
{ | |
int Health; // Declare member types | |
int Damage; | |
int Points; | |
}; | |
struct Enemy // Declare ENEMY struct type | |
{ | |
int Health; | |
int Damage; | |
}; | |
void wellcome_text() | |
{ | |
cout<< "You have reached in your final traped"<<"\n" | |
<<"You have to escape...Find your way"<<"\n" | |
<<"You enter a lightly lit room"<<"\n"<<"You see a treasure chest before you!"<<"\n" | |
<<"But before you reach to the treasure you have to kill the dragon"<<"\n" | |
<<"\n"<<endl; | |
} | |
void dwarf_enemy() | |
{ | |
bool player_win = false; | |
Player Azlan; | |
Azlan.Health = 100; | |
Azlan.Points = 50; | |
Azlan.Damage = rand()%26; | |
Enemy Dwarf; | |
Dwarf.Health = 20; | |
Dwarf.Damage = (rand()%20+1); | |
string playerresponse; | |
//..... player current detail and movement.... | |
cout<<"##################################################"<<endl; | |
cout <<"Player current Health is: "<< Azlan.Health<<endl; | |
cout<<"Player current points is: " <<Azlan.Points<<endl; | |
cout <<"Player damage is: "<< Azlan.Damage<<endl; | |
cout<<"You are inside room, you look around and you see a door "<<endl; | |
cout<<"##################################################"<<endl; | |
cout<<"\n"; | |
cout<<" Type open to open the door "<<endl; | |
cin>>playerresponse; | |
if(playerresponse == "open" || playerresponse == "Open" || playerresponse == "OPEN") | |
{ | |
cout <<"It is time to face your first enemy Dwarf"<<endl; | |
cout <<"Dwarf Health is : "<<Dwarf.Health<<endl; | |
cout <<"Dwarf Damage is : "<< Dwarf.Damage<<endl; | |
cout <<"Type Fight to fight the enemy or type Flee to run for your life and lose the game"<<endl; | |
for(Dwarf.Health = 20; Dwarf.Health>0; Dwarf.Health) | |
{ | |
cin>>playerresponse; | |
if(playerresponse == "fight"|| playerresponse == "Fight") | |
{ | |
Dwarf.Health = Dwarf.Health - Azlan.Damage; | |
cout <<"Dwarf Health is: "<<Dwarf.Health<<endl; | |
} | |
else if (playerresponse == "Flee"|| playerresponse == "flee") | |
{ | |
cout << "You lose the Game"<<endl; | |
exit(1); | |
} | |
else | |
{ | |
system("read -p 'Press Enter to continue...' var"); | |
cout<<"Type your choice fight or flee"<<endl; | |
playerresponse =""; | |
} | |
if(Dwarf.Health <=0) | |
{ | |
cout<<"Enemy defeated and continue "<<endl; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
player_win = true; | |
} | |
else if(Dwarf.Health >=0) | |
{ | |
Azlan.Health = Azlan.Health - Dwarf.Damage; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
cout<<"Type Fight again "<<endl; | |
playerresponse =""; | |
player_win = false; | |
} | |
if(Azlan.Health <=0) | |
{ | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
player_win = false; | |
cout<<"You loss the game"<<endl; | |
exit(1); | |
} | |
} | |
} | |
} | |
void dragon_enemy() | |
{ | |
bool player_win = false; | |
Player Azlan; | |
Azlan.Health = 100; | |
Azlan.Points = 50; | |
Azlan.Damage = rand()%26; | |
Enemy Dragon; | |
Dragon.Health = 50; | |
Dragon.Damage = (rand()%30+1); | |
string playerresponse; | |
cout<<"You are one step close to escaping however something is still standing in your way "<<endl; | |
cout<<"\n"; | |
cout<<"You enter a large cavern. \n Its walls climb for what seems an eternity with out end \n in the middle of the cavern you see a large dragon sleeping " << "\n"; | |
cout<<"What do you do?" << "\n" ; | |
cout<<"\n"; | |
cout <<"Type Fight to fight the enemy or type Flee to run for your life and lose the game"<<endl; | |
for(Dragon.Health = 50; Dragon.Health>0; Dragon.Health) | |
{ | |
cin>>playerresponse; | |
if(playerresponse == "fight"|| playerresponse == "Fight") | |
{ | |
Dragon.Health = Dragon.Health - Azlan.Damage; | |
cout <<"Dragon Health is: "<<Dragon.Health<<endl; | |
} | |
else if (playerresponse == "Flee"|| playerresponse == "flee") | |
{ | |
cout << "You lose the Game"<<endl; | |
exit(1); | |
} | |
else | |
{ | |
cout<<"Type your choice fight or flee"<<endl; | |
playerresponse =""; | |
system("read -n 1 -p \"Press any key to continue . . .\""); | |
} | |
if(Dragon.Health > 0) | |
{ | |
Azlan.Health = Azlan.Health - Dragon.Damage; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
cout<<"Type Fight again "<<endl; | |
playerresponse =""; | |
player_win = false; | |
} | |
if(Dragon.Health <=0) | |
{ | |
cout<<"Enemy defeated "<<endl; | |
cout<<"Well done "<<endl; | |
cout<<"You won the game" << "\n" ; | |
player_win = true; | |
} | |
if(Azlan.Health <=0) | |
{ | |
Dragon.Health = Dragon.Health -Azlan.Damage; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
player_win = false; | |
cout<<"You loss the game "<<endl; | |
exit(1); | |
} | |
cout <<"Type Fight to fight the enemy or type Flee to run for your life and lose the game"<<endl; | |
for(Dragon.Health = 50; Dragon.Health>0; Dragon.Health) | |
{ | |
cin>>playerresponse; | |
if(playerresponse == "fight"|| playerresponse == "Fight") | |
{ | |
Dragon.Health = Dragon.Health - Azlan.Damage; | |
cout <<"Dragon Health is: "<<Dragon.Health<<endl; | |
} | |
else if (playerresponse == "Flee"|| playerresponse == "flee") | |
{ | |
cout << "You lose the Game"<<endl; | |
exit(1); | |
} | |
else | |
{ | |
cout<<"Type your choice fight or flee"<<endl; | |
playerresponse =""; | |
system("read -p 'Press Enter to continue...' var"); | |
} | |
if(Dragon.Health > 0) | |
{ | |
Azlan.Health = Azlan.Health - Dragon.Damage; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
cout<<"Type Fight again "<<endl; | |
playerresponse =""; | |
player_win = false; | |
} | |
if(Dragon.Health <=0) | |
{ | |
cout<<"Enemy defeated "<<endl; | |
cout<<"Well done "<<endl; | |
cout<<"You won the game" << "\n" ; | |
player_win = true; | |
} | |
if(Azlan.Health <=0) | |
{ | |
Dragon.Health = Dragon.Health -Azlan.Damage; | |
cout<<"Player Health is: "<<Azlan.Health<<endl; | |
player_win = false; | |
cout<<"You loss the game "<<endl; | |
exit(1); | |
} | |
} | |
} | |
} | |
int Play_scene() | |
{ | |
wellcome_text(); | |
dwarf_enemy(); | |
dragon_enemy(); | |
} | |