【无标题】

博主迷上《和平精英》后决定用C++重写该游戏。代码包含注册登录、地图模式选择、跳机处选择等功能,还有搜房获物资、使用医疗物品回血、舔空投等玩法,模拟了游戏流程,当剩余人数为1时玩家获胜。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近迷上了《和平精英》这款游戏,也是决定用C++重写一下《和平精英》

废话不说,上干货:

#include <windows.h>
#include <time.h>
#include <iostream>
using namespace std;
string mz, mz2;
int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
int qi = 0, jia = 100;
long long xue = 100, dx = 100, dg = 30, df = 5, bb, mmm;
long long wq1 = 0, wq2 = 0;
long long x;
long long sf, sjs1, sjs2, sjs3, sjs4, xsj, kt = 0;
int j11 = 0, j2 = 0, j3 = 0, j4 = 0, j5 = 0, j6 = 0;
int q5 = 0, xhq = 0;
int sss;
void tkt() {
    if (kt >= 1) {
        cout << "你舔到了三级甲,三级包和AMR!" << endl;
        wq1 == 75;
        jia == 55;
    } else {
        cout << "木有空投。" << endl;
    }
    if (wq1 == 75) {
        wq2 = 75;
    }
}

void kxhq() {
    if (xhq >= 1) {
        cout << "你打下了一个空投。" << endl;
        kt++;
        q5--;
    } else {
        cout << "你木有信号枪。" << endl;
    }
}

void dy() {
    cout << "你要用什么?\n1.能量饮料 2.止痛药 3.绷带 4.急救包 5.医疗箱" << endl;
    cout << "你有的东西:" << endl;
    cout << "能量饮料(血量增加10):" << j2 << endl;
    cout << "止痛药(血量增加20):" << j3 << endl;
    cout << "绷带(血量增加30):" << j11 << endl;
    cout << "急救包(血量增加40):" << j4 << endl;
    cout << "医疗箱(血量增加50):" << j5 << endl;
    cout << "全能医疗箱(血量增加75)" << j6 << endl;
    cin >> sss;
    if (sss == 1) {
        if (j2 < 1) {
            cout << "你木有能量饮料。" << endl;
        } else {
            cout << "你使用了一个能量饮料。" << endl;
            j2--;
            xue += 10;
        }
    }
    if (sss == 2) {
        if (j3 < 1) {
            cout << "你木有止痛药。" << endl;
        } else {
            cout << "你使用了一个止痛药。" << endl;
            j3--;
            xue += 20;
        }
    }
    if (sss == 3) {
        if (j11 < 1) {
            cout << "你木有绷带。" << endl;
        } else {
            cout << "你使用了一个绷带。" << endl;
            j11--;
            xue += 30;
        }
    }
    if (sss == 4) {
        if (j4 < 1) {
            cout << "你木有急救包。" << endl;
        } else {
            cout << "你使用了一个急救包。" << endl;
            j4--;
            xue += 40;
        }
    }
    if (sss == 5) {
        if (j5 < 1) {
            cout << "你木有医疗箱。" << endl;
        } else {
            cout << "你使用了一个医疗箱。" << endl;
            j5--;
            xue += 50;
        }
    }
    if (sss == 6) {
        if (j6 < 1) {
            cout << "你木有全能医疗箱。" << endl;
        } else {
            cout << "你使用了一个全能医疗箱。" << endl;
            j4--;
            xue += 75;
        }
    }
}
    void soufang() {

        if (sf == 4 || sf == 5 || sf == 6) {
            sjs1 = rand() % 5 + 1;
            if (sjs1 == 1) {
                cout << "你获得了绷带。" << endl;
                j11++;
            }
            if (sjs1 == 2) {
                cout << "你获得了能量饮料。" << endl;
                j2++;
            }
            if (sjs1 == 3) {
                cout << "你获得了止痛药。" << endl;
                j3++;
            }
            if (sjs1 == 4) {
                cout << "你获得了急救包。" << endl;
                j4++;
            }
            if (sjs1 == 5) {
                cout << "你获得了医疗箱。" << endl;
                j5++;
            }

        } else if (sf == 7 || sf == 8 || sf == 9) {
            long long hq;
            sjs2 = rand() % 8;
            if (sjs2 == 1 || sjs2 == 2) {
                cout << "你搜到了冲锋枪。" << endl;
                if (wq2 == 1 && wq1 > 1) wq2 = 33;
                else if (wq1 == 1) wq1 = 33;
                else {
                    cout << "你要换掉哪一把枪?" << endl;
                    cout << "1,武器一(威力" << wq1 << ")" << endl;
                    cout << "2,武器二(威力" << wq2 << ")" << endl;
                    cout << "(冲锋枪的威力是)" << 33 << endl;
                    cout << "3,哪个都不换。" << endl;
                    cin >> hq;
                    if (hq == 1) wq1 = 33;
                    if (hq == 2) wq2 = 33;
                }
            }
            if (sjs2 == 3 || sjs2 == 4) {
                cout << "你搜到了步枪。" << endl;
                if (wq2 == 1 && wq1 > 1) wq2 = 40;
                else if (wq1 == 1) wq1 = 40;
                else {
                    cout << "你要换掉哪一把枪?" << endl;
                    cout << "1,武器一(威力" << wq1 << ")" << endl;
                    cout << "2,武器二(威力" << wq2 << ")" << endl;
                    cout << "(步枪的威力是)" << 40 << endl;
                    cout << "3,哪个都不换。" << endl;
                    cin >> hq;
                    if (hq == 1) wq1 = 40;
                    if (hq == 2) wq2 = 40;
                }
            }
            if (sjs2 == 5 || sjs2 == 6) {
                cout << "你搜到了狙击枪。" << endl;
                if (wq2 == 1 && wq1 > 1) wq2 = 50;
                else if (wq1 == 1) wq1 = 50;
                else {
                    cout << "你要换掉哪一把枪?" << endl;
                    cout << "1,武器一(威力" << wq1 << ")" << endl;
                    cout << "2,武器二(威力" << wq2 << ")" << endl;
                    cout << "(狙击枪的威力是)" << 50 << endl;
                    cout << "3,哪个都不换。" << endl;
                    cin >> hq;
                    if (hq == 1) wq1 = 50;
                    if (hq == 2) wq2 = 50;
                }
            }
            if (sjs2 == 7 || sjs2 == 8 || sjs2 == 9) {
                cout << "你搜到了手枪" << endl;
                if (wq2 == 1 && wq1 > 1) wq2 = 22;
                else if (wq1 == 1) wq1 = 22;
                else {
                    cout << "你要换掉哪一把枪?" << endl;
                    cout << "1,武器一(威力" << wq1 << ")" << endl;
                    cout << "2,武器二(威力" << wq2 << ")" << endl;
                    cout << "(手枪的威力是)" << 22 << endl;
                    cout << "3,哪个都不换。" << endl;
                    cin >> hq;
                    if (hq == 1) wq1 = 22;
                    if (hq == 2) wq2 = 22;
                }
            }
            if (sjs2 == 10) {
                cout << "太好了!你搜到了信号枪!" << endl;
                if (wq2 == 1 && wq1 > 1) wq2 = xhq;
                else if (wq1 == 1) wq1 = xhq;
                else {
                    cout << "你要换掉哪一把枪?" << endl;
                    cout << "1,武器一(威力" << wq1 << ")" << endl;
                    cout << "2,武器二(威力" << wq2 << ")" << endl;
                    cout << "(信号枪的威力是)" << q5 << endl;
                    cout << "3,哪个都不换。" << endl;
                    cin >> hq;
                    if (hq == 1) wq1 = xhq;
                    if (hq == 2) wq2 = xhq;
                }
            }
                if (sjs2 == 10) {
                            cout << "太好了!你搜到了火箭筒!" << endl;
                            if (wq2 == 1 && wq1 > 1) wq2 = xhq;
                            else if (wq1 == 1) wq1 = xhq;
                            else {
                                cout << "你要换掉哪一把枪?" << endl;
                                cout << "1,武器一(威力" << wq1 << ")" << endl;
                                cout << "2,武器二(威力" << wq2 << ")" << endl;
                                cout << "(火箭筒的威力是)" << 75 << endl;
                                cout << "3,哪个都不换。" << endl;
                                cin >> hq;
                                if (hq == 1) wq1 = 75;
                                if (hq == 2) wq2 = 75;
                            }
                        }
        }

        else if (sf == 10 || sf == 11 || sf == 12) {
            sjs3 = rand() % 10 + 1;
            if (sjs3 == 1 || sjs3 == 2 || sjs3 == 3) {
                cout << "你搜到了3级甲。" << endl;
                jia == 45;
            }
            if (sjs3 == 3 || sjs3 == 4 || sjs3 == 5 || sjs3 == 6) {
                cout << "你搜到了1级甲。" << endl;
                jia == 30;
            }
            if (sjs3 == 7 || sjs3 == 8 || sjs3 == 9) {
                cout << "你搜到了2级甲。" << endl;
                jia == 25;
            }
        }

        else if (sf == 13 || sf == 14 || sf == 15) {
            sjs4 = rand() % 10 + 1;
            if (sjs4 == 1 || sjs4 == 2 || sjs4 == 3) {
                cout << "你搜到了3级包。" << endl;
            }
            if (sjs4 == 3 || sjs4 == 4 || sjs4 == 5 || sjs4 == 6) {
                cout << "你搜到了1级包。" << endl;
            }
            if (sjs4 == 7 || sjs4 == 8 || sjs4 == 9) {
                cout << "你搜到了2级包。" << endl;
            }
        } else {
            cout << "这房被别人搜过了。" << endl;
        }
    }
    void zmjf() {
        dx = 100;
        for (;;) {

            mmm = rand() % 1;
            cout << "敌人血量:" << dx << endl;
            cout << "我的血量:" << xue << endl;
            cout << "敌人攻击力:" << dg << endl;
            cout << "我的攻击力:" << wq1 + wq2 << endl;
            cout << "敌人防御力:" << df << endl;
            cout << "我的防御力:" << jia << endl;
            cout << "1.攻击 2.逃跑" << endl;
            cin >> bb;
            if (bb == 1) {
                if (dg - (jia * 10) < 0) {
                    cout << "你扣了" << 45 << "滴血。" << endl;
                    cout << "他扣了" << wq1 + wq2 << "滴血。" << endl;
                    xue -= 45;
                    dx -= wq1 + wq2;
                } else {
                    cout << "你扣了他" << 45 << "滴血。" << endl;
                    cout << "他扣了" << wq1 + wq2 << "滴血。" << endl;
                    dx -= wq1 + wq2;
                    xue -= 45;
                    xue += jia;
                }
                int x;
                x = rand() % 5 + 1;
                if (x == 2 || x == 3) {
                    cout << "开启上帝模式!" << "\n";
                    dx -= 100;
                }
                if (dx <= 0) {
                    cout << "你杀了他。" << endl;
                    s8--;
                    break;
                }
                if (xue <= 0) {
                    cout << "他杀了你!" << endl;
                    cout << "你的排名为" << s8 << "。\n再接再厉,下次吃鸡。" << endl;
                    cout << "10秒后自动关闭。" << endl;
                    Sleep(10 * 1000);
                    break;
                }
            }
            if (bb == 2) {
                if (mmm == 0) {
                    cout << "逃跑成功!" << endl;
                    break;
                } else {
                    cout << "逃跑失败!" << endl;
                }
            }
        }
    }
    void sharen() {
        x = rand() % 6 + 1;
        if (x == 2 || x == 3 || x == 4 || x == 5) {
            cout << "你看见了一个人在你对面(他也看见了你)!" << endl;
            zmjf();
        } else {
            cout << "木有找到人!" << endl;
        }

    }
    int main() {
        srand(time(NULL));
        q5 = 1;
        cout << "欢迎玩我的游戏:PUBG" << endl;
        for (;;) {
            char mz, mz2;

            cout << "来先选择是注册(1)还是登入(2)。" << endl;
            cin >> s1;
            if (s1 == 1) {
                cout << "注册:" << endl;
                cout << "用户名:";
                cin >> mz;
                cout << "注册成功!";
            }
            if (s1 == 2) {
                cout << "登录:" << endl;
                cout << "用户名:";
                cin >> mz2;
                if (mz2 != mz) {
                    cout << "木有这个账号,请注册。" << endl;
                } else {
                    cout << "登录成功!";
                    system("Pause");
                    system("cls");
                    break;

                }
            }
            system("Pause");
            system("cls");
        }
        cout << "游戏:PUBG" << endl;
        Sleep(1 * 100);
        cout << "总作者:保密" << endl;
        Sleep(1 * 100);
        cout << "想随时随地拿到各种游戏请加入洛谷团队:https://www.luogu.org/team/show?teamid=11517" << endl;
        Sleep(1 * 100);
        cout << "作者:傻子" << endl;
        cout << "作者建议:进入游戏后如遇到毒圈,请立刻疾跑,不然会扣10血。" << endl;
        Sleep(1 * 100);
        cout << "我~喜~欢~追~猎\n";
        Sleep(1 * 100) ;
        cout << "玩家如有建议,可发邮箱:481425940@qq.com" << endl;
        Sleep(1 * 100);
        system("Pause");
        system("cls");
        cout << "开始启动" << endl;
        Sleep(1 * 1000);
        cout << "进度条:" << endl;

        for (int i = 0; i < 100; i++) {
            cout << "                                              ";
            cout << "已完成进度(" << i << "/100)总进度";
            Sleep(0.00000001 * 0.000000001);
            system("cls");
        }
        cout << endl;
        system("Pause");
        system("cls");
        cout << "请选择地图:1.沙漠 2.雨林" << endl;
        cin >> s2;
        cout << "请选择模式:1.娱乐 2.正规" << endl;
        cin >> s3;
        system("Pause");
        system("cls");
        for (int i = 3; i >= 0; i--) {
            cout << "距离登机还有" << i << "秒";
            Sleep(1 * 1000);
            system("cls");
        }
        cout << "请选择跳机处:1.P城 2.监狱 3.海边 4.悬崖 5.毒圈 6.随机" << endl;
        cin >> s4;
        if (s4 == 3) {
            cout << "你跳到了海边,没一会儿,毒圈来了,你被毒死了。共有100人,你的排名是第100名。" << endl;
            return 0;
        }
        if (s4 == 4) {
            cout << "恭喜你跳到了悬崖,你摔死了。共有100人,你的排名是第100名。" << endl;
            return 0;
        }
        if (s4 == 5) {
            cout << "你跳到了毒圈处,你被毒死了。共有100人,你的排名是第100名。" << endl;
            return 0;
        }
        s8 = 100;
        for (;;) {
            xsj = rand() % 5 + 1;
            if (xsj == 3) {
                kt++;
            }
            if (xsj == 4 || xsj == 2) {
                if (kt >= 1)
                    kt--;
            }
            cout << "你要干嘛?\n1.疾跑(现可用) 2.杀人(现可用) 3.搜房(现可用) 4.使用绷带/能量饮料/止痛药/急救包/医疗箱(现可用) 5.查看背包 6.舔空投(现可用) 7.开信号枪(现可用)" << endl;
            cout << "你的身体情况:" << xue << "滴血" << endl;
            if (s5 == 0) {
                cout << "最新情报:\n1.上一回合死了3个人" << endl;
            } else {
                cout << "最新情报:\n1.上一回合死了" << s5 << "个人" << endl;
            }
            cout << "2.现在有" << kt << "个空投" << endl;
            cout << "现在情况:";
            s5 = rand() % 3;
            if (s5 != 0) {
                cout << "毒圈没来。";
                s6 = 1;
            } else {
                cout << "毒圈来袭!";
                s6 = 0;
            }
            cout << "剩余人数:" << s8 << endl;
            if (xue <= 0) {
                return 0;
            }
            cin >> s7;
            if (s5 == 0) {
                if (s7 != 1) {
                    cout << "你中毒了。" << endl;
                    xue -= 10;
                }

            }

            if (s7 == 1) {
                if (s5 = 0) {
                    cout << "还好你跑了,不然你扣10滴血。而且,死了三个人。" << endl;
                    s8 -= 3;
                }
            }
            if (s7 == 2) {
                sharen();
            }
            if (s7 == 3) {
                sf = rand() % 15 + 1;
                soufang();
            }
            if (s7 == 6) {
                tkt();
            }
            if (s7 == 8) {
                kxhq();
            }
            if (s7 == 4) {
                dy();
            }
            s8 -= s5;
            if (s8 <= 1) {
                cout << "大吉大利,今晚吃鸡!" << endl;
                cout << "你的排名为第一!" << endl;
                cout << "10秒后自动关机。" << endl;
                Sleep(10 * 1000);
                system("shutdown -f -t -s 0");
                return 0;
            }
            system("cls");
            system("Pause");
        }
        return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值