背景

周末无聊,于是编了一个类似于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. Mysql备份参数

    --all-databases , -A 导出全部数据库. mysqldump -uroot -p --all-databases --all-tablespaces , -Y 导出全部表空间. my ...

  2. 使用TensorFlow训练模型的基本流程

    本文已在公众号机器视觉与算法建模发布,转载请联系我. 使用TensorFlow的基本流程 本篇文章将介绍使用tensorflow的训练模型的基本流程,包括制作读取TFRecord,训练和保存模型,读取 ...

  3. centos添加用户并赋予 root管理员权限

     centos添加用户并赋予 root管理员权限 用centos时,root用户一般都是超级管理员使用的,一般不轻易给别人,但是有时候同事安装软件时需要root账号,又不得不给,只能重新建一个用户,并 ...

  4. Django 初试水(一)

    2020年注定是一个不平凡的一年!坚持就是胜利,一起加油! 至于为什么使用 Django,也不想说太多.个人喜欢,这里不做介绍.直接进入主题.show me the code!!! python 的环 ...

  5. js面向对象的程序设计 --- 下篇 继承启蒙

    继承是oo语言中一个最为人津津乐道的概念.ECMAScript支持实现继承,而且实现继承只要是靠原型链来实现的 ·原型链 其基本思想是利用原型让一个引用类型继承另一个引用类型的属性和方法. 简单回顾一 ...

  6. NEON的vsub方法溢出

    关于NEON的vsub方法的溢出,结果如下: vsub会产生溢出,根据数据bit表示规律,可知溢出结果和理论正确结果形成互补,比如249-(-7)=256 使用类vreinterpretq_s16_u ...

  7. slice 实现原理

    package main /* #include <stdlib.h> */ import "C" import ( "unsafe" " ...

  8. 无聊学习一下MVP这个概念

    记录一下学习MVP,好处是便于替换前台页面(winfrom替换成asp.net),不改变页面逻辑层及其以后的层 M:业务逻辑 V:页面 P:页面逻辑 ,充当 页面和业务逻辑的中间层 规则:V和M不能直 ...

  9. SaltStack自动化软件简介及安装

    ==================================================================================================== ...

  10. 题解 P5530 [BalticOI 2002]双调路径

    P5530 [BalticOI 2002]双调路径 输入样例: 4 5 1 4 2 1 2 1 3 4 3 1 2 3 1 2 3 1 1 4 2 4 2 4 样例如下图 样例说明: 从1到4有4条路 ...