背景

周末无聊,于是编了一个类似于cmd的小玩意。
可是越想越不对劲,所以把它改成了一个小游戏。

信息

语言:DEV_C++
源代码已公布!!

打败GG


版本:1.0(正式版)


版本:1.5(番外)


目前最新版本:2.0(英雄版)
源代码:

#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
#include <ctime>
#define srandom srand((int)time(0))
#define random(a,b) (rand()%(b-a+1)+a)
#define cl system("cls")
using namespace std;
int x=1000,y=10,apks,doks,opinfs,bigets,comes,gos,japk;
int deapks,dedoks,deopinfs,debigets,decomes,degos;
int dokbuff;
int apklow;
int agas;
int guts;
int bag[10];
int gx=2000;
bool shopbl=0;
int wearthing[10]={0,100,170,210,190,220};
int hurtggb;
int playper;
int pero;
float pert;
int perttime;
int pere;
int peretime;
int perf;
int perftime;
int perfapk;
int perfall;
void start()
{
    char ch='0';
    while(ch!='1')
    {
        cl;
        cout<<"1.开始 2.退出 3.了解背景&操作 4.关于";
        while(!kbhit())
        {

        }
        ch = getch();
        if(ch == '2')
            exit(0);
        if(ch == '3')
        {
            cl;
            cout<<"你被选定为FG勇士\n打败FG怪兽——GG获得胜利!"<<endl<<endl;
            cout<<"input:a---普攻"<<endl;
            cout<<"input:d---防御"<<endl;
            cout<<"input:o---恢复"<<endl;
            cout<<"input:s---商店"<<endl;
            cout<<"input:f---状态"<<endl;
            cout<<"input:b---杀招"<<endl;
            cout<<"input:c---召唤"<<endl;
            cout<<"input:g---回避"<<endl;
            cout<<"input:r---减CD"<<endl;
            cout<<"你会在GG的攻击下血量减少,尽快干掉他!\n 'Z'键返回";
            while(!kbhit())
            {
            }
        }
        if(ch=='4')
        {
            MessageBox(NULL,"本程序最终解释权归 GG 所有\n\n              版本号1.95","关于",MB_OK);
        }
    }
    cout<<endl<<"开始";
    Sleep(500);
    system("cls");
}
int choose(int yx)
{
    cl;
    char yxc;
    if(yx == 1)
    {
        cout<<"青龙"<<endl<<endl;
        cout<<"技能:[青龙怒吼] -------- 触发暴击效果,造成原有3倍伤害。    CD:30"<<endl<<endl;
        cout<<"-------------------\nTAB 切换英雄";
    }
    if(yx == 2)
    {
        cout<<"白虎"<<endl<<endl;
        cout<<"技能:[大灵魂术] -------- 心魔防御,受到伤害将变为原有伤害的20%,提高自身攻击30(累加),持续7回合。    CD:13"<<endl<<endl;
        cout<<"-------------------\nTAB 切换英雄";
    }
    if(yx == 3)
    {
        cout<<"朱雀"<<endl<<endl;
        cout<<"技能:[朱雀圣火] -------- 灼伤GG,每回合扣除GG生命值的20%,持续3回合。    CD:12"<<endl<<endl;
        cout<<"-------------------\nTAB 切换英雄";
    }
    if(yx == 4)
    {
        cout<<"玄武"<<endl<<endl;
        cout<<"技能:[龟图大显] -------- 吸收伤害,每次释放吸收伤害的200%,单次最多吸收7回合,一共至多吸收950点伤害,再次按下C释放伤害。    CD:19"<<endl<<endl;
        cout<<"-------------------\nTAB 切换英雄";
    }
    while(!kbhit())
    {

    }
    yxc = getch();
    if(int(yxc)==9)
    {
        yx++;
        if(yx>4)
            yx=1;
        choose(yx);
    }
    else if(int(yxc)==13)
    {
        cl;
        return yx;
    }
    else
    {
        choose(yx);
    }
}
void rewe()
{
    if(apks!=0)apks--;
    if(doks!=0)doks--;
    if(opinfs!=0)opinfs--;
    if(bigets!=0)bigets--;
    if(comes!=0)comes--;
    if(gos!=0)gos--;
}
void help()
{
    cout<<"input:a---普攻"<<endl;
    cout<<"input:d---防御"<<endl;
    cout<<"input:o---恢复"<<endl;
    cout<<"input:s---商店"<<endl;
    cout<<"input:f---状态"<<endl;
    cout<<"input:b---杀招"<<endl;
    cout<<"input:c---召唤"<<endl;
    cout<<"input:g---回避"<<endl;
    cout<<"input:r---减CD"<<endl;
    cout<<"你会在GG的攻击下血量减少,尽快干掉他!";
    rewe();
    return;
}
void apk()
{
    if(apks>0)
    {
        cout<<"You can't do it"<<endl;
        rewe();
        return;
    }
    srandom;
    int ap = random(japk + 90 + apklow, japk + 190);
    cout<<"You hurt gg "<<ap<<" hurtnumber"<<endl;
    gx -= ap;
    hurtggb += ap;
    rewe();
    apks = 5 + deapks;
    return;
}
void self()
{
    cout<<"攻击冷却 "<<apks<<endl;
    cout<<"防御冷却 "<<doks<<endl;
    cout<<"恢复冷却 "<<opinfs<<endl;
    cout<<"大招冷却 "<<bigets<<endl;
    cout<<"召唤冷却 "<<comes<<endl;
    cout<<"躲避冷却 "<<gos<<endl;
    cout<<"武器增益 "<<japk<<endl;
    cout<<"gg的生命 "<<gx<<endl;
    cout<<"gut保命 "<<guts<<endl;
    cout<<"aga复活 "<<agas<<endl;
    rewe();
    return;
}
void biget()
{
    if(bigets > 0 || y < 100)
    {
        cout<<"You can't do it";
        rewe();
        return;
    }
    srandom;
    int ap = random(japk + 100 + apklow, japk + 200);
    ap*=2;
    cout<<"You hurt gg "<<ap<<" hurtnumber"<<endl;
    gx -= ap;
    hurtggb += ap;
    rewe();
    bigets = 10 + debigets;
    y -= 100;
}
void wear(int a)
{
    if(a==1) japk+=10;
    if(a==2) japk+=5,guts+=3;
    if(a==3) agas+=1;
    if(a==4) apklow+=20;
    if(a==5)
    {
        deapks-=2;dedoks-=2;deopinfs-=2;debigets-=2;decomes-=2;degos-=2;
    }

}
char shop()
{
    rewe();
    cout<<"|1.wug     |--|攻击+10                |--|100经验     |"<<endl;
    cout<<"|2.gut     |--|攻击+05,抵挡3次致命伤害|--|170经验     |"<<endl;
    cout<<"|3.aga     |--|复活(700生命)          |--|210经验     |"<<endl;
    cout<<"|4.qaq     |--|攻击伤害下限提高10     |--|190经验     |"<<endl;
    cout<<"|5.pid     |--|全体技能CD减少2        |--|220经验     |"<<endl;
    cout<<"|按编号购买                                           |"<<endl;
    shopping_again:
    while(!kbhit())
    {
    }
    char chi;
    int a;
    chi=getch();
    if(chi>='0' && chi<='9')
    {
        a=chi-'0';
        if(wearthing[a]>y)
        {
            cout<<"You can't do it"<<endl;
            rewe();
            goto shopping_again;
        }
        y-=wearthing[a];
        bag[a]+=1;wear(a);/*----穿上----*/
        goto shopping_again;
    }
    else
        return chi;
    /*----购买----*/
}
void dok()
{
    if(doks>0)
    {
        cout<<"You can't do it"<<endl;
        rewe();
        return;
    }
    dokbuff+=3;
    rewe();
    doks=7+dedoks;
    /*----防御----*/
}
void opinf()
{
    if(opinfs>0)
    {
        cout<<"You can't do it"<<endl;
        rewe();
        return;
    }
    x+=5;
    rewe();
    opinfs=2+deopinfs;
    /*----恢复----*/
}
bool going=false;
int gotime;
void go()
{
    if(gos>0)
    {
        cout<<"You can't do it"<<endl;
        rewe();
        return;
    }
    going=true;
    gotime=7;
    rewe();
    gos=19+degos;
    /*----回避功能----*/
}
void come(int yx)
{
    if(yx == 1)
    {
        if(comes > 0)
        {
            cout<<"You can't do it";
            rewe();
            return;
        }
        srandom;
        int ap = random(japk + 100 + apklow, japk + 200);
        ap*=3;
        cout<<"Take it!!!"<<endl;
        cout<<"You hurt gg "<<ap<<" hurtnumber"<<endl;
        gx -= ap;
        hurtggb += ap;
        rewe();
        comes = 30 + decomes;
    }
    if(yx == 2)
    {
        if(comes > 0)
        {
            cout<<"You can't do it";
            rewe();
            return;
        }
        cout<<"My dream will come true!!!"<<endl;
        pert = 0.2;
        japk += 30;
        perttime += 7;
        comes = 13 + decomes;
    }
    if(yx == 3)
    {
        if(comes > 0)
        {
            cout<<"You can't do it";
            rewe();
            return;
        }
        cout<<"Fire!!!"<<endl;
        pere=1;
        peretime=3;
        comes = 12 + decomes;
    }
    if(yx == 4)
    {
        if(comes > 0 && perf==0)
        {
            cout<<"You can't do it";
            rewe();
            return;
        }
        if(perfall>950)
        {
            cout<<"I am old.Sorry,I can't do it..."<<endl;
            return;
        }
        if(perf==1)
        {
            cout<<"Kill it!"<<endl;
            perfapk*=2;
            gx-=perfapk;
            perfapk/=2;
            perfall+=perfapk;
            perf=0;
            perftime=0;
            perfapk=0;
            return;
        }
        else
        {
            cout<<"Let me ..."<<endl;
            perf=1;
            perftime=7;
            comes = 9 + decomes;
        }
    }
}
int main()
{
    start();
    playper=choose(1);
    char ch;
    while(1)
    {
        /*----开始----*/
        if(pere==1)
        {
            gx=floor(gx*0.8);
        }
        if(peretime>0)
            peretime--;
        if(peretime==0)
            pere=0;
        /*----判断是否在朱雀圣火效果内----*/
        if(perttime==0)
        {
            pert=1;
        }
        if(perttime>0)
        {
            perttime--;
        }
        /*----判断是否在大灵魂术效果内----*/
        main:
        int ap;
        if(gotime>0)
        {
            gotime--;
            goto goead;
        }
        else if(gotime==0)
            going=false;
        /*----判断是否回避----*/
        srandom;
        ap = random(20,40);
        if(dokbuff>0)
        {
            dokbuff--;
            ap=floor(ap*0.5);
        }
        ap=floor(ap*pert);
        /*----判断是否防御----*/
        if(perftime>0)
        {
            perfapk+=ap;
            ap=0;
            perftime--;
        }
        /*----判断是否龟图----*/
        goead:
        cout<<"(Press 'h' to get the help)"<<endl;
        if(going==false)
            cout<<"gg hurt you "<<ap<<" hurtnumber"<<endl<<endl,x -= ap;
        else
            cout<<"gg don't hurt you because you go"<<endl<<endl;
        cout<<"Your Blood:"<<x<<endl;
        cout<<"Your XP:"<<y<<endl;
        cout<<"GG's Blood:"<<gx<<endl;
        /*----回合基本操作----*/
        if(x<0)
        {
            if(guts>0)/*----用gut----*/
            {
                guts--;
                x+=ap;
                cout<<"You use the gut"<<endl;
                goto next1;
            }
            if(agas>0)/*----用aga----*/
            {
                agas--;
                x=700;
                cout<<"You use the aga"<<endl;
                goto next1;
            }
            cl;
            cout<<"分数:"<<hurtggb<<endl<<endl;
            cout<<"gg kill you!"<<endl;
            cout<<"Your Blood:"<<x<<endl;
            cout<<"Your XP:"<<y<<endl;
            self();
            system("pause");
            system("pause");
            system("pause");
            system("pause");
            system("pause");
            return 0;
        }
        /*----判断是否die----*/
        next1:
        if(gx<0)
        {
            cl;
            cout<<"分数:"<<hurtggb*x<<endl<<endl;
            cout<<"you kill gg!"<<endl;
            cout<<"Your Blood:"<<x<<endl;
            cout<<"Your XP:"<<y<<endl;
            self();
            system("pause");
            system("pause");
            system("pause");
            system("pause");
            system("pause");
            return 0;
        }
        /*----判断是否kill GG---*/
        y+=10;
        if(shopbl==true)/*----判断上一次是否为shop----*/
        {
            shopbl=false;
            goto jumptocase;
        }
        ch=getch();
        jumptocase:
        cout<<"----------------------------"<<endl;
        if(ch=='h')
            help();
        if(ch=='a')
            apk();
        if(ch=='r')
            cout<<"Rewe!"<<endl, rewe();
        if(ch=='f')
            self();
        if(ch=='b')
            biget();
        if(ch=='s')
        {
            ch = shop();
            if(ch<'0' || ch>'9')
            {
                shopbl=true;
                cl;
                goto main;
            }
        }
        if(ch=='d')
        {
            dok();
        }
        if(ch=='o')
        {
            opinf();
        }
        if(ch=='g')
        {
            go();
        }
        if(ch=='c')
        {
            come(playper);
        }
        /*----读入----*/
        while(!kbhit())
        {
        }
        cl;
    }
}

欢迎试玩

自编C++游戏的更多相关文章

  1. python实例:解决经典扑克牌游戏 -- 四张牌凑24点 (一)

    Hey! Hope you had a great day so far! 今天想和大家讨论的是一道我从这学期cs的期末考试得到灵感的题:Get 24 Poker Game.说到 Get 24 Pok ...

  2. 科学家有了钱以后,真是挺吓人的——D.E.Shaw的牛逼人生

    科学家有了钱以后,真是挺吓人的——D.E.Shaw的牛逼人生 黑科技,还是要提D.E.Shaw Research这个奇异的存在. 要讲这个黑科技,我们可能要扯远一点,先讲讲D.E. Shaw这个人是怎 ...

  3. D.E.Shaw——高频统计套利交易获利41亿美元

    黑科技,还是要提 D.E.Shaw Research 这个奇异的存在. 要讲这个黑科技,我们可能要扯远一点,先讲讲 D.E. Shaw 这个人是怎么学术赚钱通吃,成为彻底的人生大赢家的. D.E.Sh ...

  4. OI总结

    当下考的钟声叮当响起,该走了,一年半的OI竞赛就此结束 留下了很多遗憾.也拥有过一段美好的竞赛生活 结识了一群优秀的OI战友,一起进步一起开心一起忧愁,但这一切的一切都将在今晚变成过去式,CSp的好与 ...

  5. 少儿编程|Scratch编程教程系列合集,总有一款适合你

    如果觉得资源不错,友情转发,贵在分享!!! 少儿编程Scratch: 少儿编程Scratch第一讲:Scratch完美的初体验少儿编程Scratch第二讲:奇妙的接球小游戏少儿编程Scratch第三讲 ...

  6. 探究:编程语言那么多,为什么偏偏是 C 语言成了大学的必修课?

    谁叫你不幸生在中国了? ——何祚庥(中国科学院院士) 这是一本给非计算机专业的大学生的C语言的书.“我不是学计算机的,为啥要学C语言?”这个问题每年在中华大地都会被问上几百万次.被问的对象可能是老师, ...

  7. 编程语言那么多,为什么偏偏是C语言成了大学的必修课?

    谁叫你不幸生在中国了?--何祚庥(中国科学院院士) 这是一本给非计算机专业的大学生的C语言的书."我不是学计算机的,为啥要学C语言?"这个问题每年在中华大地都会被问上几百万次. 被 ...

  8. 老梗新玩「GitHub 热点速览 v.22.34」

    作者:HelloGitHub-小鱼干 不知道你是否和我有一样的烦恼,最近的流行梗当自己要用拿来造词时,就陷入了不知道咋"换壳"的尴尬地步.sao-gen-gen 大大减少了你老梗新 ...

  9. Swift数独游戏优化——C++与OC混编、plist自动生成

    一.为什么要C++与OC混编? 在我之前的数独游戏中涉及到的数独游戏生成算法是参考的网上其他人的算法,是利用C++来实现的.   但是在我的例子中我发现这样存在一定的局限性: 1.我是利用Termin ...

随机推荐

  1. git merge代码

    把主干合并进分支 git checkout branch git merge origin/master [一开始我使用的是git merge master,提交代码后发现主干和分支还是有差异,如果不 ...

  2. docker镜像相关的常用操作

    1.保存镜像 #docker save 镜像名称 -o 保存的完整地址和文件名 docker save zhoushiya/zhiboyuan -o d:/zhiboyuan.tar 2.载入镜像 # ...

  3. 一、c++语言基础

    1. 程序员的第一条代码"Hello,world!" #include <cstdio> //头文件,主要负责输入.输出 using namespace std;//C ...

  4. 在GPU上训练数据

    在GPU上训练数据 模型搬到GPU上 数据搬到GPU上 损失函数计算搬到GPU上

  5. (转)java垃圾回收一

    转自:http://jianfulove.iteye.com/blog/1833768 一切都进入了自动化了,但是对于各种内存溢出,内存泄漏问题的出现,我们还是很有必要学习GC的.地球人都知道,Jav ...

  6. 在多租户(容器)数据库中如何创建PDB:方法4 克隆远程Non-CDB

    基于版本:19c (12.2.0.3) AskScuti 创建方法:克隆远程Non-CDB(从 Non-CDB 中进行远程克隆).将 非CDB数据库PROD1 远程克隆为 CDB1 中的 PDB7 对 ...

  7. 神舟战神笔记本使用U盘重装系统

    今天我的神舟战神笔记本电脑系统故障了,在这里记录一下使用U盘重装系统的方法: 1.插入装机U盘. 2.按开机键,然后马上按Esc键. 3.选择Boot Manager进入. 4.选择EFI USB D ...

  8. MySql -- default 默认约束

    常用数据库约束: 一.default 默认约束: 二.not null:非空约束,指定某列不为NULL: 三.unique:唯一约束,指定某列和几列组合的数据不能重复: 四.primary key:主 ...

  9. Vue(二)

    ---恢复内容开始--- 1.vue条件指令 可以运行加减运算 可以进行if判断 <!DOCTYPE html> <html> <head> <meta ch ...

  10. 文件上传plupload组件使用

    这段时间一直在使用文件上传,简要的介绍一下文件上传的组件使用,先上一段代码. var uploader = new plupload.Uploader( { //用来指定上传方式,指定多个上传方式请使 ...