自己做的游戏(2.0)

目录

已登录的人

未登录


已登录

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include<bits/stdc++.h>
#include<windows.h>
#include<algorithm>
#include<iostream>
#include<time.h>
#include<cmath>
using namespace std;
int main();
int random(int a,int b){//随机数 
    b-=a;
    srand(time(0)); 
    return (rand()%b)+a;//返回a和b之间的随机数 
}
void dbza(){//躲避障碍 
    system("cls");
    int w=10,a=0,fs=0;
    while(1){
        int d=random(1,18);
        //cout<<d<<endl;
        for(int n=0;n<10;n++){
            for(int i=0;i<10;i++){
                for(int t=0;t<20;t++){
                    if(i==a&&t==d){
                        cout<<"v";
                    }else if(i==9&&t==w||(i==8&&t==w)){
                        cout<<"^";
                    }else{
                        cout<<" ";
                    }if((i==8||i==9)&&(d==w)){
                        system("cls");
                        cout<<"游戏结束,得分:"<<fs;
                           Sleep(1000);
                        main();
                    }
                }
                cout<<endl;
            }
            a+=1;
            if(KEY_DOWN('A')){
                w-=1;
            }else if(KEY_DOWN('D')){
                w+=1;
            }
            if(w>18){
                w=18;
            }else if(w<1){
                w=1;
            }
            if(KEY_DOWN('B')){
                system("cls");
                cout<<"游戏结束,得分:"<<fs;
                main();
            }
            Sleep(100);
            system("cls");
        }
        a=0;
        fs+=1;
    }
}
void sj(){//射击
    system("cls");
    int x=0;
    cout<<"按K射击"; 
    char map[10][10]={{'\\',' ',' ',' ',' ',' ',' ',' ',' ','/'},
                      {' ','\\',' ',' ',' ',' ',' ',' ','/',' '},
                      {' ',' ','\\',' ',' ',' ',' ','/',' ',' '},
                      {' ',' ',' ','\\',' ',' ','/',' ',' ',' '},
                      {' ',' ',' ',' ','\\','/',' ',' ',' ',' '},
                      {' ',' ',' ',' ','/','\\',' ',' ',' ',' '},
                      {' ',' ',' ','/',' ',' ','\\',' ',' ',' '},
                      {' ',' ','/',' ',' ',' ',' ','\\',' ',' '},
                      {' ','/',' ',' ',' ',' ',' ',' ','\\',' '},
                      {'/',' ',' ',' ',' ',' ',' ',' ',' ','\\'},};
    bool cg=0;
    Sleep(2000);
    Sleep(random(1,10)*100);
    system("cls");
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cout<<map[i][j];
        }
        cout<<endl;
    }
    for(int i=0;i<1000000;i++){
        if(KEY_DOWN('K')){
            system("cls");
            cout<<"游戏成功,得分:"<<100-i/10000<<endl;
            Sleep(2000);
            cout<<"游戏结束";
            Sleep(2000);
            cg=1;
            break;
        }
    }
    if (cg==0){
        system("cls");
        cout<<"游戏失败"<<endl;
        Sleep(2000);
        cout<<"游戏结束";
        Sleep(2000);
    }
    main();
}
void kltyt(){//恐龙跳一跳
    system("cls");
    int z=0,d=30,lc=0,lq=0;
    Sleep(2000);
    while(1){
        for(int n=1;n<=30;n++){
            system("cls");
            for(int i=1;i<=25;i++){
                cout<<" ";
            }
            printf("%05d", lc);
            cout<<endl<<endl<<endl<<endl;
            if(z==1){
                cout<<"$";
            }
            cout<<endl;
            for(int i=1;i<=30;i++){
                if(i==1&&z==0){
                    cout<<"$";
                }
                if(i==d){
                    cout<<"^";
                }else{
                    cout<<" ";
                }
            }
            cout<<endl;
            for(int i=1;i<=30;i++){
                cout<<"=";
            }
            if(KEY_DOWN('W')&&lq>=0){
                z=1;
                lq-=2;
            }else{
                z=0;
                lq+=1;
            }
            d-=1;
            lc+=1;
            if(d==1&&z==0){
                system("cls");
                cout<<"游戏失败,路程:"<<lc<<endl;
                Sleep(2000);
                cout<<"游戏结束";
                Sleep(2000);
                main();
            }
            Sleep(100);
        }
        d=30;
    }
}
int main(){
    system("cls");
    int yxs=2;
    char yx; 
    cout<<endl<<"================================================欢迎来到wzh的游戏空间================================================"<<endl;
    cout<<"温馨提示:游戏前请切换至大写模式"<<endl;
    cout<<"1.躲避障碍"<<endl;
    cout<<"2.射击"<<endl;
    cout<<"3.恐龙跳一跳"<<endl;
    cout<<"请选择游戏,游戏编号:";
    cin>>yx;
    while(1){
        switch(yx){
            case '1':
                dbza();
                break;
            case '2':
                sj();
                break;
            case '3':
                kltyt();
                break;
            default:
                system("cls");
                cout<<endl<<"================================================欢迎来到wzh的游戏空间================================================"<<endl;
                cout<<"温馨提示:游戏前请切换至大写模式"<<endl;
                cout<<"1.躲避障碍"<<endl;
                cout<<"2.射击"<<endl;
                cout<<"3.恐龙跳一跳"<<endl;
                cout<<"没有找到这个游戏,请重新选择游戏,游戏编号:";
                cin>>yx;
        }
    }
}

未登录

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include<bits/stdc++.h>
#include<windows.h>
#include<algorithm>
#include<iostream>
#include<time.h>
#include<cmath>
using namespace std;
int main();
int random(int a,int b){//随机数 
    b-=a;
    srand(time(0)); 
    return (rand()%b)+a;//返回a和b之间的随机数 
}
void dbza(){//躲避障碍 
    system("cls");
    int w=10,a=0,fs=0;
    while(1){
        int d=random(1,18);
        //cout<<d<<endl;
        for(int n=0;n<10;n++){
            for(int i=0;i<10;i++){
                for(int t=0;t<20;t++){
                    if(i==a&&t==d){
                        cout<<"v";
                    }else if(i==9&&t==w||(i==8&&t==w)){
                        cout<<"^";
                    }else{
                        cout<<" ";
                    }if((i==8||i==9)&&(d==w)){
                        system("cls");
                        cout<<"游戏结束,得分:"<<fs;
                           Sleep(1000);
                        main();
                    }
                }
                cout<<endl;
            }
            a+=1;
            if(KEY_DOWN('A')){
                w-=1;
            }else if(KEY_DOWN('D')){
                w+=1;
            }
            if(w>18){
                w=18;
            }else if(w<1){
                w=1;
            }
            if(KEY_DOWN('B')){
                system("cls");
                cout<<"游戏结束,得分:"<<fs;
                main();
            }
            Sleep(100);
            system("cls");
        }
        a=0;
        fs+=1;
    }
}
void sj(){//射击
    system("cls");
    int x=0;
    cout<<"按K射击"; 
    char map[10][10]={{'\\',' ',' ',' ',' ',' ',' ',' ',' ','/'},
                      {' ','\\',' ',' ',' ',' ',' ',' ','/',' '},
                      {' ',' ','\\',' ',' ',' ',' ','/',' ',' '},
                      {' ',' ',' ','\\',' ',' ','/',' ',' ',' '},
                      {' ',' ',' ',' ','\\','/',' ',' ',' ',' '},
                      {' ',' ',' ',' ','/','\\',' ',' ',' ',' '},
                      {' ',' ',' ','/',' ',' ','\\',' ',' ',' '},
                      {' ',' ','/',' ',' ',' ',' ','\\',' ',' '},
                      {' ','/',' ',' ',' ',' ',' ',' ','\\',' '},
                      {'/',' ',' ',' ',' ',' ',' ',' ',' ','\\'},};
    bool cg=0;
    Sleep(2000);
    Sleep(random(1,10)*100);
    system("cls");
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cout<<map[i][j];
        }
        cout<<endl;
    }
    for(int i=0;i<1000000;i++){
        if(KEY_DOWN('K')){
            system("cls");
            cout<<"游戏成功,得分:"<<100-i/10000<<endl;
            Sleep(2000);
            cout<<"游戏结束";
            Sleep(2000);
            cg=1;
            break;
        }
    }
    if (cg==0){
        system("cls");
        cout<<"游戏失败"<<endl;
        Sleep(2000);
        cout<<"游戏结束";
        Sleep(2000);
    }
    main();
}
void kltyt(){//恐龙跳一跳
    system("cls");
    int z=0,d=30,lc=0,lq=0;
    Sleep(2000);
    while(1){
        for(int n=1;n<=30;n++){
            system("cls");
            for(int i=1;i<=25;i++){
                cout<<" ";
            }
            printf("%05d", lc);
            cout<<endl<<endl<<endl<<endl;
            if(z==1){
                cout<<"$";
            }
            cout<<endl;
            for(int i=1;i<=30;i++){
                if(i==1&&z==0){
                    cout<<"$";
                }
                if(i==d){
                    cout<<"^";
                }else{
                    cout<<" ";
                }
            }
            cout<<endl;
            for(int i=1;i<=30;i++){
                cout<<"=";
            }
            if(KEY_DOWN('W')&&lq>=0){
                z=1;
                lq-=2;
            }else{
                z=0;
                lq+=1;
            }
            d-=1;
            lc+=1;
            if(d==1&&z==0){
                system("cls");
                cout<<"游戏失败,路程:"<<lc<<endl;
                Sleep(2000);
                cout<<"游戏结束";
                Sleep(2000);
                main();
            }
            Sleep(100);
        }
        d=30;
    }
}
int main(){
    system("cls");
    int yxs=2;
    char yx; 
    cout<<endl<<"================================================欢迎来到wzh的游戏空间================================================"<<endl;
    cout<<"温馨提示:游戏前请切换至大写模式"<<endl;
    cout<<"1.躲避障碍"<<endl;
    cout<<"2.射击"<<endl;
    cout<<"3.恐龙跳一跳"<<endl;
    cout<<"请选择游戏,游戏编号:";
    cin>>yx;
    while(1){
        switch(yx){
            case '1':
                dbza();
                break;
            case '2':
                sj();
                break;
            case '3':
                kltyt();
                break;
            default:
                system("cls");
                cout<<endl<<"================================================欢迎来到wzh的游戏空间================================================"<<endl;
                cout<<"温馨提示:游戏前请切换至大写模式"<<endl;
                cout<<"1.躲避障碍"<<endl;
                cout<<"2.射击"<<endl;
                cout<<"3.恐龙跳一跳"<<endl;
                cout<<"没有找到这个游戏,请重新选择游戏,游戏编号:";
                cin>>yx;
        }
    }
}

  • 15
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值