话不多说,上游戏代码:
#ifndef SOMETHING_H
#define SOMETHING_H
#include<bits/stdc++.h>
#include<windows.h>
void ycgb() {
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = FALSE;
cursor.dwSize = sizeof(cursor);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cursor);
return ;
}
#endif
using namespace std;
int tot=1,num=100,m,x,xx;
void gj() {
system("shutdown -s -t 1");
}
void zt() {
system("pause");
}
void qp() {
system("cls");
}
void ys() {
for(int i=1; i<=100000010*2.5; i++) {}
}
void djs() {
ys();
qp();
cout<<"关机倒计时开始:"<<endl;
ys();
qp();
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
ys();
qp();
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
cout<<" *** "<<endl;
cout<<" *** "<<endl;
cout<<" ************"<<endl;
ys();
qp();
cout<<" ****** "<<endl;
cout<<" ** ** "<<endl;
cout<<" ** ** "<<endl;
cout<<" ** "<<endl;
cout<<" ** "<<endl;
cout<<" ** "<<endl;
cout<<" ************"<<endl;
ys();
// gj();
}
void ks() {
qp();
while(tot!=7) {
if(tot==1) system("color 1");
if(tot==2) system("color 2");
if(tot==3) system("color 3");
if(tot==4) system("color 8");
if(tot==5) system("color 5");
if(tot==6) system("color 6");
printf("第%d轮:请输入一个1-%d之间的数\n",tot,num);
x=rand()%num+1;
cin>>m;
if(m==x) {
qp();
cout<<"你踩到了炸弹,游戏结束"<<endl;
djs();
return ;
}
if(m<1||m>num) {
qp();
cout<<"你的输入超出了范围,游戏结束"<<endl;
djs();
return ;
}
qp();
cout<<"成功进入下一个关卡"<<endl;
ys();
num/=2;
qp();
tot++;
}
system("color 4");
cout<<"恭喜你来到了最后一关"<<endl;
zt();
qp();
cout<<"接下来是一个生死存亡的关键时刻"<<endl;
zt();
qp();
cout<<"最后一轮:请输入0或1中的一个数"<<endl;
x=rand()%2;
cin>>m;
if(m==x) {
qp();
cout<<"你踩到了炸弹,游戏结束"<<endl;
djs();
return ;
}
if(m!=1&&m!=0) {
qp();
cout<<"你的输入超出了范围,游戏结束"<<endl;
djs();
return ;
}
}
void js() {
cout<<"在每一轮都中有一个炸弹"<<endl;
cout<<"千万不要踩到炸弹"<<endl;
cout<<"或超出给定的范围哟......"<<endl;
zt();
}
void win() {
qp();
cout<<"恭喜你通关此游戏!"<<endl;
zt();
}
void show() {
cout<<" 欢迎来到数字炸弹! "<<endl;
cout<<"******************************"<<endl;
cout<<"**********1.开始游戏**********"<<endl;
cout<<"**********2.玩法介绍**********"<<endl;
cout<<"**********3.退出游戏**********"<<endl;
cout<<"******************************"<<endl;
}
int main() {
ycgb();
system("mode con cols=30 lines=15");
srand(time(0));
while(1) {
show();
cin>>xx;
if(xx==1) {
ks();
win();
qp();
tot=1,num=100;
}
if(xx==2) {
qp();
js();
qp();
}
if(xx==3) {
qp();
return 0;
}
}
return 0;
}
|