码迷,mamicode.com
首页 > 其他好文 > 详细

战斗系统改进

时间:2020-05-18 14:33:24      阅读:61      评论:0      收藏:0      [点我收藏+]

标签:inpu   click   mic   show   shang   getch   default   bsp   title   

增加了怪物的台词,有更多台词想法的可以发我邮箱<2393014054@qq.com>

技术图片技术图片技术图片

技术图片

技术图片
  1 #include <bits/stdc++.h>
  2 #include <windows.h>
  3 using namespace std;
  4 int main() {
  5     int fangyu=0,shengmin=20,gongji=10,tili=15,sudu=10;
  6     int choose,user_input,qiangzhigongji;
  7     int rjfangyu,rjshengmin,rjgongji,rjtili,rjsudu,rjshangxian;
  8     srand(time(NULL));
  9     cout<<"你发现了";
 10     rjfangyu=rand()%(9-7+1)+7;
 11     rjshengmin=rand()%(50-35+1)+35;
 12     rjgongji=rand()%(7-5+1)+5;
 13     rjshangxian=rand()%(13-10+1)+10;
 14     rjsudu=rand()%(9-5+1)+5;
 15     rjtili=rjshangxian;
 16     user_input=getchar();
 17 start:
 18     cout<<"怪物"<<endl;
 19     cout<<"1.查看其属性"<<endl;
 20     cout<<"2.查看自身属性"<<endl;
 21     cout<<"3.防御"<<endl;
 22     cout<<"4.攻击"<<endl;
 23     cout<<"5.技能"<<endl;
 24     cout<<"6.逃跑"<<endl;
 25     if(tili>0) {
 26         cin>>choose;
 27         system("cls");
 28         switch(choose) {
 29             case 1:
 30                 goto a1;
 31                 break;
 32             case 2:
 33                 goto a2;
 34                 break;
 35             case 3:
 36                 goto a3;
 37                 break;
 38             case 4:
 39                 goto a4;
 40                 break;
 41             case 5:
 42                 goto a5;
 43                 break;
 44             case 6:
 45                 goto a6;
 46                 break;
 47             default:
 48                 goto start;
 49         }
 50     } else {
 51         cout<<"你的体力已耗尽,轮到怪物了"<<endl;
 52         Sleep(1500);
 53         choose=rand()%(4-1+1)+1;
 54         switch(choose) {
 55             case 1:
 56                 cout<<"怪物:哈哈,天道好轮回,苍天饶过谁!" <<endl;
 57                 break;
 58             case 2:
 59                 cout<<"怪物:哈哈,待我长发及腰,你已成夜宵!" <<endl;
 60                 break;
 61             case 3:
 62                 cout<<"怪物:哈哈,今朝有酒今朝醉,大铁锅里两行泪!" <<endl;
 63                 break;
 64             case 4:
 65                 cout<<"怪物:哈哈,有缘千里来相会,我要你的心肝肺!" <<endl;
 66                 break;
 67             default:
 68                 goto start;
 69         }
 70         rjtili=rjshangxian;
 71         Sleep(1500);
 72         system("cls");
 73         goto rjhuihe;
 74     }
 75 a1:
 76     cout<<"皮糙肉厚,却略微笨拙的怪物"<<endl;
 77     cout<<"防御:"<<rjfangyu<<endl;
 78     cout<<"生命:"<<rjshengmin<<endl;
 79     cout<<"攻击:"<<rjgongji<<endl;
 80     cout<<"体力:"<<rjtili<<endl;
 81     cout<<"速度:"<<rjsudu<<endl;
 82     user_input=getchar();
 83     Sleep(2000);
 84     system("cls");
 85     goto start;
 86 
 87 a2:
 88     cout<<"防御:"<<fangyu<<endl;
 89     cout<<"生命:"<<shengmin<<endl;
 90     cout<<"攻击:"<<gongji<<endl;
 91     cout<<"体力:"<<tili<<endl;
 92     cout<<"速度:"<<sudu<<endl;
 93     user_input=getchar();
 94     Sleep(2000);
 95     system("cls");
 96     goto start;
 97 
 98 a3:
 99     cout<<"你强化了防御"<<endl;
100     tili=tili-3;
101     fangyu++;
102     user_input=getchar();
103     Sleep(1500);
104     system("cls");
105     goto start;
106 
107 a4:
108     qiangzhigongji=rand()%(2-1+1)+1;
109     if(gongji-rjfangyu>0) {
110         cout<<"你打出一击"<<endl;
111         cout<<"造成了"<<gongji-rjfangyu<<"点伤害"<<endl;
112         rjshengmin=rjshengmin+rjfangyu-gongji;
113     } else {
114         cout<<"你打出一击,却连怪物的鳞片都打不烂,只能踹出一脚,造成" <<qiangzhigongji<<"点伤害" <<endl;
115         rjshengmin=rjshengmin-qiangzhigongji;
116     }
117     tili--;
118     user_input=getchar();
119     Sleep(1500);
120     system("cls");
121     if(rjshengmin>0) {
122         goto start;
123     } else goto rjdie;
124 a5:
125     cout<<"技能列表" <<endl;
126     cout<<"1.诅咒之术"<<endl;
127     cout<<"2.祝福之术"<<endl;
128     cout<<"3.返回"<<endl;
129     cin>>choose;
130     switch(choose) {
131         case 1:
132             goto jineng1;
133             break;
134         case 2:
135             goto jineng2;
136             break;
137         case 3:
138             system("cls");
139             goto start;
140             break;
141         default:
142             goto a5;
143     }
144 
145 a6:
146     if(sudu<=rjsudu) {
147         cout<<"无法逃跑"<<endl;
148     }
149     user_input=getchar();
150     Sleep(1500);
151     system("cls");
152     goto start;
153 
154 rjhuihe:
155     choose=rand()%(2-1+1)+1;
156     if(rjtili>0) {
157         switch(choose) {
158             case 1:
159                 goto rj1;
160                 break;
161             case 2:
162                 goto rj2;
163                 break;
164             default:
165                 goto rjhuihe;
166         }
167     } else
168         cout<<"怪物的体力已耗尽,轮到你了"<<endl;
169     tili=15;
170     Sleep(1500);
171     system("cls");
172     goto start;
173 
174 rj1:
175     if(rjtili>=3) {
176         cout<<"怪物的鳞片更坚硬了"<<endl;
177         rjfangyu++;
178         rjtili=rjtili-3;
179         Sleep(1500);
180         system("cls");
181         goto rjhuihe;
182     } else goto rjhuihe;
183 
184 rj2:
185     qiangzhigongji=rand()%(2-1+1)+1;
186     if(rjgongji-fangyu>0) {
187         cout<<"怪物朝你扑来,造成了" <<rjgongji-fangyu<<"点伤害" <<endl;
188         shengmin=shengmin+fangyu-rjgongji;
189     } else {
190         cout<<"怪物朝你扑来,却连你的盔甲都抓不烂,只能一巴掌拍飞你,造成" <<rand()%(2-1+1)+1<<"点伤害" <<endl;
191         shengmin=shengmin-qiangzhigongji;
192     }
193     rjtili--;
194     Sleep(1500);
195     system("cls");
196     if(shengmin>0) {
197         goto rjhuihe;
198     } else goto die;
199 rjdie:
200     cout<<"怪物倒飞了出去,再也没有站起来......"<<endl;
201     Sleep(1500);
202     cout<<"你,赢了";
203     user_input=getchar();
204     return 0;
205 
206 die:
207     cout<<"怪物的爪子扎进了你的心脏,你缓缓倒在了血泊中......"<<endl;
208     Sleep(1500);
209     cout<<"你,输了";
210     user_input=getchar();
211     return 0;
212 
213 jineng1:
214     if(rjshangxian>2) {
215         cout<<"怪物变得虚弱"<<endl;
216         rjshangxian--;
217         tili=tili-4;
218         Sleep(1500);
219         system("cls");
220         goto start;
221     } else {
222         cout<<"怪物已经虚弱得不能再虚弱了"<<endl;
223         Sleep(1500);
224         system("cls");
225         goto start;
226     }
227 
228 jineng2:
229     cout<<"你感觉一道圣光照在你身上,你的伤口有所愈合,肌肉也更坚韧了"<<endl;
230     shengmin=shengmin+3;
231     gongji=gongji+2;
232     fangyu++;
233     tili=tili-5;
234     Sleep(1500);
235     system("cls");
236     goto start;
237     return 0;
238 }
战斗系统代码

 

战斗系统改进

标签:inpu   click   mic   show   shang   getch   default   bsp   title   

原文地址:https://www.cnblogs.com/Tianyu1105/p/12910010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!