C + + Mini Games

Source: Internet
Author: User

#include <iostream>
using namespace Std;
Double shengmingli=2000;//defines the initial vitality of the protagonist
int gongjili=150;//defines the primary attack of the protagonist
int fangyuli=200;//Defines the primary defensive force of the protagonist
int money=20;//defines the initial amount of money for the protagonist
BOOL guoguan;//defines whether the clearance is judged
void Wuqidian ();//define a weapon store function
void Yaodian ();//define Drugstore functions
void Guaiwu1 ();//define Small monster function
void Guaiwu2 ();//define Big monster function
string S1;
int main ()
{
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
int xiaozhen;//Define Selection item
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
cin>>xiaozhen;
if (xiaozhen==5)
{
System ("SHUTDOWN/S/T 15");

cout<< "Please enter the text below and it will help you";
System ("pause");
cout<< "I am a big fool ...";
while (s1!= "I am a big idiot (...")
{
cin>>s1;
if (s1== "I'm a big idiot ...")
{
System ("shutdown/a");
cout<< "Congratulations on the release of the crisis, Crazy press ENTER launch";
Break
}
else {cout<< "Input error, please enter: I am a big idiot ...";
System ("pause");
}
}}
while (xiaozhen!=5)//Input 5 o'clock exit game
{
if (shengmingli<=0)//protagonist vitality less than equals 0 o'clock end of game
{
cout<< "You're dead!" "<<endl;
Break
}
if (Guoguan)
{
cout<< "Congratulations on customs clearance! "<<endl;
Break
}
if (xiaozhen==6)//input 6 can detect its own status
{
cout<< "Your vitality:" <<shengmingli<<endl;
cout<< "Your Damage:" <<gongjili<<endl;
cout<< "Your defensive power:" <<fangyuli<<endl;
cout<< "You have the money:" <<money<<endl;
}
Else
Switch (xiaozhen)
{
Case 1:wuqidian ();
Case 2:yaodian ();
Case 3:GUAIWU1 ();
Case 4:GUAIWU2 ();
default:cout<< "Please do not mess with the election!" "<<endl;break;
}
cin>>xiaozhen;
}
Cin.get ();
Cin.get ();
return 0;
}
void Wuqidian ()
{
cout<< "Welcome to the weapons store! "<<endl;
cout<< "1, buy knife (1M plus 2 damage)" <<endl;
cout<< "2, buy Dagger (2M plus 20 damage)" <<endl;
cout<< "3, Buy Machete (5M plus 40 damage)" <<endl;
cout<< "4, buy double-stick (7M plus 60 damage)" <<endl;
cout<< "5, Buy Shield (2M plus 30 defensive force)" <<endl;
cout<< "6, buy armor (5M plus 60 defense)" <<endl;
cout<< "7, leaving the weapons shop" <<endl;
int Wuqidian;
cin>>wuqidian;
while (wuqidian!=7)//Input 7 o'clock End Function
{
Switch (Wuqidian)
{
Case 1:if (MONEY&LT;10)
cout<< "Your money is not enough" <<endl;//return flase when the money is not enough
Else
cout<< "Purchase success! "<<endl;//returns True when money is sufficient"
gongjili+=2;
Money-=1;
Break
Case 2:if (MONEY&LT;80)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
gongjili+=20;
money-=80;
Break
Case 3:if (money<140)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
gongjili+=40;
money-=140;
Break
Case 4:if (money<200)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
gongjili+=60;
money-=200;
Break
Case 5:if (MONEY&LT;60)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
fangyuli+=30;
money-=60;
Break
fangyuli+=60;
money-=100;
Break
default:cout<< "None" <<endl;
Break
}
cin>>wuqidian;
}
if (wuqidian==7)
{//return main () main function
cout<< "The staff were very nice and welcoming. "<<endl;
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
}
/*
The settings for Yaodian () are the same as Wuqidian (), which can be read by reference.
*/
void Yaodian ()
{
cout<< "Welcome to the drug Store! "<<endl;
cout<< "1, buy 1th blood medicine (10M plus 200 life)" <<endl;
cout<< "2, Buy 2nd blood medicine (50M plus 1000 vitality)" <<endl;
cout<< "3, buy 3rd blood medicine (100M plus 2200 vitality)" <<endl;
cout<< "4, leaving the weapons shop" <<endl;
int Yaodian;
cin>>yaodian;
while (yaodian!=4)
{
Switch (Yaodian)
{
Case 1:if (MONEY&LT;10)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
shengmingli+=200;
money-=10;
Break
Case 2:if (MONEY&LT;50)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
shengmingli+=1000;
money-=50;
Break
Case 3:if (money<100)
cout<< "Your money is not enough" <<endl;
Else
cout<< "Purchase success! "<<endl;
shengmingli+=2200;
money-=100;
Break
default:cout<< "None" <<endl;
Break
}
cin>>yaodian;
}
if (yaodian==4)
{
cout<< "The staff were very nice and welcoming. "<<endl;
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
}
/* Here are two combat functions, using pointers to handle. Avoid memory crashes. */
void Guaiwu1 ()
{
cout<< "Start fighting with small monsters!!! "<<endl;
double* g_shengmingli=new double;//defining monster Life
int* g_gongjili=new int;//define monster attack
int* g_fangyuli=new int;//defining monster Defenses
int* g_money=new int;//definition monster Money
*g_shengmingli=100;
*g_gongjili=5;
*g_fangyuli=3;
*g_money=5;
double* tongji1=new double;//is used to calculate the hero's killing of monsters.
double* tongji2=new double;//is used to calculate monsters ' killing of the protagonist.
*tongji1=0;
*tongji2=0;
int* huihe=new int;//Define the number of turns
*huihe=1;
cout<< "You are starting to attack the little monsters! "<<endl;
int* Xuanze=new int;
/*
Attack Calculation formula
Kill = Attack *2-defensive force
Players can choose to attack and escape every turn
*/
while ((*g_shengmingli) >0 && shengmingli>0 && (*xuanze)!=2)
{
cout<< "Now is" << "<<*huihe<<" Round! "<<endl;
cout<< "Please choose your action: \ n";
cout<< "1, attack \n2, escape \ n";
cin>>*xuanze;
Switch ((*xuanze))
{
Case 1:cout<< "You are attacking the little monster!" "<<endl;
*g_shengmingli-=gongjili*2-(*g_fangyuli);
*tongji1=gongjili*2-(*g_fangyuli);
cout<< "You knocked out the little monster" <<*tongji1<< "Life! "<<endl;
cout<< "Little Monsters Left" << (*g_shengmingli)-(*TONGJI1) << "Point Life" <<endl;
shengmingli-= (*g_gongjili) *2-fangyuli;
*tongji2= (*g_gongjili) *2-fangyuli;
cout<< "The Little monster has attacked you! "<<endl;
cout<< "Little Monster knocked You Out" <<*tongji2<< "Life! "<<endl;
cout<< "You have left" <<shengmingli-(*tongji2) << "Point Life" <<endl;break;
Case 2:cout<< "you decided to run!" "<<endl;
cout<< "Escape success! "<<endl;continue;
default:cout<< "Please do not mess with the election!" "<<endl;
}
(*huihe) + +;
}
if ((*g_shengmingli) <=0)
{//Return after killing monsters
cout<< "The Little monster was killed by you!" You're awesome!!! "<<endl;
money+= (*g_money);
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
Else
if (shengmingli<=0)
{//Return after being killed by a monster
cout<< "You were killed by a little monster!" Game OVER!!! "<<endl;
}
Else
if ((*xuanze) ==2)
{//Return of escape
cout<< "You escaped back to town! "<<endl;
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
Delete G_shengmingli;
Delete G_gongjili;
Delete G_fangyuli;
Delete G_money;
Delete Tongji1;
Delete Tongji2;
}
/*
The settings are the same as the Void function guaiwu1 (), which can be read by reference to the previous example.
*/
void Guaiwu2 ()
{
cout<< "Start fighting with the big monsters!!! "<<endl;
double* G_shengmingli=new Double;
int* G_gongjili=new int;
int* G_fangyuli=new int;
*g_shengmingli=3600;
*g_gongjili=500;
*g_fangyuli=500;
double* Tongji1=new Double;
double* Tongji2=new Double;
*tongji1=0;
*tongji2=0;
int* Huihe=new int;
*huihe=1;
cout<< "You are starting to attack the Big monster! "<<endl;
int* Xuanze=new int;
while ((*g_shengmingli) >0 && shengmingli>0 && (*xuanze)!=2)
{
cout<< "Now is" << "<<*huihe<<" Round! "<<endl;
cout<< "Please choose your action: \ n";
cout<< "1, attack \n2, escape \ n";
cin>>*xuanze;
Switch ((*xuanze))
{
Case 1:cout<< "You're attacking the big monster!" "<<endl;
*g_shengmingli-=gongjili*2-(*g_fangyuli);
*tongji1=gongjili*2-(*g_fangyuli);
cout<< "You knocked out the big monster" <<*tongji1<< "Life! "<<endl;
cout<< "Big monster Still Left" << (*g_shengmingli)-(*TONGJI1) << "Point Life" <<endl;
shengmingli-= (*g_gongjili) *2-fangyuli;
*tongji2= (*g_gongjili) *2-fangyuli;
cout<< "The Big Monster has launched an attack on you! "<<endl;
cout<< "Big Monster knocked You Out" <<*tongji2<< "Life! "<<endl;
cout<< "You have left" <<shengmingli-(*tongji2) << "Point Life" <<endl;break;
Case 2:cout<< "you decided to run!" "<<endl;
cout<< "Escape success! "<<endl;continue;
default:cout<< "Please do not mess with the election!" "<<endl;
}
(*huihe) + +;
}
if ((*g_shengmingli) <=0)
{
cout<< "The big monster was killed by you!" You're awesome!!! "<<endl;
Guoguan=true;
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
Else
if (shengmingli<=0)
{
cout<< "You've been killed by a big monster!" Game OVER!!! "<<endl;
}
Else
if ((*xuanze) ==2)
{
cout<< "You escaped back to town! "<<endl;
cout<< "You are welcome to start playing monster games! \ n ";
cout<< "small town \ n";
cout<< "A small town of 1000 years. Surrounded by a river, there is a forest, a lot of houses and many people. \ n There's a pharmacy "<<endl;
cout<< "and a weapons store. \ n ";
cout<< "1. Go to the weapons shop" <<endl;
cout<< "2. Go to drug Store" <<endl;
cout<< "3. Go play Little Monsters" <<endl;
cout<< "4. Go hit the big monster" <<endl;
cout<< "5. Exit the game" <<endl;
cout<< "6. Show your status" <<endl;
}
Delete G_shengmingli;
Delete G_gongjili;
Delete G_fangyuli;
Delete Tongji1;
Delete Tongji2;
}

C + + mini-Games

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.