杨氏集团出品:打怪小游戏

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <Windows.h>
using namespace std;
void Welcome()
{
    cout << "杨";
    Sleep(300);
    cout << "氏";
    Sleep(300);
    cout << "出";
    Sleep(300);
    cout << "品";
    Sleep(300);
    cout << ":";
    Sleep(300);
    cout << "打";
    Sleep(300);
    cout << "怪";
    Sleep(300);
    cout << "小";
    Sleep(300);
    cout << "游";
    Sleep(300);
    cout << "戏" << endl;
}
int main()
{
    Welcome();
    int attack = 1;
    int defense = 10;
    int maxhp = 10;
    int hp1 = 10;
    int money = 0;
    int boss[16] = { 0,20,30,40,50,60,70,80,90,100,110,120,130,140,150 ,160 };
    int boss_attack[16] = { 0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
    double life = 100.000000;
    srand(time_t(NULL));
    while (1)
    {
    QT:
        system("cls");
        cout << "1、商城\t2、打怪\t3、恢复\t4、查看\t5、退出游戏" << endl;
        int n;
        cin >> n;
        system("cls");
        switch(n)
        {
            case 1:
            {
            FLAG:
                system("cls");
                cout << "品名\t威力\t金钱\n头盔\t抵御10\t10\n盔甲\t抵御20\t20\n防弹头盔抵御100\t100\n防弹衣\t抵御200\t200\n圣盾\t抵御320\t320\n匕首\t攻击1\t1\n长矛\t攻击30\t30\n机枪\t攻击100\t100\nAWM\t攻击300 300\n(返回初始界面)";
                string str1;
                cin >> str1;
                if (str1 == "头盔")
                {
                    if (money - 10 > 0)
                    {
                        maxhp += 10;
                        defense += 10;
                        money -= 10;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "盔甲")
                {
                    if (money - 20 > 0)
                    {
                        maxhp += 20;
                        defense += 20;
                        money -= 20;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "防弹头盔")
                {
                    if (money - 100 > 0)
                    {
                        maxhp += 100;
                        defense += 100;
                        money -= 100;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "防弹衣")
                {
                    if (money - 200 > 0)
                    {
                        maxhp += 200;
                        defense += 200;
                        money -= 200;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "圣盾")
                {
                    if (money - 320 > 0)
                    {
                        maxhp += 320;
                        defense += 320;
                        money -= 320;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "匕首")
                {
                    if (money - 1 > 0)
                    {
                        attack += 1;
                        money -= 1;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "长矛")
                {
                    if (money - 30 > 0)
                    {
                        attack += 30;
                        money -= 30;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "机枪")
                {
                    if (money - 100 > 0)
                    {
                        attack += 100;
                        money -= 100;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "AWM")
                {
                    if (money - 300 > 0)
                    {
                        attack += 300;
                        money -= 300;
                    }
                    else
                        cout << "没钱?这可是看钱的社会!" << endl;
                    system("pause");
                    goto FLAG;
                }
                else if (str1 == "返回初始界面")
                {
                    system("cls");
                    goto QT;
                }
                break;
            }
            case 2:
            {
                int k;
                IO:
                cout << "请输入对手等级(1~15)" << endl;
                cin >> k;
                system("cls");
                if (k > 15 || k < 0)
                {
                    goto IO;
                }
                system("cls");
                while (1)
                {
                    int num;
                    num = rand();
                    if (num % 2 == 0)
                    {
                        cout << "人类先攻击!" << endl;
                        system("cls");
                        boss[k] -= attack;
                        if (boss[k] <= 0)
                        {
                            cout << "人类获胜" << endl;
                            int temp1;
                            money += temp1 = rand() % 10 + 1;
                            cout << "金钱+" << temp1 << "\t剩余金钱" << money << endl;
                            system("pause");
                            system("cls");
                            break;
                        }
                    }
                    else
                    {
                        cout << "怪物先攻击!" << endl;
                        system("cls");
                        hp1 -= (boss_attack[k]-defense);
                        if (hp1 <= 0)
                        {
                            cout << "怪物获胜" << endl;
                            system("pause");
                            system("cls");
                            cout << "G";
                            Sleep(300);
                            cout << "A";
                            Sleep(300);
                            cout << "M";
                            Sleep(300);
                            cout << "E";
                            cout << " ";
                            Sleep(300);
                            cout << "O";
                            Sleep(300);
                            cout << "V";
                            Sleep(300);
                            cout << "E";
                            Sleep(300);
                            cout << "R" << endl;
                            Sleep(3000);
                            system("cls");
                            return 0;
                        }
                    }
                }
                break;
            }
            case 3:
            {
                if (money - money * 4 / 5 - 1 > 0)
                {
                    hp1 = maxhp;
                    cout << "恢复成功!" << endl;
                    money -= money * 4 / 5 - 1;
                }
                else
                    cout << "这可是看钱的时代!" << endl;
                system("pause");
                system("cls");
                break;
            }
            case 4:
            {
                cout << "金币数量:" << money << endl;
                cout << "生命值:" << hp1 << endl;
                cout << "生命值上限:" << maxhp << endl;
                cout << "攻击力:" << attack << endl;
                cout << "防御力:" << defense << endl;
                system("pause");
                system("cls");
                break;
            }
            case 5:
            {
                cout << "欢";
                Sleep(300);
                cout << "迎";
                Sleep(300);
                cout << "下";
                Sleep(300);
                cout << "次";
                Sleep(300);
                cout << "在";
                Sleep(300);
                cout << "来";
                Sleep(300);
                cout << "!" << endl;
                system("pause");
                system("cls");
                return 0;
            }
            case 6:
            {
                cout << "欢迎来到开挂世界!" << endl;
                cout << "请输入密码:";
                string i;
                cin >> i;
                if (i == "123456789" || i == "老九学堂")
                {
                    cout << "开挂成功!" << endl;
                    money += 100000;
                }
                else
                    cout << "开挂失败!" << endl;
                system("pause");
                system("cls");
            }
        }
    }
    return 0;
}

不嫌弃的话,请给一个赞!求求各位大佬给些赞!

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值