前言
hello,大家好啊,这里是文宇,不是文字
小游戏教程2这不就来了吗
完善技能
上次用数组定义了技能的各项属性,现在把其补全(因为一点点原因,所以只有8个技能)
int lieri[6]={20,0,3,0,5,0};
/*烈日蚀晴:
使用出来20点伤害
可以冻结敌人0回合
可以每回合给对方造成3点追加伤害
可以给自己回复0点血量
需要5点法术值
0代表没有,1代表拥有
*/
int jinmu[6]={0,0,0,10,3,0};//浸沐春风
int kanni[6]={30,0,0,0,5,0};//坎离雷电
int lianyu[6]={15,0,5,0,5,0};//炼狱阴火
int zhuanfeng[6]={20,0,0,0,3,0};//转风术
int qianshui[6]={25,1,0,0,7,0};//千水凝冰
int huoshen[6]={40,0,0,0,10,0};//火神降临
int guyuan[6]={0,3,0,0,3,0};//锢元入石
之所以后面又加了一个是因为它要判断你是否有这个技能,而再使用新的bool定义实在是太麻烦了又要定义好几个
当然如果你觉得太少了你可以再加一点,但我并不建议这么做,因为后面有个装配技能的函数,因为没想到什么好办法所以用if堆过去的,如果你有什么好的建议可以再评论区来说一下,作者会尽量改的简单一些
装配技能
因为真想不到什么好办法,我只能用if一个一个判定过去
void zhuangpei(){
while(1){
cout<<"你有"<<yongyou<<endl<<endl;
cout<<"你的技能槽1是"<<jnc1_<<endl;
cout<<"你的技能槽2是"<<jnc2_<<endl;
cout<<"你的技能槽3是"<<jnc3_<<endl<<endl;
cout<<"输入1装配烈日蚀晴\n";
cout<<"输入2装配浸沐春风\n";
cout<<"输入3装配坎离雷电\n";
cout<<"输入4装配炼狱阴火\n";
cout<<"输入5装配转风术\n";
cout<<"输入6装配千水凝冰\n";
cout<<"输入7装配火神降临\n";
cout<<"输入8装配锢元入石\n\n";
cout<<"输入9退出\n";
cin>>sr;
if(sr==1){
if(lieri[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = lieri[i];
jnc1_="烈日蚀晴";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = lieri[i];
jnc2_="烈日蚀晴";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = lieri[i];
jnc3_="烈日蚀晴";
}
}
}
else cout<<"你没有烈日蚀晴\n";
}
if(sr==2){
if(jinmu[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = jinmu[i];
jnc1_="浸沐春风";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = jinmu[i];
jnc2_="浸沐春风";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = jinmu[i];
jnc3_="浸沐春风";
}
}
}
else cout<<"你没有浸沐春风\n";
}
if(sr==3){
if(kanni[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = kanni[i];
jnc1_="坎离雷电";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = kanni[i];
jnc2_="坎离雷电";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = kanni[i];
jnc3_="坎离雷电";
}
}
}
else cout<<"你没有坎离雷电\n";
}
if(sr==4){
if(lianyu[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = lianyu[i];
jnc1_="炼狱阴火";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = lianyu[i];
jnc2_="炼狱阴火";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = lianyu[i];
jnc3_="炼狱阴火";
}
}
}
else cout<<"你没有炼狱阴火\n";
}
if(sr==5){
if(zhuanfeng[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = zhuanfeng[i];
jnc1_="转风术";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] =zhuanfeng[i];
jnc2_="转风术";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = zhuanfeng[i];
jnc3_="转风术";
}
}
}
else cout<<"你没有转风术\n";
}
if(sr==6){
if(zhuanfeng[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = qianshui[i];
jnc1_="千水凝冰";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = qianshui[i];
jnc2_="千水凝冰";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = qianshui[i];
jnc3_="千水凝冰";
}
}
}
else cout<<"你没有千水凝冰\n";
}
if(sr==7){
if(huoshen[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = huoshen[i];
jnc1_="火神降临";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = huoshen[i];
jnc2_="火神降临";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = huoshen[i];
jnc3_="火神降临";
}
}
}
else cout<<"你没有火神降临冰\n";
}
if(sr==8){
if(guyuan[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = guyuan[i];
jnc1_="锢元入石";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = guyuan[i];
jnc2_="锢元入石";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = guyuan[i];
jnc3_="锢元入石";
}
}
}
else cout<<"你没有锢元入石\n";
}
if(sr==9) break;
}
}
因为用的是if判定过来的,所以很长,大概有个100多行,你现在应该做到为什么我不建议多定义几个技能了,因为这玩意太长了,但是如果有大佬有建议,请在评论区讨论
结语
因为写上面的这个玩意花了我很长的时间,所以今天只能草草结束,我大概每周在周二周四周六有时间,但是有的时候可能会有事情,但是一周至少一更,把目前写完的代码放在最后了,拜拜
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
int sr;//输入暂存
int zhujue[3]={20,20,3};/*
主角:
20点血量
20点法术值上限
3每回合回复一点
*/
int jnc1[6];//技能槽1
int jnc2[6];//技能槽2
int jnc3[6];//技能槽3
int lieri[6]={20,0,3,0,5,0};
/*烈日蚀晴:
使用出来20点伤害
可以冻结敌人0回合
可以每回合给对方造成3点追加伤害
可以给自己回复0点血量
需要5点法术值
0代表没有,1代表拥有
*/
int jinmu[6]={0,0,0,10,3,0};//浸沐春风
int kanni[6]={30,0,0,0,5,0};//坎离雷电
int lianyu[6]={15,0,5,0,5,0};//炼狱阴火
int zhuanfeng[6]={20,0,0,0,3,0};//转风术
int qianshui[6]={25,1,0,0,7,0};//千水凝冰
int huoshen[6]={40,0,0,0,10,0};//火神降临
int guyuan[6]={0,3,0,0,3,0};//锢元入石
string yongyou;//你拥有的
string jnc1_;//技能槽1装配技能
string jnc2_;//技能槽2装配技能
string jnc3_;//技能槽3装配技能
int diren_1[4]={10,8,3,10};
/*敌人1:
10点血
8点攻击
需要3点法术点
10点技能伤害
*/
void zhuangpei(){
while(1){
cout<<"你有"<<yongyou<<endl<<endl;
cout<<"你的技能槽1是"<<jnc1_<<endl;
cout<<"你的技能槽2是"<<jnc2_<<endl;
cout<<"你的技能槽3是"<<jnc3_<<endl<<endl;
cout<<"输入1装配烈日蚀晴\n";
cout<<"输入2装配浸沐春风\n";
cout<<"输入3装配坎离雷电\n";
cout<<"输入4装配炼狱阴火\n";
cout<<"输入5装配转风术\n";
cout<<"输入6装配千水凝冰\n";
cout<<"输入7装配火神降临\n";
cout<<"输入8装配锢元入石\n\n";
cout<<"输入9退出\n";
cin>>sr;
if(sr==1){
if(lieri[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = lieri[i];
jnc1_="烈日蚀晴";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = lieri[i];
jnc2_="烈日蚀晴";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = lieri[i];
jnc3_="烈日蚀晴";
}
}
}
else cout<<"你没有烈日蚀晴\n";
}
if(sr==2){
if(jinmu[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = jinmu[i];
jnc1_="浸沐春风";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = jinmu[i];
jnc2_="浸沐春风";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = jinmu[i];
jnc3_="浸沐春风";
}
}
}
else cout<<"你没有浸沐春风\n";
}
if(sr==3){
if(kanni[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = kanni[i];
jnc1_="坎离雷电";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = kanni[i];
jnc2_="坎离雷电";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = kanni[i];
jnc3_="坎离雷电";
}
}
}
else cout<<"你没有坎离雷电\n";
}
if(sr==4){
if(lianyu[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = lianyu[i];
jnc1_="炼狱阴火";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = lianyu[i];
jnc2_="炼狱阴火";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = lianyu[i];
jnc3_="炼狱阴火";
}
}
}
else cout<<"你没有炼狱阴火\n";
}
if(sr==5){
if(zhuanfeng[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = zhuanfeng[i];
jnc1_="转风术";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] =zhuanfeng[i];
jnc2_="转风术";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = zhuanfeng[i];
jnc3_="转风术";
}
}
}
else cout<<"你没有转风术\n";
}
if(sr==6){
if(zhuanfeng[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = qianshui[i];
jnc1_="千水凝冰";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = qianshui[i];
jnc2_="千水凝冰";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = qianshui[i];
jnc3_="千水凝冰";
}
}
}
else cout<<"你没有千水凝冰\n";
}
if(sr==7){
if(huoshen[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = huoshen[i];
jnc1_="火神降临";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = huoshen[i];
jnc2_="火神降临";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = huoshen[i];
jnc3_="火神降临";
}
}
}
else cout<<"你没有火神降临冰\n";
}
if(sr==8){
if(guyuan[5]==1){
cout<<"输入1将之装配在1号位\n";
cout<<"输入2将之装配在2号位\n";
cout<<"输入3将之装配在3号位\n";
cin>>sr;
if(sr==1){
for (int i = 0; i < 5; ++i) {
jnc1[i] = guyuan[i];
jnc1_="锢元入石";
}
}
if(sr==2){
for (int i = 0; i < 5; ++i) {
jnc2[i] = guyuan[i];
jnc2_="锢元入石";
}
}
if(sr==3){
for (int i = 0; i < 5; ++i) {
jnc3[i] = guyuan[i];
jnc3_="锢元入石";
}
}
}
else cout<<"你没有锢元入石\n";
}
if(sr==9) break;
}
}
int main(){
return 0;
}