更新内容:
1.更改标题目录
2.更改字体大小
3.增加载入动画
4.合法字符命名
5.增加询问设置
6.非法输入解释
#include<bits/stdc++.h>
#include<windows.h>
#include <conio.h>
using namespace std;
void SetColorAndBackground(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
int main()
{
SetConsoleTitle("<<抽奖小程序 0.4>>");
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof cfi;
cfi.nFont = 0;
cfi.dwFontSize.X = 25;
cfi.dwFontSize.Y = 45;
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
SetColorAndBackground(15,0);
cout<<"<<载入中>>"<<endl;
SetColorAndBackground(0,15);
for(int i=1;i<=5;i++){
cout<<"■";
Beep(500,300);
Sleep(300);
}
cout<<endl;
SetColorAndBackground(15,0);
cout<<"请按任意键开始游戏";
for(int i=1;i<=6;i++){
cout<<'.';
Sleep(100);
}
getch();
system("cls");
system("color 0F");
string nemima;
cout<<"输入一个新密码:";
cin>>nemima;
cout<<"创建成功!!!"<<endl;
getch();
system("cls");
system("color 0A");
int doubi=10;
mat:
system("color 0A");
cout<<"兜币数量:"<<doubi<<endl;
cout<<"开始游戏输入1"<<endl;
cout<<"调整语言输入2(暂不支持)"<<endl;
cout<<"询问设置输入3"<<endl;
int yes;
cin>>yes;
if(yes==1){
system("cls");
cout<<"密码思密达:";
SetColorAndBackground(0,10);
string mima;
cin>>mima;
if(mima==nemima){
system("color 0A");
cout<<"Welcome back to 兜兜的抽奖点,"<<nemima;
Beep(750,400);
Beep(800,500);
Beep(520,200);
Beep(520,825);
Sleep(500);
system("cls");
sy:
system("color 0A");
if(doubi==0){
cout<<"作者:兜兜"<<endl;
Sleep(500);
cout<<"你的兜币数量像蛋仔的小黄蛋...";
Sleep(300);
return 1;
}
cout<<"简单:1"<<endl;
cout<<"一般:2"<<endl;
cout<<"困难:3"<<endl;
cout<<"兜币:"<<doubi<<endl;
int pass;
cin>>pass;
system("cls");
if(pass==1){
srand(time(0));
int sjs;
sjs=rand()%500+1;
cout<<"请输入一个数:";
int a;
cin>>a;
doubi--;
if(a==sjs){
cout<<"你真的太NB啦!兜币+3,中中中中中奖号码是:"<<sjs;
Sleep(1000);
system("cls");
doubi+=3;
goto sy;
}
else if(abs(sjs-a)<=50){
cout<<"还八错!兜币+2,中中中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi+=2;
goto sy;
}
else if(abs(sjs-a)<=100){
cout<<"That\'s good,兜币+1,中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi++;
goto sy;
}
else{
cout<<"再接再厉! 兜币+0,"<<sjs;
Sleep(3000);
system("cls");
goto sy;
}
}
if(pass==2){
srand(time(0));
int sjs;
sjs=rand()%1000+1;
cout<<"请输入一个数:";
int a;
cin>>a;
doubi--;
if(a==sjs){
cout<<"你真的太NB啦!兜币+5,中中中中中奖号码是:"<<sjs;
Sleep(1000);
system("cls");
doubi+=5;
goto sy;
}
else if(abs(sjs-a)<=100){
cout<<"还八错!兜币+3,中中中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi+=3;
goto sy;
}
else if(abs(sjs-a)<=500){
cout<<"That\'s good,兜币+2,中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi+=2;
goto sy;
}
else{
cout<<"再接再厉! 兜币+0,"<<sjs;
Sleep(3000);
system("cls");
goto sy;
}
}
if(pass==3){
srand(time(0));
int sjs;
sjs=rand()%5000+1;
cout<<"请输入一个数:";
int a;
cin>>a;
doubi--;
if(a==sjs){
cout<<"你真的太NB啦!兜币+10,中中中中中奖号码是:"<<sjs;
Sleep(1000);
system("cls");
doubi+=10;
goto sy;
}
else if(abs(sjs-a)<=300){
cout<<"还八错!兜币+5,中中中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi+=5;
goto sy;
}
else if(abs(sjs-a)<=700){
cout<<"That\'s good,兜币+3,中奖号码是:"<<sjs;
Sleep(3000);
system("cls");
doubi+=3;
goto sy;
}
else{
cout<<"再接再厉! 兜币+0,"<<sjs;
Sleep(3000);
system("cls");
goto sy;
}
}
}
}
else if(yes==3){
system("cls");
SetColorAndBackground(15,0);
cout<<"简单模式:1~500的数 符合+3 误差(<=50)+2 误差(<=100)+1"<<endl;
cout<<"普通模式:1~1000的数 符合+5 误差(<=100)+3 误差(<=500)+2"<<endl;
cout<<"困难模式:1~5000的数 符合+10 误差(<=300)+5 误差(<=700)+3"<<endl;
cout<<"按任意键返回主页>>";
getch();
system("cls");
goto mat;
}
SetColorAndBackground(15,0);
system("cls");
cout<<"\n你失败了!请检查是否有输入错误!欢迎下次再来!";
cout<<endl;
return 0;
}