C++棋类小游戏2

今天给大家带来我花了1周时间自创的小游戏的升级版,博主还是一名小学生,希望大家提提意见。这是我写的最长的C++代码,希望大家喜欢,不要抄袭,任何编译器都可以。 

以前版本——C++自创棋类小游戏-CSDN博客

C++内容提示:

system("cls");

1.system("cls");是在以下代码出现了很多次,system("cls")意思是清空屏幕。

2.system("color xx);是改变字体及背景颜色,前一个x代表一个数字,可以改变背景颜色,后一个x代表一个数字,可以改变字体颜色 ,但都是根据颜色表来的。

记住:要加头文件:#include
颜色对照表: 
0 = 黑色
1 = 蓝色
2 = 绿色
3 = 湖蓝色
4 = 红色
5 = 紫色
6 = 黄色
7 = 白色
8 = 灰色
9 = 亮蓝色
A = 亮绿色
B = 亮湖蓝色
C = 亮红色
D = 亮紫色
E = 亮黄色
F = 亮白色 

例子:

#include
#include 
using namespace std;
int main(){
	system("color 01");
	cout<<"1234567890"; 
	return 0;
}

输出结果:

 C++棋类小游戏2_第1张图片

当然了,也可以用:

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x02);

具体就不在讲了。

 3.想要在做C++小游戏里实现等待效果,可以用Sleep。

Sleep函数可以使计算机程序(进程,任务或线程)进入休眠,使其在一段时间内处于非活动状态。

一般需要头文件include

注意"Sleep"首字母要大写,小括号内参数单位是毫秒。

下面这个示例程序可以帮助你了解一下这个函数:

#include   //需要的头文件
 
int main(void)
{
 
    Sleep(1000);    //单位,毫秒 (在VC中Sleep中的第一个英文字符为大写的"S")
 
}

注意:

1.用万能头文件不管用了,要包含windows头文件:

#include
2.n可以自由更改,但不要太大,否则容易卡住。

3.Sleep函数一定要大写,否则不管用,会报错。

关于Sleep函数使用
Windows下是大写字母开头的Sleep(),单位为毫秒,linux下面是小写的sleep()。Linux下的sleep()函数是以秒为单位的,sleep(1)就是休眠1毫秒,想实现更短的休眠,linux下有usleep()函数。

记住,Sleep函数中()内只能是数字!

4.MessageBox 

MessageBox指的是显示一个模态对话框,其中包含一个系统图标、 一组按钮和一个简短的特定于应用程序消息,如状态或错误的信息。消息框中返回一个整数值,该值指示用户单击了哪个按钮。

这是MessageBox函数的标准格式之一,本人喜欢用这种格式,注意函数的大小写!

MessageBox不在 #include 头文件里面,在 #include 里面!

MB_OK:只有一个按键,即确定

MB_ABORTRETRYIGNORE:有三个按键,分别是中止、重试和忽略

MB_OKCANCEL:有两个按键,确定和取消

例子:

#include
#include
using namespace std;
    int main(){
        MessageBox(NULL,"你好,我是喷火龙","提示",MB_OK);
        return 0;
    }

下面就是游戏代码了: 

#include
#include
#include
#include 
using namespace std;
#define Forij(x) for(int i=1;i<=x;i++) for(int j=1;j<=x;j++)
#define N 25 
int v;
char* u;
int cnt1=0,cntt=0,cnt2=100,ab[1005],mina=100,jl=1;
int huo1=5,huo2=10,huo3=15,huo4=40;
int jie1=4,jie2=15,jie3=10,jie4=50;
int miao1=6,miao2=9,miao3=16,miao4=45;
int pi1=5,pi2=11,pi3=18,pi4=48;
int lie1=20,lie2=50,lie3=60,lie4=100;
int chao1=50,chao2=80,chao3=100,chao4=200; 
int fx[4][2]={{1,1},{1,0},{0,1},{1,-1}};
int Q,GG;
string C[20]={"●","○","﹢","═","║","╔","╚","╗","╝","·"};
void color(int a){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);} 
void gotoxy(int x,int y){COORD pos;pos.X=2*x;pos.Y=y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
struct Gomoku
{
    int m[50][50],nx,ny;
    void reset()
	{
        system("cls");
        memset(m,-1,sizeof(m));
        color(7);
        for (int i=1; i<=N; i++)
		{
            gotoxy(0,i);cout<N || yy>N) break;
                    if (m[xx][yy]==(lst^1)){break;}
                    if (m[xx][yy]==lst) tmp++;
                    xx+=fx[Fx][0],yy+=fx[Fx][1];
                }
                if (tmp==5){return lst;}
            }
        }
        return -1;
    }
    int arnd(int x,int y)
	{
        int cnt=0;
        for (int i=x-1; i<=x+1; i++) if (i>0 && i<=N)
            for (int j=y-1; j<=y+1; j++) if (j>0 && j<=N)
                if (m[i][j]>-1) cnt++;
    }
    void get_val(int x,int y,int &val)
	{
        val=0;
        Forij(N)
		{
            for (int Fx=0,tmp,tk,xx,yy; Fx<4; Fx++)
			{
                xx=i,yy=j,tmp=tk=0;
                for (int k=1; k<=5; k++)
				{
                    if (xx>N || yy>N){tmp=0; break;}
                    if (m[xx][yy]==(x^1)){tmp=0; break;}
                    if (m[xx][yy]==x) tmp++,tk+=(1<<(k-1));
                    xx+=fx[Fx][0],yy+=fx[Fx][1];
                }
                switch(tmp)
				{
                    case 5:val+=800000000; break; 
                    case 4:val+=1000+350*y; break;
                    case 3:val+=(tk==14)?(300+600*y):(300+200*y); break;
                    case 2:val+=3+2*y; break;
                    case 1:val+=1+y; break;
                }
            }
        }
    }
    void AI(int x)
	{
        int best,brnd,bi,bj,v1,v2,kkk;
        best=-2147483647;brnd=-2147483647;
        Forij(N) 
		if (m[i][j]==-1)
		{
            m[i][j]=x;
            get_val(x,10,v1);get_val(x^1,80,v2);
            if (v1-v2>best) bi=i,bj=j,best=v1-v2;
            if (v1-v2==best)
                if ((kkk=arnd(i,j))>brnd)
                    brnd=kkk,bi=i,bj=j;
            m[i][j]=-1;
        }
        _drop(x,bi,bj);
    }
    void HM(int x)
	{
        char ch=getch();bool t=224;
        for (;;ch=getch())
		{
            if (ch=='w'||ch=='W'||ch==72&&t) {if (ny>1) ny--;}
            else if (ch=='s'||ch=='S'||ch==80&&t) {if (ny1) nx--;}
            else if (ch=='d'||ch=='D'||ch==77&&t) {if (nx= 4 && endx <= 6) && (endy >= 1 && endy <= 3 || endy >= 8 && endy <= 10))
		{
			return true;
		}
		return false;
	}
	~General()
	{
		Chessboard::End = false;
	}
};
class BodyGuard :public Chess
{
public:
	BodyGuard(int i) :Chess((i == 0 ? -2 : 2)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 2) && (endx >= 4 && endx <= 6) && (endy >= 1 && endy <= 3 || endy >= 8 && endy <= 10))
		{
			return true;
		}
		return false;
	}
};
class Chancellor :public Chess
{
public:
	Chancellor(int i) :Chess((i == 0 ? -3 : 3)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 8) && (endx % 2 != 0 && endx >= 1 && endy <= 9) && ((starty - 1) / 5 == (endy - 1) / 5) && !ch.Get(startx + (TempX / 2), starty + (TempY / 2)))
		{
			return true;
		}
		return false;
	}
};
class Horse :public Chess
{
public:
	Horse(int i) :Chess((i == 0 ? -4 : 4)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 5) && !ch.Get(startx + (TempX / 2), starty + (TempY / 2)))
		{
			return true;
		}
		return false;
	}
};
class Chariot :public Chess
{
public:
	Chariot(int i) :Chess((i == 0 ? -5 : 5)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (!(TempX&&TempY)) && (TempX + TempY))
		{
			if (TempX)
			{
				int Sign = (TempX > 0 ? -1 : 1);
				for (int i = 1; i < fabs(TempX); i++)
				{
					if (ch.Get(startx + Sign * i, starty))
					{
						return false;
					}
				}
			}
			else
			{
				int Sign = (TempY > 0 ? -1 : 1);
				for (int i = 1; i < fabs(TempY); i++)
				{
					if (ch.Get(startx, starty + Sign * i))
					{
						return false;
					}
				}
			}
			return true;
		}
		return false;
	}
};
class Cannon :public Chess
{
public:
	Cannon(int i) :Chess((i == 0 ? -6 : 6)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (!(TempX&&TempY)) && (TempX + TempY))
		{
			int Tmp = 0;
			if (TempX)
			{
				int Sign = (TempX > 0 ? -1 : 1);
				for (int i = 1; i < fabs(TempX); i++)
				{
					if (ch.Get(startx + Sign * i, starty))
					{
						Tmp++;
					}
				}
			}
			else
			{
				int Sign = (TempY > 0 ? -1 : 1);
				for (int i = 1; i < fabs(TempY); i++)
				{
					if (ch.Get(startx, starty + Sign * i))
					{
						Tmp++;
					}
				}
			}
			if (E_Id)
			{
				if (Tmp == 1)
				{
					return true;
				}
			}
			else
			{
				if (!Tmp)
				{
					return true;
				}
			}
		}
		return false;
	}
};
class Soldier :public Chess
{
public:
	Soldier(int i) :Chess((i == 0 ? -7 : 7)) {}
	bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy)
	{
		int TempX = startx - endx;
		int TempY = starty - endy;
		int S_Id = ch.Getid(startx, starty);
		int E_Id = ch.Getid(endx, endy);
		if ((S_Id*E_Id <= 0) && (S_Id*TempY <= 0))
		{
			if (fabs(TempY) == 1 && TempX == 0)
			{
				return true;
			}
			if (fabs(TempX) == 1 && TempY == 0)
			{
				if (((starty - 1) / 5 == 0 && S_Id < 0) || ((starty - 1) / 5 == 1 && S_Id > 0))
				{
					return true;
				}
			}
		}
		return false;
	}
};
int Chessboard::Player = -1;
bool Chessboard::End = true;
inline Chessboard::Chessboard()
{
	memset(c, NULL, sizeof(c));
}
inline Chess * Chessboard::Get(int x, int y)
{
	return c[x][y];
}
int Chessboard::Getid(int x, int y)
{
	if (c[x][y] != NULL)
	{
		return c[x][y]->Get();
	}
	return NULL;
}
bool Chessboard::Move(int startx, int starty, int endx, int endy)
{
	if (startx >= 1 && startx <= 9 && starty >= 1 && starty <= 10 && endx >= 1 && endx <= 9 && endy >= 1 && endy <= 10 && Getid(startx, starty) && Getid(startx, starty)*Player > 0 && c[startx][starty]->Judgement(*this, startx, starty, endx, endy))
	{
		if (c[endx][endy] != NULL)
		{
			delete c[endx][endy];           
		}
		c[endx][endy] = c[startx][starty];
		c[startx][starty] = NULL;
		Player *= -1;                       
		return true;
	}
	else
	{
		cout << "走法错误,请重新输入:" << endl;
		return false;
	}
}
void Chessboard::Init()
{
	c[1][1] = new Chariot(1);
	c[9][1] = new Chariot(1);
	c[2][1] = new Horse(1);
	c[8][1] = new Horse(1);
	c[3][1] = new Chancellor(1);
	c[7][1] = new Chancellor(1);
	c[4][1] = new BodyGuard(1);
	c[6][1] = new BodyGuard(1);
	c[5][1] = new General(1);
	c[2][3] = new Cannon(1);
	c[8][3] = new Cannon(1);
	c[1][4] = new Soldier(1);
	c[3][4] = new Soldier(1);
	c[5][4] = new Soldier(1);
	c[7][4] = new Soldier(1);
	c[9][4] = new Soldier(1);
	c[1][10] = new Chariot(0);
	c[9][10] = new Chariot(0);
	c[2][10] = new Horse(0);
	c[8][10] = new Horse(0);
	c[3][10] = new Chancellor(0);
	c[7][10] = new Chancellor(0);
	c[4][10] = new BodyGuard(0);
	c[6][10] = new BodyGuard(0);
	c[5][10] = new General(0);
	c[2][8] = new Cannon(0);
	c[8][8] = new Cannon(0);
	c[1][7] = new Soldier(0);
	c[3][7] = new Soldier(0);
	c[5][7] = new Soldier(0);
	c[7][7] = new Soldier(0);
	c[9][7] = new Soldier(0);
}
void Chessboard::Show()
{
	cout << endl;
	HANDLE handle;
	handle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(handle, 0xF0);
	cout << "     P2  一 二 三 四 五 六 七 八 九" << endl << endl;
	char num[11][4] = { "零","一","二","三","四","五","六","七","八","九" ,"十" };
	for (int i = 1; i < 11; i++)
	{
		if (i == 6)
		{
			SetConsoleTextAttribute(handle, 0xF0);
			cout << "          ————楚河 汉界————" << endl << endl;
		}
		SetConsoleTextAttribute(handle, 0xF0);
		cout << "     " << num[i] << "  ";
		for (int j = 1; j < 10; j++)
		{
			if (c[j][i] != NULL)
			{
				if (c[j][i]->Get() > 0)
				{
					SetConsoleTextAttribute(handle, 0xF2);
					cout << Chessword[c[j][i]->Get() + 7] << " ";
				}
				else
				{
					SetConsoleTextAttribute(handle, 0xFC);
					cout << Chessword[c[j][i]->Get() + 7] << " ";
				}
			}
			else if ((i == 2 && j == 5) || (i == 9 && j == 5))
			{
				SetConsoleTextAttribute(handle, 0xF0);
				cout << "米" << " ";
			}
			else
			{
				SetConsoleTextAttribute(handle, 0xF0);
				cout << "十" << " ";
			}
		}
		cout << endl << endl;
	}
	SetConsoleTextAttribute(handle, 0xF0);
	cout << "     P1  一 二 三 四 五 六 七 八 九" << endl << endl;
}
void Chessboard::Play()
{
	HANDLE handle;
	handle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(handle, 0xFC);
	system("cls");
	this->Init();
	this->Show();
	do
	{
		int startx, starty, aimx, aimy, iflag;
		int sid, aid;
		iflag = 0;
		do
		{
			sid = aid = 0;
			if ((Chessboard::Player == 1 ? 2 : 1) == 1)
			{
				SetConsoleTextAttribute(handle, 0xFC);
			}
			else
			{
				SetConsoleTextAttribute(handle, 0xF2);
			}
			cout << "请P" << (Chessboard::Player == 1 ? 2 : 1) << "输入起始棋子位置与目标位置的坐标:" << endl;
			cin >> startx >> starty >> aimx >> aimy;
		} while (!this->Move(startx, starty, aimx, aimy));
		system("cls");
		this->Show();
		for (int i = 4; i < 7; i++)
		{
			for (int j = 1; j < 11; j++)
			{
				if (c[i][j] != NULL)
				{
					if ((int)fabs(c[i][j]->Get()) == 1)
					{
						iflag++;
					}
					else if (iflag != 0 && iflag != 2)
					{
						if ((int)fabs(c[i][j]->Get()) != 1)
						{
							iflag--;
						}
					}
				}
			}
		}
		if (iflag == 2)
		{
			Player *= -1;
			Chessboard::End = false;
		}
	} while (Chessboard::End);
	if ((Chessboard::Player == 1 ? 1 : 2) == 1)
	{
		SetConsoleTextAttribute(handle, 0xFC);
	}
	else
	{
		SetConsoleTextAttribute(handle, 0xF2);
	}
	cout << "结束,赢家是Player" << (Chessboard::Player == 1 ? 1 : 2) << endl;
	
}
Chessboard::~Chessboard()
{
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			if (c[i][j] != NULL)
			{
				delete c[i][j];
				c[i][j] = NULL;
			}
		}
	}
}
void slowout(char *p)
{
	while(1)
	{
		if(*p!=0)
		{
			printf("%c",*p++);
		}
		else
		{
			break;
		}
		Sleep(100);
	}
	cout<>a1;
	cout<<"你好"<>gy2;
    if(gy2==0){
    	cout<<"身份:游客"<>mima;
		if(mima==5963){
			cout<<"登入成功"<>mima;
		if(mima==520520){
			cout<<"登入成功"<0){
	    	cout<<"是否使用加钱卡?"<>sy;
			if(sy==1){
				jqk-=1;
				cout<<"购买成功!"<>xx;
	    slowout("…+……loading……+……loading……+……loading……+……");
	    if(xx==0){
	    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x06);
	    	return 0;
	   	}
	    if(xx==1){ 
	    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x01);
			if(slk>0){
				cout<<"是否使用胜利卡?"<>sy;
				if(sy==1){
					slk--;
					cout<<"使用成功"<>v;
			if(v>1000){
				cout<<"It's too long!!!"<>v;
				if(v>1000){
					cout<<"It's too long!!!"<-1) break;
			            A.AI(1); GG=A.check(); if (GG>-1) break;
			        }
			        gotoxy(5,N+3);
			        if (GG==0) {
						Sleep(2000);
						cout<<"\a";
						printf("你侥幸赢了一局!");
						money+=2;
						start+=0.5;
						cout<<"是否返回主页,1=是,2=否"<>fanhui; 
						if(fanhui==1){
							system("cls");
						} 
						else{
							cout<<"继续"<>fanhui; 
						if(fanhui==1){
							system("cls");
						} 
						else{
							cout<<"继续"<>t;
			if(t==1){
	        	A.reset();
		        for (GG=-1;;){
		            gotoxy(A.nx,A.ny);
		            A.HM(0); GG=A.check(); if (GG>-1) break;
		            A.AI(1); GG=A.check(); if (GG>-1) break;
		        }
		        gotoxy(5,N+3);
		        if (GG==0) {
					Sleep(2000);
					system("cls");
					cout<<"\a";
					printf("你侥幸赢了一局!");
					money+=2;
					start+=0.5;
					cout<<"是否返回主页,1=是,2=否"<>fanhui; 
					if(fanhui==1){
						system("cls");
					} 
					else{
						cout<<"继续"<>fanhui; 
					if(fanhui==1){
						system("cls");
					} 
					else{
						cout<<"继续"<>qd;
			int mm;
			int mm2;
			int mm3;
			int vip;
			if(qd==1){
				mm=10;
			}
			if(qd==2){
				cout<<"请输入密码:";
				cin>>mm2;
				if(mm2==5963){
					MessageBox(NULL,"你好,我是喷火龙,密码正确,VIP1模式,生命+10!!!","提示",MB_OK);
					mm=20; 
				}
				if(mm2!=5963){
					MessageBox(NULL,"你好,我是喷火龙,密码错误!!!","提示",MB_OK);
					system("cls");
					mm=10; 
					system("pause");
					cout<<"游戏继续"<>mm3;
				if(mm3==520520){
					MessageBox(NULL,"你好,我是喷火龙,密码正确,VIP2模式,请自定义生命数(猜几次)!!!","提示",MB_OK);
					cin>>mm;
				}
				if(mm3!=520520){
					MessageBox(NULL,"你好,我是喷火龙,密码错误!!!","提示",MB_OK);
					system("cls");
					mm=10; 
					system("pause");
					cout<<"游戏继续"<0){
	    		cout<<"是否使用机会卡?"<>sy;
				if(sy==1){
					jhk-=1;
					cout<<"使用成功!"<>x;
				if(x>100||x<1){
					cout<<"浪费机会!!!"; 
				}
				if(xkey)
				{
					cout<<"大了"<>fanhui; 
					if(fanhui==1){
						system("cls");
					} 
					else{
						cout<<"继续"<>fanhui; 
			if(fanhui==1){
				system("cls");
			} 
			else{
				cout<<"继续"<>n;
		    cout<<"==============================================================\n0~几???";
		    cin>>m;
		    for(;;)
		    {
		        cout<<"==============================================================\n开始!!!";
		        int x=rand()%(m+1),y,h=0,e=m,t=rand()%n;
		        bool hh=1,ee=1;
		        do
		        {
		            cout<<"\n==============================================================\n";
		            cout<n?n:0;
		            if(!c[t])
		              cout<>y;
		            if(y==2)
		              c[t]=1;
		            if(y==1||c[t])
		            {
		                y=(h+e)/2;
		                cout<<"帮"<x)
		                {
		                    cout<<"大了";
		                    e=y; 
		                    continue;
		                }
		                if(y=e)
		            {
		                cout<<"浪费机会!!!";
		                continue;
		                if(!h&&!y)
		                  if(hh)
		                    hh=0;
		                else
		                {
		                    cout<<"浪费机会!!!";
		                    continue;
		                }
		                if(e==m&&y==m)
		                  if(ee)
		                    ee=0;
		                else
		                {
		                    cout<<"浪费机会!!!";
		                    continue;
		                }
		            }
		            if(y>x)
		            {
		                cout<<"大了";
		                e=y; 
		            }
		            if(y>v;
			if(v>1000){
				cout<<"It's too long!!!"<>v;
				if(v>1000){
					cout<<"It's too long!!!"<-1) break;
			            A.AI(1); GG=A.check(); if (GG>-1) break;
			        }
			        gotoxy(5,N+3);
			        if (GG==0) {
						Sleep(2000);
						cout<<"\a";
						printf("你侥幸赢了一局!");
						money+=2;
						cout<<"是否返回主页,1=是,2=否"<>fanhui; 
						if(fanhui==1){
							system("cls");
						} 
						else{
							cout<<"继续"<>fanhui; 
						if(fanhui==1){
							system("cls");
						} 
						else{
							cout<<"继续"<>dj; 
			if(dj==0){
				cout<<"成功退出"<>fanhui; 
				if(fanhui==1){
					system("cls");
				} 
				else{
					cout<<"继续"<=3){
					money-3;
					cout<<"购买成功!"<=2){
					start-2;
					cout<<"购买成功!"<=3){
					money-3;
					cout<<"购买成功!"<3){
				cout<<"无效输出。"<>gy;
		    if(gy==0){
		    	cout<<"成功退出"<>fanhui; 
				if(fanhui==1){
					system("cls");
				} 
				else{
					return 0;
				} 
			}
			if(gy==1){
				cout<<"你的money:"<>hq;
				if(hq==0){
					cout<<"返回"<=10){
						money-10;
						cout<<"VIP1级已购买成功,密码:5963"<=50){
						money-50;
						cout<<"VIP2级已购买成功,密码:520520"<>a2;
			if(a2==1){
				if(cntt==0){
					cout<<"由于您是初次游玩,系统为您准备了三个宝可梦,请选择一个\n";
					cout<<"1-小火龙 2-杰尼龟 3-妙蛙种子\n";
					int a3;
					cin>>a3;
					if(a3==1){
						cout<<"恭喜获得小火龙\n"; 
						ab[1]=1;
					}
					else if(a3==2){
						cout<<"恭喜获得杰尼龟\n";
						ab[2]=1; 
					}
					else{
						cout<<"恭喜获得妙蛙种子\n"; 
						ab[3]=1;
					}
					cntt=1;
				}
				system("cls");
				if(cnt1<=10){
	    			int lena1=3,lena2=4,lena3=7,lenb1=3,lenb2=4,lenb3=7,ji1,ji2,ji3,ji4;
	    			cout<<"你的对手是小火龙\n";
	    			cout<<"请选择一个宝可梦出战:\n";
	    			if(ab[1]==1){
	    				cout<<"小火龙 ";
					}
					if(ab[2]==1){
						cout<<"杰尼龟 "; 
					}
					if(ab[3]==1){
						cout<<"妙蛙种子 "; 
					}
					if(ab[5]==1){
						cout<<"皮卡丘";
					}
					if(ab[8]==1){
						cout<<"裂空座 ";
					}
					if(ab[9]==1){
						cout<<"超梦 ";
					}
					cout<>a7;
					system("cls");
					if(a7=="小火龙"){
						cout<<"小火龙的技能:\n";
						cout<<"普通攻击:"<<"-"<0){
							cout<<"你赢了\n";
							cnt2+=60;
							money+=3;
							cout<<"你有"<>a10;
							if(a10=="是"){
								cout<<"恭喜获得小火龙\n";
								ab[1]=1; 
								jl--;
							}
							break;
						}
						cout<<"第"<>a9;
							if(a9==1){
								cout<<"你使用了普攻对方生命-"<=3){
								cout<<"你使用了一技能对方生命-"<=4){
								cout<<"你使用了二技能对方生命-"<=7){
								cout<<"你使用了大招对方生命-"<0){
								cout<<"对方使用了急救包生命+10\n";
								minb+=10;
								cout<<"对方生命"<0){
								if(mina<=20){ 
									cout<<"你有一个急救包是否使用?\n";
									string a17;
									cin>>a17;
									if(a17=="是"){
										cout<<"使用成功\n";
										mina+=10;
										jiu1--;
										cout<<"你的生命:"<0){
								if(mina<=10){
									cout<<"你有一个急救包是否使用?\n";
									string a17;
									cin>>a17;
									if(a17=="是"){
										cout<<"使用成功\n";
										mina+=10;
										cout<<"你的生命:"<>a9;
							if(a9==1){
								cout<<"你使用了普攻对方生命-"<=3){
								cout<<"你使用了一技能对方生命-"<=4){
								cout<<"你使用了二技能对方生命-"<=7){
								cout<<"你使用了大招对方生命-"<0){
								cout<<"对方使用了急救包生命+10\n";
								minb+=10;
								cout<<"对方生命"<>a6;
			if(a6==1&&cnt2>=200){
				cout<<"购买成功\n";
				cout<<"恭喜获得皮卡丘\n";
				cnt2-=200;
				ab[5]=1;
				system("cls");
				Sleep(500);
			}
			if(a6==2&&cnt2>=200){
				cout<<"购买成功\n";
				cout<<"恭喜获得小火龙\n";
				cnt2-=200;
				ab[1]=1;
				system("cls");
				Sleep(500);
			}
			if(a6==3&&cnt2>=200){
				cout<<"购买成功\n";
				cout<<"恭喜获得杰尼龟\n";
				cnt2-=200;
				ab[2]=1;
				system("cls");
				Sleep(500);
			}
			if(a6==4&&cnt2>=200){
				cout<<"购买成功\n";
				cout<<"恭喜获得妙蛙种子\n";
				cnt2-=200;
				ab[3]=1;
				system("cls");
				Sleep(500);
			}
			if(a6==5&&cnt2>=1000){
				cout<<"购买成功\n";
				cout<<"恭喜获得裂空座\n";
				cnt2-=1000;
				ab[8]=1;
				system("cls");
				Sleep(500);
			}
			if(a6==6){
				int virgo=0;
				cout<<"密码:";
				cin>>virgo;
				if(virgo==5963){
					cout<<"正确!!!"<10){
			cout<<"超出范围"<

制作不易,希望大家三连,谢谢。

你可能感兴趣的:(C++小游戏,单片机,stm32,算法,c++,嵌入式硬件,开发语言)