问题标题: 小游戏

0
0
已解决
冯章轩
冯章轩
初级光能
初级光能
#include<iostream>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<windows.h>
//system("cls");
//Sleep(1000);//一秒
using namespace std;
int pai=800,ban=400;
int ting=250;
    int cnt=5,cds=0;
    int main(){
    for(int i=0;i<=100;i++){
        cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
        cout<<"                                                                          "<<"游戏载入中"<<endl;
        cout<<"                                                                          "<<"   "<<"%"<<i;
        if(i>=50){
            Sleep(100);
            system("cls");          

        }else{
            Sleep(25);
            system("cls");  
        }

    }
    cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
    cout<<"                                                                   游戏加载完成";
    Sleep(950);
    system("cls");
    cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
    cout<<"  作者:  "<<endl;
    Sleep(500);
    cout<<"       "<<"                                         _______________________                          _______________________"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |______________________                          |______________________  "<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                                                |"<<endl;
    cout<<"       "<<"                                         |                           O                    |"<<endl;
    Sleep(3500);
    system("cls");
    cout<<"请打开英文输入法";
    Sleep(2500);
    system("cls");   
    int MIN=1,MAX=100,hp=7,a;
    srand((int)time(NULL));
    int  cd=MIN+rand()%(MAX-MIN+1);
    char jc;
    while(1){
        for(int i=1;i<=hp;i++){
            int ans=MIN+rand()%(MAX-MIN+1);
            srand((int)time(NULL)); 
            cout<<"      "<<"HP:"<<hp+1-i<<endl;
            cout<<"请输入一个("<<MIN<<"~"<<MAX<<")之间的数"<<endl;
            cin>>a;   
            if(a==0){
                system("cls");
                Sleep(600);//一秒
                cout<<"恭喜你抽到了彩蛋,hp+5 (^_^)☆ ";
                hp+=5; 
                cds++;
                Sleep(1900);//一秒
                system("cls");          
            }
            else if(a==cd||a==0&&cds!=0){
                system("cls");
                Sleep(2000);//一秒
                cout<<"不许刷生命! hp-5 ! ! !";
                hp-=5;
                Sleep(1500);//一秒
                system("cls");
            }
            if(a==ans&&i==1){
                cout<<"你真厉害(*^▽^*)~,一次就对了!";
                cds++;
                break;
            }
            else if(ans==a){
                cout<<"你猜对了!o( ̄▽ ̄)d"<<endl;
                cds++;
                break; 
            }
            else if(a>ans&&i<hp){
                cout<<"你猜的太大了(╬ ̄皿 ̄)"<<endl;
            } 
            else if(a<ans&&i<hp){
                cout<<"你猜的太小了(╯°Д°)╯"<<endl;
            }
            else{
                cout<<"再接再厉( ̄. ̄)\n";
                cout<<"正确答案:";
                Sleep(300);
                cout<<ans<<"!!!"; 
                Sleep(1500);
            } 
            if(cds==3){
                system("cls");
                char gl;//定义攻略
                cout<<endl<<endl<<endl;
                cout<<"                       可查看攻略,是否查看(y或n)                  "<<endl;
                cin>>gl;
                if(gl=='y'){
                    system("cls");
                    cout<<"        对半开方法"<<"\n比如到100/2等于50,输入50。此类推...";
                    Sleep(5000);//一秒
                    system("cls");
                }
                if(gl=='n'){
                    continue;
                }
        }
    }   
        Sleep(500);
        system("cls");  
        cout<<endl<<"是否继续游戏?继续按y!( ●—● )  (退出按n)"<<endl;
        cin>>jc;
        if(jc!='y'){
            break;
        } 
        system("cls");
    }
    return 0;
}

 


0
已采纳
孙浩轩
孙浩轩
中级守护
中级守护

 

有错误,请作者改正,谢谢。

0
李牧晓
李牧晓
中级天翼
中级天翼

这个游戏还可以再更新

比如储存上次玩的数据?等等......

我要回答