自创的小游戏
上周末没什么事情,于是写了一个游戏。听我爸说这种游戏他小时候玩过。
#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++)
{
}
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++)
{
}
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++)
{
}
cout<<endl;
system("cls");
}
cout<<endl;
}
return 0;
}