C++自制小游戏《袁坤》1.0版本

        OK呀,上次也是说过要更新的,所以这次我又来了,这次新增了一些功能,详见游戏内公告,直接上代码:

#include <iostream>
#include <bits/stdc++.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
using namespace std;
char a[13];
int main(){
    int L=1,life=100,dlife=100,J=1,s=1000,sj=0,sh=50;
    int h416=0,ak74n=0,scar=0,aug=0,g18c=0,m1911=0;
    cout<<"========================================="<<endl<<endl;
    cout<<"                    袁坤"<<endl<<"                   1.0版本"<<endl;
    Sleep(2000);
    system("cls");
    
    cout<<"========================================="<<endl<<endl;
    cout<<"         抵制不良游戏,拒绝盗版游戏。"<<endl;
    cout<<"         注意自我保护,谨防受骗上当。"<<endl;
    cout<<"         适度游戏益脑,沉迷游戏伤身。"<<endl;
    cout<<"         合理安排时间,享受健康生活。"<<endl<<endl;
    cout<<"              初始化资源中..."<<endl;
    int n=20;
    cout<<"            _____________________"<<endl;
    cout<<"            ";
    while(n--){
        cout<<"█";
        Sleep(300);
    }
    system("cls");
//====================================================         
    cout<<"========================================="<<endl<<endl;
    cout<<"         抵制不良游戏,拒绝盗版游戏。"<<endl;
    cout<<"         注意自我保护,谨防受骗上当。"<<endl;
    cout<<"         适度游戏益脑,沉迷游戏伤身。"<<endl;
    cout<<"         合理安排时间,享受健康生活。"<<endl<<endl;
    cout<<"             加载客户端数据中..." <<endl;
    n=20;
    cout<<"            _____________________"<<endl;
    cout<<"            ";
    while(n--){
        cout<<"█";
        Sleep(300);
    }
    system("cls");
    char x;
    cout<<"========================================="<<endl;
    cout<<"                   公告"<<endl;
    cout<<"    本游戏于11月26日更新后,新增如下功能:"<<endl;
    cout<<"    1.购买:可购买武器。对伤害有加成。"<<endl;
    cout<<"    2.手机:在手机店购买手机后,可使用"<<endl;
    cout<<"相应的功能。(购买华为有惊喜)"<<endl;
    cout<<"(按任意键继续)"<<endl;
    cin>>x;
    system("cls"); 
//====================================================         
    cout<<"========================================="<<endl<<endl;
    cout<<"    欢迎来到坤瓦特大陆,rap者,请问你叫什"<<endl;
    cout<<"么名字?"<<endl;
    cout<<"请输入你的名字(仅限中文,3个字符):"<<endl;
    for(int i=0;i<6;i++){
        cin>>a[i];
    }
    cout<<"    "<<a[0]<<a[1]<<a[2]<<a[3]<<a[4]<<a[5];
    cout<<",这是你的坤瓦特通行证,"<<endl;
    cout<<"有了它,你就能通行坤瓦特大部分地区了。"<<endl;
    Sleep(2000);
     system("cls");
//====================================================    
    cout<<"========================================="<<endl;
    cout<<"    "<<a[0]<<a[1]<<a[2]<<a[3]<<a[4]<<a[5];
    cout<<"        等级:"<<L<<"  财产:"<<s<<endl; 
    cout<<"选择要做的事情:(输入对应的序号)"<<endl;
        cout<<"A.移动  B.购买  C.出售  D.查看物品 E.探索"<<endl;
        cout<<"F.关于  G.退出"<<endl;
    while(cin>>x){
        life=100;
        dlife=100;
        if(x=='A'){//移动 
            system("cls");
            cout<<"========================================="<<endl;
            cout<<"选择要去的地方:"<<endl;
            cout<<"A.饭店  B.手机店  C.野外  D.家"<<endl;
            cin>>x;
            system("cls");
            if(x=='A'){//饭店 
                system("cls");
                cout<<"========================================="<<endl;
                cout<<"饭店正在装修,敬请期待。"<<endl;
                Sleep(1000); 
                system("cls");
            } else if(x=='B'){//手机店 
                cout<<"========================================="<<endl;
                cout<<"请问您要买什么手机?"<<endl;
                cout<<"A.小米($1000)  B.苹果($1500)"<<endl;
                cout<<"C.华为($1550)  D.离开"<<endl;
                cin>>x; 
                if(x=='A'){//小米 
                    if(s>=1000){
                        cout<<"恭喜您喜提新机!"<<endl; 
                        sj=1;
                    }else{
                        cout<<"余额不足!"<<endl;
                    }
                } 
                if(x=='B'){//苹果 
                    if(s>=1500){
                        cout<<"恭喜您喜提新机!"<<endl;
                        sj=2; 
                    }else{
                        cout<<"余额不足!"<<endl;
                    }
                } 
                if(x=='C'){//华为 
                    if(s>=1550){
                        cout<<"恭喜您喜提新机!"<<endl; 
                        sj=3;
                    }else{
                        cout<<"余额不足!"<<endl;
                    }
                } 
                Sleep(1000); 
                system("cls");
            }else if(x=='C'){//野外
                system("cls");
                cout<<"========================================="<<endl;
                cout<<"一只野生坤坤向你扑了过来!"<<endl;
                while(dlife>0){
                    if(life>0){
                        cout<<"你反击,坤坤血量-"<<sh<<"。"<<endl;
                        dlife-=sh;    
                        Sleep(500);
                    }
                    if(dlife>0){
                        cout<<"坤坤攻击,你的血量-10。"<<endl;
                        life-=10; 
                        Sleep(500);
                    }
                    if(dlife<=0){
                        cout<<"坤坤被击败,你的等级+2,财产+100。"<<endl;
                        L+=2;
                        s+=100; 
                        break;
                    }    
                }
            }else if(x=='D'){//家 
            cout<<"========================================="<<endl;
                cout<<"请选择要做的事情:"<<endl;
                cout<<"A.吃饭  B.睡觉"<<endl;
                cin>>x;
                if(x=='A'){
                    Sleep(3000);
                    cout<<"吃完了"<<endl; 
                } else if(x=='B'){
                    Sleep(5000);
                    cout<<"睡醒了"<<endl; 
                }
                Sleep(1000); 
                system("cls");
            }
        }else if(x=='B'){//购买 
                system("cls");
                cout<<"========================================="<<endl;
                cout<<"要买什么?"<<endl;
                cout<<"步枪"<<endl;
                cout<<"A.H416  B.AK74N  C.SCAR  D.AUG"<<endl;
                cout<<"($3000) ($2000)  ($2500) ($3000)"<<endl;
                cout<<"手枪"<<endl;
                cout<<"E.G18c  F.M1911"<<endl;
                cout<<"($1500) ($1000)"<<endl;
                cin>>x;
                if(x=='A'){
                    cout<<"购买成功!";
                    h416++;
                    sh=80;
                    s-=3000;
                } 
                if(x=='B'){
                    cout<<"购买成功!";
                    ak74n++;
                    sh=85;
                    s-=2000;
                } 
                if(x=='C'){
                    cout<<"购买成功!";
                    scar++;
                    sh=75;
                    s-=2500;
                } 
                if(x=='D'){
                    cout<<"购买成功!";
                    aug++;
                    sh=80;
                    s-=3000;
                } 
                if(x=='E'){
                    cout<<"购买成功!";
                    g18c++;
                    sh=60;
                    s-=1500;
                } 
                if(x=='F'){
                    cout<<"购买成功!";
                    m1911++;
                    sh=55;
                    s-=1000;
                } 
            Sleep(1000); 
                system("cls");
        }else if(x=='C'){
                system("cls");
                cout<<"========================================="<<endl;
            cout<<"此功能正在开发中,敬请期待。"<<endl; Sleep(1000); 
                system("cls");
        } else if(x=='D'){
                system("cls");
                cout<<"========================================="<<endl;
            cout<<"此功能需等“购买”“出售等功能开发后开发,敬请期待。"<<endl;Sleep(1000); 
                system("cls"); 
        }else if(x=='F'){
                system("cls");
            cout<<"========================================="<<endl<<endl;
            cout<<"    关于此游戏:"<<endl;
            cout<<"    《袁坤》是一款由原神启动(袁*杰)制作"<<endl; 
            cout<<"的C++小游戏,在游戏中,玩家将扮演一名rap"<<endl;
            cout<<"者,探索坤瓦特大陆。"<<endl;
            cout<<"                     更新于2023年11月26日"<<endl<<endl;
            cout<<"(按任意键继续)"<<endl;
            cin>>x; 
                system("cls");
        } else if(x=='E'){
                system("cls");
                cout<<"========================================="<<endl;
            cout<<"此功能正在开发中,敬请期待。"<<endl; Sleep(1000); 
                system("cls");
        }else if(x=='G'){
            cout<<"========================================="<<endl<<endl<<endl<<endl;
            cout<<"                正在退出..."<<endl;
             int n=20;
            cout<<"          _____________________"<<endl;
            cout<<"          ";
            while(n--){
            cout<<"█";
            Sleep(300);
            }
            return 0;    
        } else if(sj!=0&&x=='H'){
            if(sj==3){
                cout<<"┍-----------------┑"<<endl;
                cout<<" | 12:00           |"<<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<<" |                 |"<<endl;
                cout<<"┖-----------------┚"<<endl;
                cout<<"按1打开邮件,按2关闭手机。"<<endl;
                cin>>x;
                if(x=='1'){
                cout<<"┍-----------------┑"<<endl;
                cout<<" | 12:00           |"<<endl;
                cout<<" |-----------------|"<<endl;
                cout<<" |华为官方    9:00 |"<<endl;
                cout<<" |亲爱的用户...... |"<<endl;
                cout<<" |        (按1打开)|"<<endl;
                cout<<" |-----------------|"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" | 没有其他消息了。|"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<"┖-----------------┚"<<endl;
                cin>>x;
                if(x=='1'){
                cout<<"┍-----------------┑"<<endl;
                cout<<" | 12:00           |"<<endl;
                cout<<" |-----------------|"<<endl;
                cout<<" |华为官方    9:00 |"<<endl;
                cout<<" |亲爱的用户,您好! |"<<endl;
                cout<<" |欢迎购买本手机, |"<<endl;
                cout<<" |这是一份无限的钱 |"<<endl;
                cout<<" |财,请笑纳!      |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |-----------------|"<<endl;
                cout<<" |                 |"<<endl;
                cout<<" |财产*1000        |"<<endl;
                cout<<" |      (按1领取)  |"<<endl;
                cout<<" |                 |"<<endl;
                cout<<"┖-----------------┚"<<endl;
                cin>>x;
                if(x=='1'){
                    s+=1000;
                    system("cls");
                } 
                }
                }
                if(x=='2'){
                    system("cls");
                } 
            }
            if(sj==2){ 
                cout<<"╭-----------------╮"<<endl;
                cout<<" | 12:00           |"<<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<<" |        ○         |"<<endl;
                cout<<"╰-----------------╯"<<endl;
                cout<<"按任意键继续"<<endl;
                cin>>x;
                system("cls");
            }
            if(sj==1){
                cout<<"┍-----------------┑"<<endl;
                cout<<" | 12:00          |"<<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<<" | △    ○    □ |"<<endl;
                cout<<"┖-----------------┚"<<endl;
                cout<<"按任意键继续"<<endl;
                cin>>x;
                system("cls");
            }
        }
        cout<<"========================================="<<endl;
        cout<<"    "<<a[0]<<a[1]<<a[2]<<a[3]<<a[4]<<a[5];
    cout<<"        等级:"<<L<<"  财产:"<<s<<endl; 
        cout<<"选择要做的事情:(输入对应的序号)"<<endl;
        cout<<"A.移动  B.购买  C.出售  D.查看物品 E.探索"<<endl;
        cout<<"F.关于  G.退出"<<endl;
        if(sj!=0){
            cout<<"H.手机"; 
        }
    }    
}

359行代码,累死我了,尤其是那个手机,我调试了好几遍才好,制作不易,要个三连不过分吧。我用的是Dev C++,没有的话详见《Dev C++下载安装》(作者:82年苏打)这篇文章,里面有详细下载教程

后期还会继续更新,想要查看最新版,请关注该账号。

(如需转载请标明作者)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值