C++ 打怪小游戏3.1
生活随笔
收集整理的這篇文章主要介紹了
C++ 打怪小游戏3.1
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
想要之前的版本可自行在我的博客中查看或去到我的個人博客:GARS 的個人博客
個人博客更新較快(因為不用審核)(其實也快不了多少)
更新內容:
首個治療技能上線
首個加強技能上線
上述技能可在村莊修煉概率獲得
BUG修復:
修復了技能名及效果與技能不匹配的情況
上代碼:
#include "heads.h" #include "io.h" typedef long long ll; string weapon[10] = {"木劍" , "石劍" , "鐵劍" , "鉆石劍" , "下界合金劍" , "寰宇支配之劍" , "亂碼劍" , "五彩斑斕劍" , "深淵劍" , "氪金蘿莉"}; string skillname[8] = {"無技能","狂暴旋風","雷霆萬鈞","冰封千里","陰晦之氣","金鋒之光","烈火涅槃","狂嘯之怒"}; string skilleffect[8] = {"無","無","無","無","陰晦","耀光","涅槃","怒吼"}; string skille[8] = {"無","無","無","無","攻擊減100000","攻擊減200000","加血30000","下一次砍擊加100000傷害"}; int s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0; int skillnum = 0; int skillenergy[8] = {0,5,15,10,7,8,6,6}; int skillatk[8] = {0,500,1500,1000,0,0,0,0}; int skilln = 0; void fightmainban () {puts ("-----------------------------------------------");puts (" 選擇行動 ");puts (" 1、砍擊 2、刺擊 3、回血 4、逃跑 5、技能");puts ("-----------------------------------------------"); } void skillmianban (int num){if (num = 0){puts ("-----------------------------------------------");puts (" 你沒有技能可選擇 ");puts ("-----------------------------------------------");}else{puts ("-----------------------------------------------------------");puts (" 選擇技能 ");puts ("1、狂暴旋風 2、雷霆萬鈞 3、冰封千里 4、陰晦之氣 5、金鋒之光");puts ("6、烈火涅槃 7、狂嘯之怒");puts ("-----------------------------------------------------------");}} void mianban (int page){if (page==1){print("<TCF >",0xF8,0,0,1);print("<TCF > <TCF >",0xF8,0,1,0);print("<TCF ><TF8 選擇行動 ><TCF >",0xF8,0,2,0);print("<TCF ><TF8 1、戰斗:NPC 2、末日機械商店 3、財富積蓄 4、最終目標:末日新生 5、更多 ><TCF >",0xF8,0,3,1);print("<TCF > ",0xF8,0,4,1);print("<TCF ><TF8 選擇: ><TCF >",0xF8,0,4,0);print("<TCF > <TCF >",0xF8,0,5,0);print("<TCF >",0xF8,0,6,1);print("",0xF8,28,4,0);}else{puts("6、抽獎 7、指令 8、進入村莊");}} COORD gets_font_size() {COORD font_size;HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);/* 字體信息 */struct CONSOLE_FONT{DWORD index;COORD dim;} cfi;typedef COORD (WINAPI *PROCGETCONSOLEFONTSIZE)(HANDLE, DWORD);typedef BOOL (WINAPI *PROCGETCURRENTCONSOLEFONT)(HANDLE, BOOL, struct CONSOLE_FONT*);HMODULE hKernel32 = GetModuleHandle("kernel32");PROCGETCONSOLEFONTSIZE GetConsoleFontSize = (PROCGETCONSOLEFONTSIZE)GetProcAddress(hKernel32,"GetConsoleFontSize");PROCGETCURRENTCONSOLEFONT GetCurrentConsoleFont = (PROCGETCURRENTCONSOLEFONT)GetProcAddress(hKernel32,"GetCurrentConsoleFont");GetCurrentConsoleFont(handle, FALSE, &cfi); /* 獲取當前字體索引信息 */font_size = GetConsoleFontSize(handle, cfi.index); /* 獲取當前字體寬高信息[字符寬度及高度所占像素數] */return font_size; }/******************************************************************************** 最大化展示控制臺窗口******************************************************************************/ void full_screen() {HWND hwnd = GetForegroundWindow();HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); /* 標準輸出緩沖區句柄 */int cx = GetSystemMetrics(SM_CXSCREEN); /* 屏幕寬度 */int cy = GetSystemMetrics(SM_CYSCREEN); /* 屏幕高度 */COORD size = gets_font_size();char cmd[32] = { 0 };sprintf(cmd, "MODE CON: COLS=%d LINES=%d", cx / size.X, cy / size.Y);system(cmd);SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0); } int main () {system("color f0");full_screen();SetConsoleTitle("GAR 3:末日新生");srand ((unsigned)time (NULL));int chance = 2 , bloodchance = 2 , pricechange = 2 , hotal = 500 , tmpblood;string s;ll blood1 = 300000 , atk1 = 300000 , wep = 0;ll atk , blood , equipment , money = 0 , experience = 0;print("<TFC----------GAR 3:末日新生 <TF5末日機械工作室:GARS> 出品------------------>",0xF8,0,0,10);print("<TFC請輸入您的名字:>",0xF8,0,1,10);print("<TFC--------------------------------------------------------------------->",0xF8,0,2,10);print("",0xF8,15,1,0);HANDLE handle = ::GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_SCREEN_BUFFER_INFO csbi;GetConsoleScreenBufferInfo(handle, &csbi);SetConsoleTextAttribute(handle, 0xF9);WORD colorOld = csbi.wAttributes;s=getstr(16);SetConsoleTextAttribute(handle, colorOld);if (s == "GARS" || s == "機械賈瑞斯"|| s == "xxz") {atk = 99999999;blood = 99999999;equipment = 99999999;money = 99999999999;experience = 999999999;}else if (s == "GARK" || s == "機械賈卡斯"||s=="zxy") {atk = 9999999;blood = 99999999;equipment = 99999999;money = 999999999;experience = 999999999;}else {atk = rand () % 10 + 99900;blood = rand () % 9 + 50000;equipment = rand (); tmpblood = blood;}int bl = 2;bool killed = false;blood += equipment;char buff[150];sprintf(buff,"<TF9%s> <TFCatk:>%lld <TFCblood:>%lld <TFCequipment:>%d \n",s.c_str(),atk,blood,equipment,experience);print(buff,0xF8,0,3,10);char opt;while (1) { i: Sleep(2000);system("cls");if (killed) blood = tmpblood;int i = 1,page = 1;mianban (page);HANDLE handle = ::GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_SCREEN_BUFFER_INFO csbi;GetConsoleScreenBufferInfo(handle, &csbi);SetConsoleTextAttribute(handle, 0xF9);WORD colorOld = csbi.wAttributes;opt=getch();putch(opt);SetConsoleTextAttribute(handle, colorOld);print("",0xF8,0,7,0);if (opt == '1') {int energy=0;while (1) {int blood1 = rand () % 10 + 50000;int atk1 = rand () % 9 + 2000;int jiacheng = 0; cout << "NPC血量=" << blood1 << ". 攻擊力=" << atk1 << endl;cout << "第" << i << "回合" << endl;cout << "請問" << s << "要干什么?" << endl;fightmainban ();int k;cin >> k;if (k == 1) {int tmp = rand () % 10;if(jiacheng = 0){if (tmp < 4) {blood1 -= (atk * 2);cout << s << "使用附魔鉆石劍砍擊" << endl;cout << "NPC" << "還剩" << blood1 << "血" << endl;energy+=4;}else {blood1 -= atk;cout << s << "使用" << weapon[wep] << "砍擊" << "NPC" << endl;cout << "NPC" << "還剩" << blood1 << "血" << endl;energy+=2;}}else{skillnum = 7;blood1 -= atk+100000;cout << s <<"使用" << weapon[wep] << "砍擊" << "NPC" << endl;cout << s <<"因" << skilleffect[skillnum] << "效果加成,攻擊+100000" <<endl;cout << "NPC" << "還剩" << blood1 << "血" << endl;jiacheng = 0;}}if (k == 2) {if (energy<=5){cout << "能量不足!"<<endl;}else{blood-=atk*3;cout<<s<<"使用"<<weapon[wep]<<"刺擊"<<"NPC"<<endl;cout<<"NPC還剩"<<blood1<<"血"<<endl; }}if (k == 3 && bl <= 0) puts ("你沒吃的了......");if (k == 3 && bl > 0) {blood += 10;bl -- ;cout << s << "加10滴血" << endl;}if (k == 4) {int tmp = rand () % 10;if (tmp <= 4) {cout << s << "逃跑了" << endl;cout << "NPC" << "勝利" << endl;money -= 10;break;}else{cout<<s<<"沒能跑掉......"<<endl;}}if (k == 5){int miss = rand()%10;int ex = rand()%10;skillmianban(skilln);if(skillnum==0){puts(" ");}else{int sf;cin>>sf;if(sf = 1){if (s1=1){skillnum = 1;if(energy<5){cout<<"能量不足!"<<endl; }else{if(miss<=3){cout<<"NPC閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;} else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf=2){if(s2=1){skillnum = 2;if(energy<15){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<"NPC閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf = 3){if(s3=1){skillnum = 3;if(energy<10){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<"NPC閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf = 4){if(s4=1){skillnum = 4;if(energy<7){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<"NPC閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){ blood1-=skillatk[skillnum]*2;cout<<"NPC"<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<"NPC"<<skille[skillnum]<<endl;cout<<"因暴擊增益,多減10000"<<endl;atk-=110000; ex=rand()%10; }else{cout<<"NPC"<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<"NPC"<<skille[skillnum]<<endl;atk1-=100000;ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf = 5){if(s5=1){skillnum = 5;if(energy<10){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<"NPC閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){cout<<"NPC"<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<"NPC"<<skille[skillnum]<<endl;cout<<"因暴擊增益,多減20000"; atk1-=220000;ex=rand()%10; }else{cout<<"NPC"<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<"NPC"<<skille[skillnum]<<endl;atk1-=200000;ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if (sf = 6){if (s6 = 1){skillnum = 6;if(energy<6){cout << "能量不足!" << endl; }else{blood += 30000;energy -= skillenergy[skillnum];cout << s << "使用了" << skillname[skillnum] <<endl;cout << s << "獲得了" << skilleffect[skillnum] << endl;cout << s << skille[skillnum] <<endl;}}else{cout<<"你沒有這個技能!" << endl;}}if (sf = 7){if (s7 = 1){skillnum = 7;if (energy < 6){cout << "能量不足!" << endl;}else{energy-=skillenergy[skillnum];cout << s <<"獲得" << skillname[skillnum] << "效果" <<endl;jiacheng = 1;}}else{cout << "你沒有這個技能!" <<endl;}}}}if (blood1 <= 0) {cout << s << "干掉了" << "NPC" << endl;cout << s << "勝利" << endl;money += rand () % 10;experience +=rand()%10;break;}int tmp2 = rand () % 10;if (tmp2 <= 4) {blood -= (atk1 * 4);cout << "NPC" << "使用攻擊" << s << endl;cout << s << "還剩" << blood << "血" << endl;}else {blood -= atk1*2;cout << "NPC使用破土攻擊" << s << endl;cout << s << "還剩" << blood << "血" << endl;}if (blood <= 0) {cout << "NPC" << "干掉了" << s << endl;cout << "NPC" << "勝利" << endl;money -= 10;killed = true;break;}i ++ ;}}if (opt == '2') {puts ("歡迎來到末日機械商店!");puts ("攻擊武器 : 1、石劍:100鉆石 2、鐵劍:500鉆石 3、鉆石劍:2000鉆石 4、下界合金劍:5000鉆石");puts ("防御裝備 : 5、皮革套:300鉆石 6、鎖鏈套:5500鉆石 7、鐵套:8000鉆石 8、鉆石套:50000鉆石 9、下界合金套:100000鉆石"); puts ("究極裝備 : 9、無盡套 2000000 10、亂碼套 3000000 11、五彩斑斕套 4000000 12、深淵套 5000000 13、氪金蘿莉 50000000000000000歐元"); puts ("技能 : 14、陰晦之氣 500000 15、金鋒之光 600000");puts ("輸入0,離開商店");int op;cin >> op;if (op == 0) goto i;if (op == 1 && money >= 10) atk += 30 , money -= 10 , wep = 1;else if (money < 10) {puts ("沒錢!!!");goto i;}if (op == 2 && money >= 50) atk += 500 , money -= 50 , wep = 2;else if (money < 50) {puts ("沒錢!!!");goto i;}if (op == 3 && money >= 200) atk += 1000 , money -= 200 , wep = 3;else if (money < 200) {puts ("沒錢!!!");goto i;}if (op == 4 && money >= 500) atk += 2000 , money -= 500 , wep = 4;else if (money < 500) {puts ("沒錢!!!");goto i;}if (op == 5 && money >= 30) blood += 200 , money -= 30;else if (money < 30) {puts ("沒錢!!!");goto i;}if (op == 6 && money >= 100) blood += 7000 , money -= 100;else if (money < 100) {puts ("沒錢!!!");goto i;}if (op == 7 && money >= 500) blood += 10000 , money -= 500;else if (money < 500) {puts ("沒錢!!!");goto i;}if (op == 8 && money >= 1000) blood += 30000 , money -= 1000;else if (money < 1000) {puts ("沒錢!!!");goto i;}if (op == 9 && money >= 200000) atk += 20000 , money -= 200000 , wep = 6;else if (money < 200000) {puts ("沒錢!!!");goto i;}if (op == 10 && money >= 300000) atk += 30000 , money -= 300000 , wep = 7;else if (money < 300000) {puts ("沒錢!!!");goto i;}if (op == 11 && money >= 400000) atk += 40000 , money -= 400000 , wep = 8;else if (money < 400000) {puts ("沒錢!!!");goto i;}if (op == 12 && money >= 500000) atk += 50000 , money -= 500000 , wep = 9;else if (money < 500000) {puts ("沒錢!!!");goto i;}if (op == 13){puts("你氪不起......");}if (op == 14 && money >=50000) s4 = 1 , money -= 50000;else if (money < 50000){puts ("沒錢!!!");goto i;}if (op == 15 && money >= 60000) s5 = 1 , money -= 60000;else if (money < 60000){puts ("沒錢!!!");goto i;}puts ("已穿上裝備");}if (opt == '3') {puts ("選擇工作");puts ("1、清理 2分鐘5鉆石");puts ("2、擼樹 2分鐘20鉆石");puts ("3、挖礦 2分鐘50鉆石");puts ("4、保衛村莊 2分鐘70鉆石");int y;cin >> y;if (y == 1 && experience >= 10) {puts ("輸入工作時間");int times;cin >> times;cout << "工作中......" << endl;Sleep (times * 60000);money += (times / 2) * 20;experience+=(times/2)*2;cout << "你現在有:" << money << "鉆石" << endl;cout<<"你的經驗為:"<<experience<<endl;goto i;}else if (y == 1 && experience < 10) {puts ("資格不足");goto i;}if (y == 2 && money >= 20) {puts ("輸入工作時間");int times;cin >> times;cout << "工作中......" << endl;Sleep (times * 60000);money += (times / 2) * 50;experience+=(times/2)*4;cout << "你現在有:" << money << "鉆石" << endl;cout<<"你的經驗為:"<<experience<<endl;goto i;}else if (y == 2 && experience < 20) {puts ("資格不足");goto i;}if (y == 3 && experience>= 50) {puts ("輸入工作時間");int times;cin >> times;cout << "工作中......" << endl;Sleep (times * 60000);experience+=(times / 2)*6;money += (times / 2) * 5;cout << "你現在有:" << money << "鉆石" << endl;cout << "你的經驗為:"<<experience<<endl;goto i;}else if (y == 3 && experience < 50) {puts ("資格不足");goto i;}if (y == 4 && money >= 100) {puts ("輸入工作時間");int times;cin >> times;cout << "工作中......" << endl;Sleep (times * 60000);experience+=(times / 2) * 8;money += (times / 2) * 70;cout << "你現在有:" << money << "鉆石" << endl;cout << "你的經驗為:" << experience << endl;goto i;}else if (y == 4 && experience < 100) {puts ("資格不足");goto i;}}if (opt == '4') {blood1*=20;atk1*=20;int miss = rand()%10;int energy = 0; int jiacheng = 0;string boss = "凋零風暴"; while (1) {cout << boss << "血量=" << blood1 << ". 攻擊力=" << atk1 << endl;cout << "第" << i << "回合" << endl;cout<<"能量:"<<energy<<endl;cout << "請問" << s << "要干什么?" << endl;fightmainban ();int k;cin >> k;if (k == 1) {int tmp = rand () % 10;if(jiacheng = 0){if (tmp < 4) {blood1 -= (atk * 2);cout << s << "使用附魔鉆石劍砍擊" << endl;cout << boss << "還剩" << blood1 << "血" << endl;energy+=4;}else {blood1 -= atk;cout << s << "使用" << weapon[wep] << "砍擊" << "NPC" << endl;cout << boss << "還剩" << blood1 << "血" << endl;energy+=2;}}else{skillnum = 7;blood1 -= atk+100000;cout << s <<"使用" << weapon[wep] << "砍擊" << boss << endl;cout << s <<"因" << skilleffect[skillnum] << "效果加成,攻擊+100000" <<endl;cout << boss << "還剩" << blood1 << "血" << endl;jiacheng = 0;}}if(k == 2){if(energy>=5){if(miss>3){blood1-=atk*3;energy-=5;cout<<s<<"使用"<<weapon[wep]<<"劈擊"<<boss<<endl;cout<<boss<<"還剩"<<blood1<<"血"<<endl;cout<<s<<"的能量"<<"還剩"<<energy<<endl;miss=rand()%10;}else{energy-=5;cout<< boss << "閃避了"<<s<<"的攻擊!!!"<<endl; cout<<s<<"的能量"<<"還剩"<<energy<<endl;miss = rand()%10; }}else{cout<<"能量不足!"<<endl;}}if (k == 3 && bl <= 0) puts ("你沒吃的了......");if (k == 3 && bl > 0) {blood += 10;bl -- ;cout << s << "加10滴血" << endl;}if (k == 4) {int tmp = rand () % 10;if (tmp <= 4) {cout << s << "逃跑了" << endl;cout << boss << "勝利" << endl;money -= 10;energy = 0;break;}else{cout << s << "沒能逃掉"<<endl;}}if (k == 5){int ex = rand()%10;skillmianban(skilln);if(skillnum==0){puts(" ");}else{int sf;cin>>sf;if(sf == 1){if (s1==1){skillnum = 1;if(sf==1&&energy<5){cout<<"能量不足!"<<endl; }else{if(miss<=3){cout<<boss<<"閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;} else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf==2){if(s2==1){skillnum = 2;if(sf==2&&energy<15){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<boss<<"閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf == 3){if(s3==1){skillnum = 3;if(sf==3&&energy<10){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<boss<<"閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){ blood1-=skillatk[skillnum]*2;ex=rand()%10; }else{blood1-=skillatk[skillnum];ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf == 4){if(s4==1){skillnum = 4;if(sf==4&&energy<7){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<boss<<"閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){cout<<boss<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<boss<<skille[skillnum]<<endl; cout<<"因暴擊增益,多減10000"<<endl;atk1-=110000;ex=rand()%10; }else{cout<<boss<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<boss<<skille[skillnum]<<endl;atk1-=100000;ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if(sf == 5){if(s5==1){skillnum = 5;if(sf==5&&energy<8){cout<<"能量不足!"<<endl;}else{if(miss<=3){cout<<boss<<"閃避了"<<s<<"的"<<skillname[skillnum]<<"攻擊"<<endl; miss=rand()%10;}else{if(ex<=3){cout<<boss<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<boss<<skille[skillnum]<<endl;cout<<"因暴擊增益,多減20000"<<endl;atk1 -= 220000;ex=rand()%10; }else{cout<<boss<<"受到"<<s<<"的"<<skilleffect[skillnum]<<"效果"<<endl;cout<<boss<<skille[skillnum]<<endl; atk1-=200000;ex=rand()%10;}energy-=skillenergy[skillnum];} }}else{cout<<"你沒有這個技能!"<<endl;}}if (sf = 6){if (s6 = 1){skillnum = 6;if(energy<6){cout << "能量不足!" << endl; }else{blood += 30000;energy -= skillenergy[skillnum];cout << s << "使用了" << skillname[skillnum] <<endl;cout << s << "獲得了" << skilleffect[skillnum] << endl;cout << s << skille[skillnum] <<endl;}}else{cout<<"你沒有這個技能!" << endl;}}if (sf = 7){if (s7 = 1){skillnum = 7;if (energy < 6){cout << "能量不足!" << endl;}else{energy-=skillenergy[skillnum];cout << s <<"獲得" << skillname[skillnum] << "效果" <<endl;jiacheng = 1;}}else{cout << "你沒有這個技能!" <<endl;}}}}if (blood1 <= 0) {cout << s << "干掉了" << boss << endl;cout << s << "勝利" << endl;cout << "挑戰已達成!"<<endl;cout << "末日新生" <<endl;return 0;}int tmp2 = rand () % 10;if (tmp2 <= 4) {blood -= (atk1 * 12);cout << boss << "使用顯卡飄香攻擊" << s << endl;cout << s << "還剩" << blood << "血" << endl;}else if(tmp2 <= 6){blood -= (atk1 * 6);cout << boss << "使用卡死5分鐘攻擊" << s <<endl;cout << s << "還剩" << blood << "血" << endl; } else {blood -= atk1*3;cout << boss<<"使用延遲1000000ms攻擊" << s << endl;cout << s << "還剩" << blood << "血" << endl;}if (blood <= 0) {cout << boss << "干掉了" << s << endl;cout << boss << "勝利" << endl;money -= 100;experience+=rand()%5;killed = true;break;}i ++ ;}}if (opt == '5'){page+=1;mianban(page);}if(opt=='6'){int g = rand()%50;puts ("獎項:1、技能:狂暴旋風 2、電光一閃 3、冰封千里");puts (" 5、鉆石500 6、鉆石1000 7、氪金蘿莉 8、血量+10000 9、隱藏大獎");puts ("抽獎一次500鉆石 按1抽獎");string yn;cin>>yn;if(yn == "1"){if(money<50){cout<<"鉆石不足!";}else{money -= 50;if(g<=5){cout<<"獲得技能:狂暴旋風!"<<endl;s1 = 1;}if(g>5&&g<=7){cout<<"獲得:氪金蘿莉!運氣爆棚!"<<endl;wep = 10;atk+=10000000; }if(g>7&&g<=10){cout<<"獲得技能:雷霆萬鈞!運氣可以!"<<endl;s2 = 1;}if(g>10&&g<=20){cout<<"獲得500鉆石!"<<endl;money+=500; }if(g>20&&g<=24){cout<<"獲得技能:冰封千里!"<<endl;s3 = 1;}if(g>24&&g<=30){cout<<"獲得1000鉆石!"<<endl;money+=1000;}if(g>30&&g<=33){cout<<"血量+10000!運氣可以啊!"<<endl;blood += 100000;}if(g>33&&g<=40||g>45&&g<=50){cout<<"運氣不佳......什么也沒抽到......"<<endl;}if(g>40&&g<=45){cout<<"隱藏大獎!!!炸彈!!!血量-5000!!!"<<endl;blood-=5000;}goto i;}} }if (opt == '7') {puts ("指令:1、coi_money (看自己有多少錢)");puts ("1(1)、coi_atk_and_blood (看boss血量、攻擊力)");puts ("1(2)、coi_me (看自己目前攻擊力、血量)");puts ("2、cut_blood (削弱boss3%血量,有20%的幾率)");puts ("3、atk++ (加強攻擊力,作者專用)");puts ("4、blood++ (加強血量)");puts ("5、cut_price (降價旅館錢數,兩次機會,有20%幾率)");puts ("請輸入指令:");string zl;cin >> zl;if (zl == "GAR:末日機械萬歲!!!"){cout<<"指令輸入成功!已開啟內部指令模式!"<<endl;string GARzl,GARpassword;puts("1、money+++(自定義增加鉆石)");puts("2、atk+++(自定義增加攻擊力)");puts("3、blood+++(自定義增加血量)") ;puts("4、leave(離開游戲)");puts("5、top-ups(充值獲得氪金蘿莉(Tips:直接加攻擊不就好了......))");puts("請輸入內部指令:");cin>>GARzl;if(GARzl=="money+++"){cout << "輸入密碼:"<<endl;cin >> GARpassword;if(GARpassword == "xuxinzhe666"){cout<<"認證成功!!!"<<endl;cout << "輸入數目:"<<endl;int GARm;cin>>GARm;money+=GARm;puts("添加成功!!!");}else{puts("呵,不知道密碼還想用");}}if(GARzl=="leave"){return 0;}if(GARzl=="blood+++"){cout << "輸入密碼:"<<endl;cin >> GARpassword;if(GARpassword == "xuxinzhe666"){cout<<"認證成功!!!"<<endl;cout << "輸入數目:"<<endl;int GARm;cin>>GARm;blood+=GARm;puts("添加成功!!!");}else{puts("呵,不知道密碼還想用");}}if(GARzl=="atk+++"){cout << "輸入密碼:"<<endl;cin >> GARpassword;if(GARpassword == "xuxinzhe666"){cout<<"認證成功!!!"<<endl;cout << "輸入數目:"<<endl;int GARm;cin>>GARm;atk+=GARm;puts("添加成功!!!");}else{puts("呵,不知道密碼還想用");}}if(GARzl=="top-ups"){cout << "輸入密碼:"<<endl;cin >> GARpassword;if(GARpassword == "xuxinzhe666"){cout<<"認證成功!!!"<<endl;wep = 10;atk+=100000000;money = 0; cout<<"已獲得氪金蘿莉"<<endl; }else{puts("呵,不知道密碼還想用");}}}if (zl == "coi_money") {cout << "money:" << money << endl;goto i;}if (zl == "coi_atk_and_blood") {cout << "攻擊力:" << atk1 << " 防御力:" << blood1 << endl;goto i;}if (zl == "coi_me") {cout << "攻擊力:" << atk << " 防御力:" << blood << endl;goto i;}if (zl == "cut_blood" && chance <= 0) {puts ("你是不是以為這是無限次數的?");goto i;}if (zl == "cut_blood" && chance > 0) {int ran = rand ();if (ran % 5 == 0) {atk1 *= 0.97; blood1 *= 0.97;cout << "目前boss攻擊力:" << atk1 << "血量:" << blood1 << endl;chance -- ;goto i;}else {puts ("真不走運......");goto i;}}if (zl == "atk++" && s == "GARS" || zl == "atk++" && s == "xxz") {string password;puts("請輸入密碼:");cin>>password;if(password=="xuxinzhe666"){puts("認證成功!");atk += 1000;blood += 10000;}else{puts("你不是作者!!!!!!"); } cout << "現在血量:" << atk << " 防御力:" << blood << endl;goto i;}else if (zl == "atk++" && s != "GARS" || zl == "atk++" && s != "GARS") {puts ("你不是作者!!!!!!");goto i;}if (zl == "blood++" && bloodchance <= 0) {puts ("你是不是以為這是無限次數的?");goto i;}if (zl == "blood++" && bloodchance > 0) {blood += 900;cout << "現在血量:" << blood;bloodchance -- ;goto i;}if (zl == "cut_price" && pricechange <= 0) {puts ("你是不是以為這是無限次數的?");goto i;}if (zl == "cut_price" && pricechange > 0) {int price = rand () % 10;if (price <= 4) {hotal *= 0.8;cout << "現在錢數:" << hotal << endl;pricechange -- ;goto i;}else {puts ("真不走運......");goto i;}}}if (opt == '8') {puts ("歡迎來到村莊!");puts ("住宿一次500鉆石,血量+5000");puts ("修煉一次500鉆石,攻擊力+5000,可能獲得烈火涅槃和狂嘯之怒技能");puts ("住店輸入1,修煉輸入2");int o;cin >> o;if (o == 1 && money >= 500) {puts ("好好睡吧......");blood += 5000;money -= 500;Sleep (3000);puts ("第二天了");goto i;}else if (o == 1 && money < 500) {puts ("你似乎沒錢呢?");goto i;}else {puts ("下次再來!!!!");goto i;}if (o == 2 && money >= 500) {puts ("嘿!呼!呀!");atk += 5000;money -= 500;Sleep (3000);puts ("一天過去了......");int xiulian = rand()%30;if(xiulian<13&&xiulian>=10){puts ("你修得了烈火涅槃!");s6 = 1;}if(xiulian>25&&xiulian<=27){puts ("你修得了狂嘯之怒!");s7 = 1;} goto i;}else if (o == 2 && money < 500) {puts ("你似乎沒錢呢?");goto i;}else {puts ("下次再來!!!!");goto i;} }}return 0; }heads.h和io.h庫可在我的博客頁面搜索heads和io(兩個博客都行)
制作不易,喜歡請點個贊吧~
總結
以上是生活随笔為你收集整理的C++ 打怪小游戏3.1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QT小控件-仪表盘
- 下一篇: python做一个打怪升级的游戏