背景

周末无聊,于是编了一个类似于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. 831. KMP字符串(模板)

    给定一个模式串S,以及一个模板串P,所有字符串中只包含大小写英文字母以及阿拉伯数字. 模板串P在模式串S中多次作为子串出现. 求出模板串P在模式串S中所有出现的位置的起始下标. 输入格式 第一行输入整 ...

  2. python接口自动化之发送get(三)

    1.安装requests requests是python的第三方库,需要进行安装.安装之前最好先关闭fiddler cmd(win+R快捷键)输入:pip install requests 其他命令: ...

  3. macaron 根目录默认为templates文件夹,所以如果启动目录同目录下有templates目录,要给它指定另一个文件夹

    m *macaron.Macaron //随便指向一个目录,因为web没用到模板,不能使用默认值templates,因为这个目录被其他模板占用了m.Use(macaron.Renderer(macar ...

  4. Vue.js ---Hello---1

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. MyEclipse 安装 emmet 插件

    1.在线安装 地址:http://download.emmet.io/eclipse/updates/ 安装完成后重新启动myeclipse 2.离线安装 下载jar包:https://github. ...

  6. C++类几种初始化的顺序

    首先给段代码: class A{ public: ; A():x(){cout<<"A(): x="<<x<<endl;} A(int a):x ...

  7. python之路之css

    方式三 方式四 <style type="text/css"> a:link{ color: red; } a:visited { color: blue; } a:h ...

  8. python之路之线程,进程,协程

    一.线程和进程概述 1.python线程的Event 2.python线程其他和队列以及生产者消费者 3. 使用multprocessing创建进程 4.进程间数据共享方式——sharedmeory( ...

  9. Hibernate:HIbernate配置详解-HelloWorld

    hibernate介绍: Hibernate是一个开源的对象关系映射框架,它对JDBC进行了轻量级的对象封装,使Java程序员可以随心所欲的使用对象编程思维来操纵数据库. 它不仅提供了从java类到数 ...

  10. kali 插上耳机没声音

    这几天装kali装的真是心力憔悴,好不容易勉强可以使用了,插上耳机想要放松下,结果没有声音? excusu me? 在经历各种方法之后终于找到了解决方法,亲测可行. 1.先打开终端,输入systemc ...