标签:改进 class ++ 攻击 列表 out lap style open
增加了逃跑系统,至此,战斗系统已开发完成,今后战斗系统还会改进。
2020-05-19 12:57:36
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 srand(time(NULL)); 147 choose=rand()%(10-1+1)+1; 148 cout<<choose<<endl; 149 if(choose!=1) { 150 cout<<"逃跑失败,怪物乘机给了你一下,造成2点伤害,又浪费了2点体力"<<endl; 151 tili=tili-2; 152 shengmin=shengmin-2; 153 } else { 154 cout<<"你成功逃出了怪物的魔爪"<<endl; 155 Sleep(1500); 156 return 0; 157 } 158 159 user_input=getchar(); 160 Sleep(1500); 161 system("cls"); 162 goto start; 163 164 rjhuihe: 165 choose=rand()%(2-1+1)+1; 166 if(rjtili>0) { 167 switch(choose) { 168 case 1: 169 goto rj1; 170 break; 171 case 2: 172 goto rj2; 173 break; 174 default: 175 goto rjhuihe; 176 } 177 } else 178 cout<<"怪物的体力已耗尽,轮到你了"<<endl; 179 tili=15; 180 Sleep(1500); 181 system("cls"); 182 goto start; 183 184 rj1: 185 if(rjtili>=3) { 186 cout<<"怪物的鳞片更坚硬了"<<endl; 187 rjfangyu++; 188 rjtili=rjtili-3; 189 Sleep(1500); 190 system("cls"); 191 goto rjhuihe; 192 } else goto rjhuihe; 193 194 rj2: 195 qiangzhigongji=rand()%(2-1+1)+1; 196 if(rjgongji-fangyu>0) { 197 cout<<"怪物朝你扑来,造成了" <<rjgongji-fangyu<<"点伤害" <<endl; 198 shengmin=shengmin+fangyu-rjgongji; 199 } else { 200 cout<<"怪物朝你扑来,却连你的盔甲都抓不烂,只能一巴掌拍飞你,造成" <<rand()%(2-1+1)+1<<"点伤害" <<endl; 201 shengmin=shengmin-qiangzhigongji; 202 } 203 rjtili--; 204 Sleep(1500); 205 system("cls"); 206 if(shengmin>0) { 207 goto rjhuihe; 208 } else goto die; 209 rjdie: 210 cout<<"怪物倒飞了出去,再也没有站起来......"<<endl; 211 Sleep(1500); 212 cout<<"你,赢了"; 213 user_input=getchar(); 214 return 0; 215 216 die: 217 cout<<"怪物的爪子扎进了你的心脏,你缓缓倒在了血泊中......"<<endl; 218 Sleep(1500); 219 cout<<"你,输了"; 220 user_input=getchar(); 221 return 0; 222 223 jineng1: 224 if(rjshangxian>2) { 225 cout<<"怪物变得虚弱"<<endl; 226 rjshangxian--; 227 tili=tili-4; 228 Sleep(1500); 229 system("cls"); 230 goto start; 231 } else { 232 cout<<"怪物已经虚弱得不能再虚弱了"<<endl; 233 Sleep(1500); 234 system("cls"); 235 goto start; 236 } 237 238 jineng2: 239 cout<<"你感觉一道圣光照在你身上,你的伤口有所愈合,肌肉也更坚韧了"<<endl; 240 shengmin=shengmin+3; 241 gongji=gongji+2; 242 fangyu++; 243 tili=tili-5; 244 Sleep(1500); 245 system("cls"); 246 goto start; 247 return 0; 248 }
标签:改进 class ++ 攻击 列表 out lap style open
原文地址:https://www.cnblogs.com/Tianyu1105/p/12916329.html