Bootstrap

爱坤小游戏

C++控制台游戏

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
   system("color b1");
   char z;
   int a=100,b=100,gh;
   cout<<setw(280)<<"正在加载中......";
   Sleep(2000);
   system("cls");
   cout<<"-----------------------------欢迎来到《爱坤擂台赛》!---------------------------"<<endl<<endl;
   cout<<"按z键开始游戏"<<endl<<endl;
   char m;
   cin>>m;
   if (m=='z')
   {
   	cout<<"你方爱坤值:"<<a<<endl<<endl;
   	cout<<"敌方黑子值:"<<b<<endl<<endl;
   	while (true)
   	{
   		cout<<"是否发动只因技能?(1.攻击,2.防御,3.光环)"<<endl;
   		cin>>z;
   		if (z=='1')
   		{
   			srand(time(0));
   			int c=rand()%3;
   			cout<<"必杀技释放中......"<<endl<<endl;
	            system("color c4");
	            Sleep(1000);
	            system("color b1");
   			if (c==0)
   			{
	            	cout<<"漂亮的一击,敌方被击倒了!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a<<endl<<endl;
	            	cout<<"敌方黑子值:"<<b-5<<endl<<endl;
	            	b=b-5;
            	}
            	else if(c==1)
            	{
	            	cout<<"哎呦,敌方反击成功,你们同时减血了!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a-5<<endl<<endl;
	            	a=a-5;
	            	cout<<"敌方黑子值:"<<b-5<<endl<<endl;
	            	b=b-5;
           	}
           	else
           	{
	            	cout<<"哎呦,敌方攻击更强,你减血了!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a-5<<endl<<endl;
	            	a=a-5;
	            	cout<<"敌方黑子值:"<<b<<endl<<endl;
   			}
   			if(a<=0)
       		{
    				cout<<"你输了!!别气馁,下次再接再厉!";
          	 		break;
	    		}
	   			if (b<=0)
	    		{
		   			cout<<"你赢了!!恭喜你成为本次擂台赛冠军!!!";
					break;
       		}   
	        }
   		else if(z=='2') 
	    	{
	    		srand(time(0));
            	int c=rand()%3;
            	cout<<"防御技能释放中......"<<endl<<endl;
	            system("color c4");
	           	Sleep(1000);
	            system("color b1");
            	if (c==0)
           	{
	            	cout<<"漂亮的防守,敌方攻击无效!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a<<endl<<endl;
	            	cout<<"敌方黑子值:"<<b<<endl<<endl;
            	}
           	else if(c==1)
           	{
	            	cout<<"哎呦,敌方攻击太强,你减血了!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a-5<<endl<<endl;
	           	 	a=a-5;
	           		cout<<"敌方黑子值:"<<b<<endl<<endl;
          		}
          		else
          		{
	           		cout<<"哇,防御进行反弹,对方减血了!!"<<endl<<endl;
	           		cout<<"你方爱坤值:"<<a<<endl<<endl;
	           		cout<<"敌方黑子值:"<<b-5<<endl<<endl;
	           		b=b-5;
   			}
       		if(a<=0)
       		{
    				cout<<"你输了!!别气馁,下次再接再厉!";
          	 		break;
	    		}
	   			if (b<=0)
	    		{
		   			cout<<"你赢了!!恭喜你成为本次擂台赛冠军!!!";
					break;
       		}   
   		}
   		else if(z=='3')
   		{
   			cout<<"请选择一个光环!"<<endl<<endl;
   			cout<<"1:荆棘光环:可以给对方多增加1点伤害。"<<endl<<endl;
   			cout<<"2:狂暴光环:发动必杀,绝对攻击,但只等对敌方造成1点攻击。"<<endl<<endl;
   			cout<<"3:回血光环:将自身血量增加1。"<<endl<<endl;
   			cout<<"请输入:";
   			cin>>gh;
   			if(gh==1)
   			{
            		srand(time(0));
            		int c=rand()%3;
            		cout<<"必杀技释放中......"<<endl<<endl;
	            	system("color c4");
	            	Sleep(1000);
	            	system("color b1");
            		if (c==0)
            		{
	            		 cout<<"漂亮的一击,敌方被击倒了!!"<<endl<<endl;
	            		 cout<<"你方爱坤值:"<<a<<endl<<endl;
	            		 cout<<"敌方黑子值:"<<b-6<<endl<<endl;
	            		 b=b-6;
            		}
            		else if(c==1)
           		{
	            		cout<<"哎呦,敌方反击成功,你们同时减血了!!"<<endl<<endl;
	            		cout<<"你方爱坤值:"<<a-5<<endl<<endl;
	            		a=a-5;
	            		cout<<"敌方黑子值:"<<b-6<<endl<<endl;
	            	    b=b-6;
           		} 
           		else
           		{
	            		cout<<"哎呦,敌方攻击更强,你减血了!!"<<endl<<endl;
	            		cout<<"你方爱坤值:"<<a-5<<endl<<endl;
	            		a=a-5;
	            		cout<<"敌方黑子值:"<<b<<endl<<endl;
   				}
   			}
	    		else if(gh==2) 
	    		{
           		cout<<"必杀技释放中......"<<endl<<endl;
        	    	system("color c4");
	            	Sleep(1000);
	            	system("color b1");
	            	cout<<"哇,必杀生效了!!!"<<endl<<endl;
	            	cout<<"你方爱坤值:"<<a<<endl<<endl;
	            	cout<<"敌方黑子值:"<<b-1<<endl<<endl;
	            	b=b-1;
   			}
   			else if(gh==3)
   			{
   			    cout<<"回血成功!!"<<endl<<endl;
   				cout<<"你方爱坤值:"<<a+1<<endl<<endl;
	            	cout<<"敌方黑子值:"<<b<<endl<<endl;
	            	a=a+1;
   			}
   			if (a<=0)
            	{
    	        	cout<<"你输了!!别气馁,下次再接再厉!";
                	break;
	         	}
	         	if (b<=0)
	         	{
    		    	cout<<"你赢了!!恭喜你成为本次擂台赛冠军!!!";
		        	break;
	         	} 
   		}			
   	} 
 	}
   return 0;
}

;