跳到正文

个人记录

小游戏 · 5 蒟蒻的双人游戏

xutongwei约 20 分钟
原文
文章信息与版本

文章信息

发布
2019年9月7日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 20 分钟

版本

  1. v1当前

其实就是僵尸游戏的改版啦~

C++
#include <iostream>
#include <string>
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
int ren[2];
int xue[2];
int go[2]; 
string ming[5] = {"0", "小明", "小红", "小刚", "菜鸡"};

void shu1(int i){
	if(i == 1){
		for(int i = 0; i < 26; i++){
			cout << " ";
		}
	}
	return;
}

void renwu(int x, int y) {
	if(y == 1){
		xue[x] = 5000;
		go[x] = 70;
	}else if(y == 2){
		xue[x] = 8000;
		go[x] = 40;
	}else if(y == 3){
		xue[x] = 3000;
		go[x] = 100;
	}else{
		xue[x] = 1000;
		go[x] = 30;
	}
	return;
}

void ce(){
	cout << "开始战斗!" << endl;
	Sleep(1000);
	system("pause");
	int x1[2] = {xue[0], xue[1]};
	int m2[2] = {1, 1};
	int m3[2] = {2, 2};
	int m4[2] = {2, 2};
	int m9 = 0;
	int ma[2] = {2, 2};
	int mc[2] = {0, 0};
	int mf[2] = {1, 1};
	int mg[2] = {0, 0};
	int ml[2] = {0, 0};
	int mm[2] = {0, 0};
	int mn[2] = {0, 0};
	int mp[2] = {0, 0};
	int mq[2] = {0, 0};
	int mr[2] = {0, 0}; 
	int ms[2] = {1, 1};
	int mt[2] = {0, 0};
	int mu[2] = {-1, -1};
	while(x1[0] > 0 && x1[1] > 0){
		m9++;
		for(int i = 0; i < 2; i++){
			Sleep(1500);
			system("cls");
			printf("第%d回合\n", m9);
			if(mc[1]){
				cout << "(火)";
			}
			if(mg[1]){
				cout << "(油)";
			}
			if(mt[0]) {
				cout << "(毒)";
			}
			cout << "选手1" << ming[ren[0]];
			printf("血量:%d/%d  ", x1[0], xue[0]);
			if(mc[0]){
				cout << "(火)";
			}
			if(mg[0]){
				cout << "(油)";
			}
			if(mt[1]) {
				cout << "(毒)";
			}
			cout << "选手2" << ming[ren[1]];
			printf("血量:%d/%d\n", x1[1], xue[1]);
			shu1(i);
			printf("轮到选手%d", i + 1);
			cout << ming[ren[i]] << endl;
			shu1(i);
			cout << "您的武器:" << endl;
			shu1(i);
			printf("1.普通攻击 100 攻速1 冷却无\n"); 
			shu1(i);
			printf("2.木板 120 攻速1 冷却%d\n", m4[i]);
			shu1(i);
			printf("3.铁棍 140 攻速1 冷却%d\n", m2[i]);
			shu1(i);
			printf("4.药瓶 80 攻速1/2 冷却%d\n", m3[i]);
			shu1(i);
			printf("5.急救包 随机回血 随机冷却\n");
			shu1(i);
			printf("6.燃烧瓶 40 攻速1/3 冷却%d\n", ma[i]);
			shu1(i);
			printf("7.油 0 攻速1 冷却%d\n", mf[i]);
			shu1(i);
			printf("8.TNT 500 攻速1 冷却%d\n", ml[i]);
			shu1(i);
			printf("9.药水 随机回血 防毒 冷却%d\n", mp[i]);
			shu1(i);
			string s1;
			cin >> s1;
			int m1;
			if(s1.size() == 1 && ((s1[0] - '0') >= 1 && (s1[0] - '0') <= 9)){
				m1 = s1[0] - '0';
				if(m1 == 1){
					Sleep(300);
					shu1(i);
					cout << "您对对方造成了80点攻击" << endl;
					x1[(int)!i] -= 80;
				}else if(m1 == 3){
					if(m2[i] >= 1){
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了130点攻击" << endl;
						x1[(int)!i] -= 130;
						m2[i]--;
					}else{
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						m2[i] = 1;
					}
				}else if(m1 == 2){
					if(m4[i] == 0){
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						m4[i] = 3;
					}else{
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了100点攻击" << endl;
						x1[(int)!i] -= 100; 
						m4[i]--;
					}
				}else if(m1 == 4){
					if(m3[i] == 0){
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						m3[i] = 2;
					}else{
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了57.5点伤害" << endl;
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了57.5点伤害" << endl;
						m3[i]--;
						x1[(int)!i] -= 115;
					}
				}else if(m1 == 5){
					srand(time(NULL));
					int m5 = rand() % 13;
					if(m5 == 2 || m5 == 3 || m5 == 7 || m5 == 11){
						Sleep(300);
						shu1(i);
						cout << "回血冷却中" << endl;
					}else{
						Sleep(300);
						srand(time(NULL));
						int m6 = (rand() % 51) + 50;
						x1[i] += m6;
						if(x1[i] < xue[i]){
							shu1(i);
							printf("回血成功,加血%d\n", m6);
						}else{
							shu1(i);
							printf("回血成功,加血%d\n", xue[i] + m6 - x1[i]);
							x1[i] = xue[i];
						}
					}
				}else if(m1 == 6){
					if(ma[i] == 0){
						ma[i] = 2;
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
					}else{
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了20点伤害" << endl;
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了20点伤害" << endl;
						Sleep(300);
						shu1(i);
						cout << "您对对方造成了20点伤害" << endl;
						x1[(int)!i] -= 60;
						ma[i]--;
						srand(time(NULL));
						int mb = rand() % 3;
						if(mb == 1){
							Sleep(300);
							shu1(i);
							cout << "对方身上着火了" << endl;
							mc[i] += 5;
						}
					}
				}else if(m1 == 7){
					if(mf[i] == 0){
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						mf[i] = 1; 
					}else{
						mf[i]--;
						mg[i] += 3;
						Sleep(300);
						shu1(i);
						cout << "很多油的样子" << endl;
						if(mc[i]) {
							Sleep(300);
							shu1(i);
							cout << "火上加油!" << endl;
						}
					}
				}else if(m1 == 8){
					if(ml[i]){
						Sleep(300);
						shu1(i);
						cout << "咝咝咝咝咝……" << endl;
						Sleep(600);
						shu1(i);
						cout << "  轰隆 !" << endl;
						Sleep(300);
						shu1(i);
						cout << "对方被炸飞了" << endl;
						x1[(int)!i] -= 500;
						if(x1[(int)!i] > 0){
							Sleep(300);
							shu1(i);
							cout << "对方生气的赶了过来……" << endl; 
						}
						ml[i]--;
						mn[i]++; 
					}else{
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						mm[i] += 1;
					}
				}else if(m1 == 9){
					if(mp[i]){
						Sleep(300);
						shu1(i);
						cout << "(⊙o⊙)…好难喝啊……" << endl;
						Sleep(300);
						shu1(i);
						cout << "防毒成功!" << endl; 
						m3[i]++; 
						mt[i] = 0;
						mp[i]--;
						Sleep(300);
						srand(time(NULL));
						int m6 = (rand() % 20) + 80;
						x1[i] += m6;
						if(x1[i] < xue[i]){
							shu1(i);
							printf("回血成功,加血%d\n", m6);
						}else{
							shu1(i);
							printf("回血成功,加血%d\n", xue[i] + m6 - x1[i]);
							x1[i] = 220;
						}
					}else{
						Sleep(300);
						shu1(i);
						cout << "攻击冷却中" << endl;
						mq[i]++;
					}
				}
			}else{
				Sleep(300);
				shu1(i);
				cout << "输入无效" << endl;
			}
			if(x1[(int)!i] > 0) {
				if(mt[i]){
					Sleep(300);
					shu1(i);
					cout << "你中毒了!" << endl;
					x1[i] -= 50;
					xue[i] -= 50;
					mt[i]--;
				}	
				srand(time(NULL));
				int m7 = rand() % 100;
				if(m7 % 5 == 0){
					srand(time(NULL));
					int m8 = (rand() % 51) + 50;
					if(mg[i]){
						int mh = rand() % 50;
						if(mh % 5 == 0){
							x1[(int)!i] += m8;
							if(x1[(int)!i] > xue[(int)!i]){
								Sleep(300);
								shu1(i);
								printf("对方回血%d\n", xue[(int)!i] + m8 - x1[(int)!i]);
								x1[(int)!i] = xue[(int)!i];
							}else{
								Sleep(300);
								shu1(i);
								printf("对方回血%d\n", m8);
							}
						}else{
							Sleep(300);
							shu1(i);
							printf("对方滑倒了\n");
						}
						mg[i]--;
					}else{
						x1[(int)!i] += m8;
							if(x1[(int)!i] > xue[(int)!i]){
							Sleep(300);
							shu1(i);
							printf("对方回血%d\n", xue[(int)!i] + m8 - x1[(int)!i]);
							x1[(int)!i] = xue[(int)!i];
						}else{
							Sleep(300);
							shu1(i);
							printf("对方回血%d\n", m8);
						}
					}
					if(mc[i]){
						int me = (rand() % 31) + 30;
						if(mg[i]){
							me += 30;
						}
						Sleep(300);
						shu1(i);
						printf("对方烧伤了,受到了%d点伤害\n", me);
						x1[(int)!i] -= me;
						mc[i]--;
					}
				}else{
					if(mc[i]){
						srand(time(NULL));
						int md = (rand() % 21) + go[(int)!i] - 30;
						int me = (rand() % 31) + 20;
						if(mn[i]){
							md += 10;
						}
						if(mg[i]){
							int mh = rand() % 50;
							if(mh % 5 == 0){
								Sleep(300);
								shu1(i);
								printf("对方对您造成了%d点攻击\n", md);
								x1[i] -= md;
							}else{
								Sleep(300);
								shu1(i);
								printf("对方滑倒了\n");
							}
							mg[i]--;
							me += 30;
						}else{
							Sleep(300);
							shu1(i);
							printf("对方对您造成了%d点攻击\n", md);
							x1[i] -= md;
						}
						Sleep(300);
						shu1(i);
						printf("对方烧伤了,受到了%d点伤害\n", me);
						x1[(int)!i] -= me;
						mc[i]--;
					}else{
						if(mg[i]){
							int mh = rand() % 50;
							if(mh % 5 == 0){
								if(mn[i]){
									Sleep(300);
									shu1(i);
									printf("对方对您造成了%d点攻击\n", go[(int)!i] + 20);
									x1[i] -= go[(int)!i] + 20;
								}else{
									Sleep(300);
									shu1(i);
									printf("对方对您造成了%d点攻击\n", go[(int)!i]);
									x1[i] -= go[(int)!i];
								}
							}else{
								Sleep(300);
								shu1(i);
								printf("对方滑倒了\n");
							}
							mg[i]--;
						}else{
							if(mn[i]){
								Sleep(300);
								shu1(i);
								printf("对方对您造成了%d点攻击\n", go[(int)!i] + 20);
								x1[i] -= go[(int)!i];
							}else{
								Sleep(300);
								shu1(i);
								printf("对方对您造成了%d点攻击\n", go[(int)!i]);
								x1[i] -= go[(int)!i];
							}
						}
					}
				}
				if(m9 % 6 == 0){
					if(m2[i] >= 3){
						m2[i] = 3;
					}else{
						m2[i]++;
					}
				}
				if(m9 % 8 == 0){
					ma[i]++;
				}
				if(m9 % 14 == 0){
					mf[i]++;
				}
				if(m9 % 5 == 0){
					mm[i]++;
				}
				if(mn[i]){
					mn[i] = 0;
				}
				if(mm[i] == 10){
					ml[i]++;
					mm[i] = 0; 
				}
				if(xue[(int)!i] - x1[(int)!i] > ms[i] * 1000){
					mp[i]++;
					ms[i]++;
				}
				if(mq[i] == 3){
					mq[i] == 0; 
					mp[i]++;
				}
				if(mu[i] == -1){
					srand(time(NULL));
					mu[i] = (rand() % 11) + 20;
					mu[i]--;
				}else if(mu[i] == 0){
					mt[i] += 10;
					mu[i] = -1;
				}else{
					mu[i]--;
				}
			}
			if(x1[0] <= 0 || x1[1] <= 0){
				break;
			}
			cout << endl;
		}
	}
	if(x1[0] <= 0) {
		Sleep(1000);
		system("cls");
		shu1(1);
		cout << "恭喜选手2胜利!" << endl;
	}else{
		Sleep(1000);
		system("cls");
		shu1(0);
		cout << "恭喜选手1胜利!" << endl;
	}
	Sleep(10000);
	return;
}

int main( ){
	cout << "请选手1选择人物(1.小明  2.小红  3.小刚  4.菜鸡):" << endl;
	cin >> ren[0];
	renwu(0, ren[0]);
	cout << "请选手2选择人物(1.小明  2.小红  3.小刚  4.菜鸡):" << endl;
	cin >> ren[1];
	renwu(1, ren[1]);
	Sleep(1000);
	system("cls");
	ce();
	system("cls");
	Sleep(300);
	cout << "留言区:" << endl << endl; 
	Sleep(300);
	cout<< "     提示:僵尸没有燃烧的时候,也可以使用油哦~,效果也不错。--by wenny" <<endl;
	Sleep(300);
	cout<< "     提示:连招使用67833,最高打掉僵尸1130点血哦!(别忘记冷却就行)--by Gspxz" <<endl;
	Sleep(10000);
	return 0;
}
原文
存档评论1 条抓取于