自编C++游戏
背景
周末无聊,于是编了一个类似于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++游戏的更多相关文章
- python实例:解决经典扑克牌游戏 -- 四张牌凑24点 (一)
Hey! Hope you had a great day so far! 今天想和大家讨论的是一道我从这学期cs的期末考试得到灵感的题:Get 24 Poker Game.说到 Get 24 Pok ...
- 科学家有了钱以后,真是挺吓人的——D.E.Shaw的牛逼人生
科学家有了钱以后,真是挺吓人的——D.E.Shaw的牛逼人生 黑科技,还是要提D.E.Shaw Research这个奇异的存在. 要讲这个黑科技,我们可能要扯远一点,先讲讲D.E. Shaw这个人是怎 ...
- D.E.Shaw——高频统计套利交易获利41亿美元
黑科技,还是要提 D.E.Shaw Research 这个奇异的存在. 要讲这个黑科技,我们可能要扯远一点,先讲讲 D.E. Shaw 这个人是怎么学术赚钱通吃,成为彻底的人生大赢家的. D.E.Sh ...
- OI总结
当下考的钟声叮当响起,该走了,一年半的OI竞赛就此结束 留下了很多遗憾.也拥有过一段美好的竞赛生活 结识了一群优秀的OI战友,一起进步一起开心一起忧愁,但这一切的一切都将在今晚变成过去式,CSp的好与 ...
- 少儿编程|Scratch编程教程系列合集,总有一款适合你
如果觉得资源不错,友情转发,贵在分享!!! 少儿编程Scratch: 少儿编程Scratch第一讲:Scratch完美的初体验少儿编程Scratch第二讲:奇妙的接球小游戏少儿编程Scratch第三讲 ...
- 探究:编程语言那么多,为什么偏偏是 C 语言成了大学的必修课?
谁叫你不幸生在中国了? ——何祚庥(中国科学院院士) 这是一本给非计算机专业的大学生的C语言的书.“我不是学计算机的,为啥要学C语言?”这个问题每年在中华大地都会被问上几百万次.被问的对象可能是老师, ...
- 编程语言那么多,为什么偏偏是C语言成了大学的必修课?
谁叫你不幸生在中国了?--何祚庥(中国科学院院士) 这是一本给非计算机专业的大学生的C语言的书."我不是学计算机的,为啥要学C语言?"这个问题每年在中华大地都会被问上几百万次. 被 ...
- 老梗新玩「GitHub 热点速览 v.22.34」
作者:HelloGitHub-小鱼干 不知道你是否和我有一样的烦恼,最近的流行梗当自己要用拿来造词时,就陷入了不知道咋"换壳"的尴尬地步.sao-gen-gen 大大减少了你老梗新 ...
- Swift数独游戏优化——C++与OC混编、plist自动生成
一.为什么要C++与OC混编? 在我之前的数独游戏中涉及到的数独游戏生成算法是参考的网上其他人的算法,是利用C++来实现的. 但是在我的例子中我发现这样存在一定的局限性: 1.我是利用Termin ...
随机推荐
- 四种webAPP横向滑动模式图解—H5页面开发
一.容器整体滑动(DEMO只演示A-B-C-B,下同) 模拟动画效果见下图(上),滑动分解见下图(下): DEMO地址:http://nirvana.sinaapp.com/demo_slider/s ...
- spring微服务实战 - 1 一个完整的HTTP JSON REST服务
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.Spr ...
- 服务遇到的问题 Linux
1.vnc配置: https://www.cnblogs.com/leolzi/p/9907856.html 2.遇到的问题,linux重启后不能链接的问题 rabbitmq 服务启动问题 [bf@l ...
- css公共
@charset "utf-8"; /* CSS Document */ *{ padding:; margin:; } ul,li{ list-style: none; } a{ ...
- Java学习笔记(十一)面向对象---多态
多态的体现 父类的引用指向了自己的子类对象. 父类的引用也可以接受自己的子类对象. 代码体现 abstract class Animal { public abstract void eat(); } ...
- 美化git commit历史
为什么要美化commit历史? 答:假如一个分支的多次意义相近的 commit,会把整个提交历史搞得很混乱, 此时可以将几个commit 合并为一个 commit,以美化整个 commit 历史. 怎 ...
- [Netcat] 断线重连 自动重连
今天想做些操作,所以想到了nc 但是nc太过于轻量级 所以 导致我没有找到他的断线重连功能 然后我就想到了windows的神器之一 vbs脚本 vbs代码如下 Dim a,b set a= WScri ...
- 浏览器中js执行机制学习笔记
浏览器中js执行机制学习笔记 RiverSouthMan关注 0.0772019.05.15 20:56:37字数 872阅读 291 同步任务 当一个脚本第一次执行的时候,js引擎会解析这段代码,并 ...
- 每天进步一点点------ORCAD Capture CIS 快捷键
ORCAD Capture CIS 快捷键 I: 放大O: 缩小C: 以光标所指为新的窗口显示中心 W: 画线On/OffP: 快速放置元件R: 元件旋转90°H: 元件 ...
- scrapy 框架基本使用
scrapy简介: Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 其可以应用在数据挖掘,信息处理或存储历史数据等一系列的程序中.其最初是为了页面抓取 (更确切来说, 网络抓取 ...