自创的小游戏

自创的小游戏

	上周末没什么事情,于是写了一个游戏。听我爸说这种游戏他小时候玩过。
#include<bits/stdc++.h>
#include<conio.h> 
using namespace std;
int main()
{
	cout<<"|---------------|\n";
	cout<<"|游戏说明:     |\n";
	cout<<"|1.按a键表示向左|\n"; 
	cout<<"|2.按d键表示向右|\n";
	cout<<"|3.当分数大于50 |\n"; 
	cout<<"|时,可以按空格 |\n";
	cout<<"|键将两个球推到 |\n"; 
	cout<<"|上面去(放大招) |\n";
	cout<<"|4.按f键表示退出|\n";
	cout<<"|游戏           |\n";
	cout<<"|5.躲过一个球得1|\n";
	cout<<"|分,被球砸到扣5|\n";
	cout<<"|分,放一个大招 |\n";
	cout<<"|扣50分         |\n";
	cout<<"|6.每轮游戏的初 |\n";
	cout<<"|始分数为5分。  |\n";
	cout<<"|---------------|";
	for(int i=0;i<1000000000;i++)
	{
		//do nothing;
	}
	int ch;
	int a=9,b=0;
	srand(time(0));
	int time=5;
	int gk=1;
	while(1)
	{
		system("cls");
		cout<<endl;
		int nowzx,nowzy;
		int nowhx,nowhy;
		nowzx=rand()%10;
		nowzy=rand()%10;
		nowhx=rand()%10;
		nowhy=rand()%10;
		for(int i=0;i<100;i++)
		{
			if(time>=200)
			{
				system("cls");
				cout<<"第"<<gk+1<<"关!";
				for(int i=0;i<1000000000;i++)
				{
					//do nothing; 
				}
				gk++;
				time=5;
			}
			int flag=0;
			if(_kbhit())
			{
				ch=_getch();
				if(ch=='a'&&b>0)
				b--;
				else if(ch=='d'&&b<10)
				b++;
				else if(ch==' '&&time>50)
				{
					nowzx=-(rand()%5);
					nowhx=-(rand()%5);
					time-=50;
				}
				else if(ch=='f')
				{
					cout<<"本轮游戏分数为:"<<time<<endl;
					return 0;
				}
			}
			nowzx++;
			nowhx++;
			if(nowzx>=10)
			{
				nowzx=0;
				nowzy=b;
				time++; 
			}
			if(nowhx>=10-rand()%6+3)
			{
				nowhx=0;
				nowhy=b;
				time++;
			}
			if(nowzx==a&&nowzy==b||nowhx==a&&nowhy==b)
			{
				time-=5;
			}
			cout<<"|";
			for(int i=0;i<=9;i++)cout<<"-";
			cout<<"|\n";
			for(int i=0;i<10;i++)
			{
				cout<<"|"; 
				for(int j=0;j<10;j++)
				{
					if(i==a&&j==b)
					{
						cout<<"&";
					}
					else if(i==nowzx&&j==nowzy||i==nowhx&&j==nowhy)
					{
						cout<<"*";
					}
					else
					{
						cout<<" ";
					}
				}
				cout<<"|";
				cout<<endl;
			}
			cout<<"|";
			for(int i=0;i<=9;i++)cout<<"-";
			cout<<"|\n";
			cout<<"玩到了第"<<gk<<"关\n";
			cout<<"当前分数为:"<<time<<endl; 
			for(int i=0;i<50000000-time*125000-gk*1000000;i++)
			{
				//do nothing;
			}
			cout<<endl;
			system("cls");
		}
		cout<<endl;
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值