目录
第三弹来啦!由于文章长度原因,每个文章只能放4~5个游戏代码,不过都是精挑细选的,而且放到devc++上可以直接运行!如果嫌文章更得慢,可以去下载我的资源,是免费的呦~156个c++小游戏源代码免费亲测可运行。
创意类
9.狼人杀(2)推荐
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
struct IDname{
int geshu;
string NAME;
};
IDname jue_se[100];
struct ID{
int num;
bool life;
string name;
int know;
int how;
};
ID player[21];
int n, MY, kill1, kill2;
char a;
bool jieyao = 1, duyao = 1;
int lieren, shouwei = 0;
void init1(){
jue_se[1].NAME = "村民 ";
jue_se[2].NAME = "狼人 ";
jue_se[3].NAME = "女巫 ";
jue_se[4].NAME = "预言家 ";
jue_se[5].NAME = "猎人 ";
jue_se[6].NAME = "守卫 ";
}
void init2(int nn){
switch (nn){
case 6:
jue_se[1].geshu = 3;
jue_se[2].geshu = 2;
jue_se[3].geshu = 1;
jue_se[4].geshu = 0;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 7:
jue_se[1].geshu = 3;
jue_se[2].geshu = 2;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 8:
jue_se[1].geshu = 3;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 9:
jue_se[1].geshu = 3;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 10:
jue_se[1].geshu = 4;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 11:
jue_se[1].geshu = 4;
jue_se[2].geshu = 4;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 12:
jue_se[1].geshu = 4;
jue_se[2].geshu = 4;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 1;
break;
default:
cout << "输入错误,再见" << endl;
exit(0);
break;
}
}
int van[10] = { 7,4,6,43,35,1,2,8,20,19 };
void init3(int nn){
srand(time(0));
Sleep(rand() % 44);
int x = 10000;
int t = rand();
srand(time(NULL));
int y = van[(rand() % 100 * van[rand() % 10] + t) % 10];
if (nn <= 6)
x = abs(x * 6 / y) % 3 + 1;
else if (nn <= 8)
x = abs(x * 7 / y) % 4 + 1;
else if (nn <= 11)
x = abs(x * 8 / y) % 5 + 1;
else if (nn <= 14)
x = abs(x * 9 / y) % 6 + 1;
do{
if (nn <= 6)
x = x % 3 + 1;
else if (nn <= 8)
x = x % 4 + 1;
else if (nn <= 11)
x = x % 5 + 1;
else if (nn <= 14)
x = x % 6 + 1;
if (jue_se[x].geshu > 0){
player[nn].name = jue_se[x].NAME;
if (player[nn].name == "猎人 ")
lieren = nn;
if (player[nn].name == "守卫 ")
shouwei = nn;
player[nn].life = 1;
player[nn].num = nn;
player[nn].know = 0;
jue_se[x].geshu--;
player[nn].how = 0;
break;
}
} while (jue_se[x].geshu == 0);
}
void printhhh(){
int cm = 0;
int sz = 0;
for (int i = 1; i <= n; i++){
if (player[i].life == 0)
continue;
else if (player[i].name == "村民 ")
cm++;
else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 " || player[i].name == "守卫 ")
sz++;
}
if (sz == 0 || cm == 0)
cout << "狼人阵营胜利" << endl;
else
cout << "好人阵营胜利" << endl;
for (int i = 1; i <= n; i++){
cout << left << setw(3) << player[i].num << ": " << player[i].name << " ";
if (player[i].life == 0)
cout << "死亡" << "\t";
else
cout << "存活" << "\t";
if (player[i].how == 0)
cout << "最终存活 " << endl;
else if (player[i].how == 1)
cout << "最终被狼人杀死" << endl;
else if (player[i].how == 2)
cout << "最终被投票投死" << endl;
else if (player[i].how == 3)
cout << "最终被女巫毒死" << endl;
else if (player[i].how == 4)
cout << "最终被猎人射杀" << endl;
}
system("pause");
}
void print(int day, int ti){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << "\t\t\t\t第" << day << "天 ";
if (ti == 0)
cout << "白天" << endl;
else
cout << "夜晚" << endl;
cout << "我的位置:" << MY << "号" << endl;
for (int i = 1; i <= 6; i++){
cout << player[i].num << "号位 ";
}
cout << endl;
for (int i = 1; i <= 6; i++){
if (player[i].life == 1){
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
cout << "存活 ";
}
else{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "已死亡 ";
}
}
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << endl;
for (int i = 1; i <= 6; i++){
if (player[i].know == 0)
cout << "未知 ";
else if (player[i].know == 1){
if (player[i].name == "狼人 ")
cout << "狼人 ";
else
cout << "好人 ";
}
else if (player[i].know == 2)
cout << player[i].name << " ";
}
cout << endl << endl;
for (int i = 7; i <= n; i++){
if (i < 10)
cout << player[i].num << "号位 ";
else
cout << player[i].num << "号位 ";
}
cout << endl;
for (int i = 7; i <= n; i++){
if (player[i].life == 1){
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
cout << "存活 ";
}
else{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "已死亡 ";
}
}
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << endl;
for (int i = 7; i <= n; i++){
if (player[i].know == 0)
cout << "未知 ";
else if (player[i].know == 1){
if (player[i].name == "狼人 ")
cout << "狼人 ";
else
cout << "好人 ";
}
else if (player[i].know == 2)
cout << player[i].name << " ";
}
cout << endl << endl;
}
int shou = 0;
void shoushui(int hhh, int hhhh){
int x;
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "守~卫~请~睁~眼~~~" << endl;
Sleep(3000);
system("cls");
print(hhh, hhhh);
if (MY == shouwei && player[MY].life == 1){
cout << "请问你要守护谁?" << endl << "输入:";
cin >> x;
while (x == shou || x<1 || x>n || player[x].life == 0){
cout << "输入错误,请重新输入" << endl << "输入:";
cin >> x;
}
shou = x;
}
else if (player[shouwei].life == 1){
cout << "请问你要守护谁?" << endl;
Sleep(rand() % 98);
srand(time(0));
x = rand() % n + 1;
while (x == shou || player[x].life == 0){
Sleep(rand() % 98);
srand(time(0));
x = rand() % n + 1;
}
shou = x;
}
else{
cout << "请问你要守护谁?" << endl;
Sleep(3000);
shou = -1;
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "守~卫~请~闭~眼~~~" << endl;
}
struct tou{
int xxx;
int num;
int toupiaoquan;
};
tou TOU[13];
bool cmp(tou x, tou y){
if (x.xxx == y.xxx)
return x.num < y.num;
return x.xxx > y.xxx;
}
bool cmp1(tou x, tou y){
return x.num < y.num;
}
void toupiao(int ddd, int nnn){
int x;
Sleep(2000);
system("cls");
print(ddd, nnn);
cout << "现在大家请投票";
for (int i = 1; i <= 3; i++){
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++){
TOU[i].num = i;
TOU[i].toupiaoquan = 1;
TOU[i].xxx = 0;
}
for (int i = 1; i <= n; i++){
if (player[i].life == 1){
Sleep(3000);
if (i == MY){
cout << "请投票...(0弃权)" << endl;
cin >> x;
while (player[x].life == 0 && x != 0){
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else{
srand(time(0));
if (player[i].name == "狼人 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i)){
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i)){
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i)){
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx){
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
Sleep(3000);
return;
}
else{
TOU[1].toupiaoquan = 0;
TOU[2].toupiaoquan = 0;
system("cls");
print(ddd, nnn);
cout << TOU[1].num << "号," << TOU[2].num << "号";
int i;
for (i = 3; i <= n; i++){
if (TOU[i].xxx == TOU[1].xxx){
TOU[i].toupiaoquan = 0;
cout << "," << TOU[i].num << "号";
}
else
break;
}
if (i == n + 1){
for (int i = 1; i <= n; i++)
TOU[i].toupiaoquan = 1;
}
cout << "平票" << endl;
}
sort(TOU + 1, TOU + n + 1, cmp1);
cout << "请再次投票";
for (int i = 1; i <= 3; i++){
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++){
if (player[i].life == 1 && TOU[i].toupiaoquan == 1){
Sleep(3000);
if (i == MY){
cout << "请投票...(0弃权)" << endl;
cin >> x;
while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0){
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else{
srand(time(0));
if (player[i].name == "狼人 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0 && TOU[i].toupiaoquan == 1)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx){
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
Sleep(3000);
return;
}
else{
TOU[1].toupiaoquan = 0;
TOU[2].toupiaoquan = 0;
system("cls");
print(ddd, nnn);
cout << TOU[1].num << "号," << TOU[2].num << "号";
int i;
for (i = 3; i <= n; i++){
if (TOU[i].xxx == TOU[1].xxx){
TOU[i].toupiaoquan = 0;
cout << "," << TOU[i].num << "号";
}
else
break;
}
if (i == n + 1){
for (int i = 1; i <= n; i++)
TOU[i].toupiaoquan = 1;
}
cout << "平票" << endl;
}
sort(TOU + 1, TOU + n + 1, cmp1);
cout << "请再次投票";
for (int i = 1; i <= 3; i++){
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++){
if (player[i].life == 1 && TOU[i].toupiaoquan == 1){
Sleep(3000);
if (i == MY){
cout << "请投票...(0弃权)" << endl;
cin >> x;
while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0){
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else{
srand(time(0));
if (player[i].name == "狼人 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 " || player[i].name == "猎人 "){
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1)){
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0 && TOU[i].toupiaoquan == 1)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx){
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
}
else{
cout << "投票结束,无人出局" << endl;
}
Sleep(5000);
}
bool game_over(){
int pingmin = 0;
int langren = 0;
int shenzhi = 0;
for (int i = 1; i <= n; i++){
if (player[i].life == 0)
continue;
if (player[i].name == "狼人 ")
langren++;
else if (player[i].name == "村民 ")
pingmin++;
else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 ")
shenzhi++;
}
if (shenzhi == 0 || langren == 0 || pingmin == 0)
return 1;
return 0;
}
void night(){
system("cls");
system("color 0f");
print(1, 1);
cout << "天~黑~请~闭~眼~~~" << endl;
if (n >= 12)
shoushui(1, 1);
Sleep(3000);
system("cls");
print(1, 1);
cout << "狼~人~请~睁~眼~~~" << endl;
if (player[MY].name == "狼人 "){
Sleep(1000);
cout << "你的同伴有:";
for (int i = 1; i <= n; i++){
if (i == MY)
continue;
if (player[i].name == "狼人 "){
cout << player[i].num << "号 ";
player[i].know = 2;
}
}
Sleep(3000);
cout << endl << "请问你们要杀谁:" << endl << "输入:";
cin >> kill1;
Sleep(1500);
system("cls");
print(1, 1);
cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
}
else{
Sleep(4000);
system("cls");
print(1, 1);
cout << "请问你们要杀谁?" << endl;
do{
Sleep(rand() % 18);
srand(time(0));
int x = rand() % n + 1;
if (player[x].name != "狼人 " && player[x].life == 1){
kill1 = x;
break;
}
} while (1);
Sleep(5000);
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "狼~人~请~闭~眼~~~" << endl;
Sleep(2000);
system("cls");
print(1, 1);
cout << "女~巫~请~睁~眼~~~" << endl;
Sleep(2000);
system("cls");
print(1, 1);
if (player[MY].name == "女巫 " && player[MY].life == 1){
Sleep(1000);
if (jieyao == 1){
cout << "今晚" << kill1 << "号玩家被杀" << endl;
Sleep(500);
cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
cin >> a;
if (a == 'A'){
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl;
Sleep(2000);
system("cls");
print(1, 1);
cout << "今晚" << kill1 << "号玩家被你解救" << endl;
jieyao = 0;
if (shou != kill1)
kill1 = 0;
}
else{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A'){
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1){
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A'){
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1){
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else{
bool b = 0;
cout << "请问你是否要用解药???" << endl;
int FFF = 0, kkkk;
for (int i = 1; i <= n; i++){
if (player[i].life == 1 && player[i].name == "村民 ")
FFF++;
if (player[i].name == "女巫 ")
kkkk = i;
}
if (jieyao == 1 && player[kkkk].life == 1){
if (FFF == 1){
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
kill1 = 0;
b = 1;
}
else
for (int i = 1; i <= n; i++){
if (player[i].name == "女巫 " && kill1 == i){
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
else if (player[i].name == "预言家 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
}
}
Sleep(3000);
if (b == 0 && duyao == 1 && player[kkkk].life == 1){
system("cls");
print(1, 1);
cout << "请问你是否要用毒药???" << endl;
srand(time(0));
int x = rand() % 2;
Sleep(1500);
cout << "请问你要毒谁???" << endl;
if (x == 1)
{
duyao = 0;
int y = rand() % n + 1;
while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
y = rand() % n + 1;
kill2 = y;
}
}
else{
Sleep(3000);
system("cls");
print(1, 1);
cout << "请问你是否要用毒药???" << endl;
Sleep(3000);
cout << "请问你要毒谁???" << endl;
Sleep(3000);
}
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "女~巫~请~闭~眼~~~" << endl;
if (n > 6){
Sleep(3000);
system("cls");
print(1, 1);
cout << "预~言~家~请~睁~眼~~~" << endl;
if (player[MY].name == "预言家 "){
Sleep(3000);
cout << "请问你想查验谁???" << endl << "输入:";
int x;
cin >> x;
player[x].know = 1;
Sleep(2000);
system("cls");
print(1, 1);
cout << "他的身份是:";
if (player[x].name == "狼人 ")
cout << "狼人" << endl;
else
cout << "好人" << endl;
Sleep(3000);
}
else{
Sleep(3000);
cout << "请问你想查验谁???" << endl;
Sleep(3000);
system("cls");
print(1, 1);
cout << "他的身份是:......";
Sleep(3000);
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "预~言~家~请~闭~眼~~~" << endl;
}
Sleep(3000);
if (kill1 != 0)
player[kill1].life = 0;
if (kill2 != 0)
player[kill2].life = 0;
player[kill1].how = 1;
player[kill2].how = 3;
system("cls");
system("color F0");
print(2, 0);
}
void night2(int hhh, int hhhh)
{
system("cls");
system("color 0f");
print(hhh, hhhh);
cout << "天~黑~请~闭~眼~~~" << endl;
if (n >= 12)
shoushui(hhh, hhhh);
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "狼~人~请~睁~眼~~~" << endl;
if (player[MY].name == "狼人 " && player[MY].life == 1)
{
Sleep(3000);
cout << endl << "请问你们要杀谁:" << endl << "输入:";
cin >> kill1;
Sleep(1500);
system("cls");
print(hhh, hhhh);
cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
}
else
{
Sleep(4000);
system("cls");
print(hhh, hhhh);
cout << "请问你们要杀谁?" << endl;
do
{
srand(time(0));
int x = rand() % n + 1;
if (player[x].name != "狼人 " && player[x].life == 1)
{
kill1 = x;
break;
}
} while (1);
Sleep(5000);
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "狼~人~请~闭~眼~~~" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "女~巫~请~睁~眼~~~" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
if (player[MY].name == "女巫 " && player[MY].life == 1)
{
Sleep(1000);
if (jieyao == 1)
{
cout << "今晚" << kill1 << "号玩家被杀" << endl;
Sleep(500);
cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
cin >> a;
if (a == 'A')
{
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "今晚" << kill1 << "号玩家被你解救" << endl;
jieyao = 0;
if (shou != kill1)
kill1 = 0;
}
else
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else if (duyao == 1)
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
else
{
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl;
}
}
else
{
bool b = 0;
cout << "请问你是否要用解药???" << endl;
int FFF = 0, kkkk;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1 && player[i].name == "村民 ")
FFF++;
if (player[i].name == "女巫 ")
kkkk = i;
}
if (jieyao == 1 && player[kkkk].life == 1)
{
if (FFF == 1)
{
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
kill1 = 0;
b = 1;
}
else
for (int i = 1; i <= n; i++)
{
if (player[i].name == "女巫 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
else if (player[i].name == "预言家 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
}
}
Sleep(3000);
if (b == 0 && duyao == 1 && player[kkkk].life == 1)
{
system("cls");
print(hhh, hhhh);
cout << "请问你是否要用毒药???" << endl;
srand(time(0));
int x = rand() % 2;
Sleep(1500);
cout << "请问你要毒谁???" << endl;
if (x == 1)
{
duyao = 0;
int y = rand() % n + 1;
while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
y = rand() % n + 1;
kill2 = y;
}
}
else
{
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "请问你是否要用毒药???" << endl;
Sleep(3000);
cout << "请问你要毒谁???" << endl;
Sleep(3000);
}
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "女~巫~请~闭~眼~~~" << endl;
if (n > 6)
{
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "预~言~家~请~睁~眼~~~" << endl;
if (player[MY].name == "预言家 " && player[MY].life == 1)
{
Sleep(3000);
cout << "请问你想查验谁???" << endl << "输入:";
int x;
cin >> x;
player[x].know = 1;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "他的身份是:";
if (player[x].name == "狼人 ")
cout << "狼人" << endl;
else
cout << "好人" << endl;
Sleep(3000);
}
else
{
Sleep(3000);
cout << "请问你想查验谁???" << endl;
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "他的身份是:......";
Sleep(3000);
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "预~言~家~请~闭~眼~~~" << endl;
}
Sleep(3000);
if (kill1 != 0)
player[kill1].life = 0;
if (kill2 != 0)
player[kill2].life = 0;
player[kill1].how = 1;
player[kill2].how = 3;
system("cls");
system("color F0");
print(hhh + 1, 0);
}
bool lr = 0;
void panduanlieren()
{
if (lr == 1)
return;
if (MY == lieren)
{
cout << "请射杀一名玩家" << endl;
int x;
cin >> x;
while (player[x].life != 1)
{
cout << "输入错误,请重新输入" << endl;
cin >> x;
}
Sleep(1000);
cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
player[x].life = 0;
player[x].how = 4;
}
else if (n >= 9)
{
srand(time(0));
int x = rand() % n + 1;
while (player[x].life != 1)
{
x = rand() % n + 1;
}
Sleep(1000);
cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
player[x].life = 0;
player[x].how = 4;
}
lr = 1;
}
void print1()
{
cout << "天亮了,昨晚";
if (kill1 != 0 || kill2 != 0)
{
cout << kill1 << "号";
if (kill2 != 0)
{
cout << "," << kill2 << "号";
kill2 = 0;
}
cout << "被杀" << endl;
}
else
cout << "是平安夜" << endl;
}
int main()
{
system("cls");
cout << " " << "狼人杀online" << endl;
cout << "请输入人数个数:" << endl;
scanf("%d", &n);
cout << "加载时间长,请耐心等待";
init1();
init2(n);
int k = 1;
do
{
srand(time(0));
init3(k);
cout << ".";
Sleep(17);
k++;
} while (k <= n);
system("cls");
system("color F0");
cout << "游戏即将开始";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
Sleep(1500);
cout << endl << endl << "请大家查看身份牌......" << endl;
Sleep(45);
srand(time(0));
MY = rand() % n + 1;
cout << "您的身份是:" << player[MY].name << endl;
Sleep(500);
cout << "在" << player[MY].num << "号位上" << endl;
system("pause");
system("cls");
player[MY].know = 2;
print(1, 0);
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night();
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(2, 0);
system("cls");
print(2, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(2, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(3, 0);
system("cls");
print(3, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(3, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(4, 0);
system("cls");
print(4, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(4, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(5, 0);
system("cls");
print(5, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(5, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(6, 0);
system("cls");
print(6, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(6, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(7, 0);
system("cls");
print(7, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0){
panduanlieren();
}
if (game_over()){
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
while (1)
system("pause");
return 0;
}
10.转杯子
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
char a[50][50]={"------",
"| |",
"| |",
"| |",
"------"};
int c,n=10,sudu;
bool k[200]={0,1,0,0};
void cls(){
system ("cls");
}
void xy(int y,int x) {
COORD coord;
coord.X=x;
coord.Y=y;
HANDLE a=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(a,coord);
}
void out(int x,int y,bool t){
if (t)
for (int i=0;i<5;i++,x++){
xy(x,y);
for (int j=0;j<6;j++)
cout <<a[i][j];
}
else
for (int i=0;i<5;i++,x++){
xy(x,y);
for (int j=0;j<6;j++)
cout <<" ";
}
}
void yuan(){
for (int i=1;i<=n;i++)
out (8,12*i-3,1);
}
void dong(){
int a,b,i,t;
a=rand()%n+1;
do
b=rand()%n+1;
while (b==a);
t=abs(12*a-12*b);
swap (k[a],k[b]);
out (8,12*a-3,0);
out (8,12*b-3,0);
for (i=7;i>=1;i--){
out (i,12*a-3,1);
out (16-i,12*b-3,1);
Sleep (sudu);
out (i,12*a-3,0);
out (16-i,12*b-3,0);
}
if (a>b)
for (i=1;i<=t;i++){
out (1,a*12-3-i,1);
out (15,b*12-3+i,1);
Sleep (sudu);
out (1,a*12-3-i,0);
out (15,b*12-3+i,0);
}
else
for (i=1;i<=t;i++){
out (15,b*12-3-i,1);
out (1,a*12-3+i,1);
Sleep (sudu);
out (15,b*12-3-i,0);
out (1,a*12-3+i,0);
}
for (i=1;i<=7;i++){
out (16-i,12*a-3,1);
out (i,12*b-3,1);
Sleep (sudu);
out (16-i,12*a-3,0);
out (i,12*b-3,0);
}
yuan();
}
int main(){
srand(int (0));
int in,d;
xy(0,5); cout <<"转杯子猜球:请选择难度星级:1 ~ 20 ( 1 最简单 ,20 最难)";
xy(1,5); cin >>in;
if (in<1) in=1;
if (in>20) in=20;
c=(in+5)*3;
Sleep (500);
cls();
xy(0,5); cout <<"转杯子猜球:请选择杯子个数:3 ~ 10";
xy(1,5);
cin >>n;
if (n<3) n=3;
if (n>10) n=10;
sudu=round(20/n)-round(in/n);
cls();
yuan();
for (int i=1;i<=7;i++){
xy(i,11); cout <<"★";
Sleep (100);
xy(i,11); cout <<" ";
}
for (int i=1;i<=c;i++)
dong();
xy(20,20);
cout <<"转完了,请问球在哪个杯子里呢?";
xy(22,20);
cin >>in;
for (int i=1;i<=n;i++)
if (k[i]){
d=i;
break;
}
xy(24,20);
if (in==d)
cout <<"恭喜你猜对了!!";
else
cout <<"很遗憾,正确答案是" <<d;
Sleep(1000);
xy(30,100);
return 0;
}
11.飞翔的小鸟
#include<bits/stdc++.h>
#include<Windows.h>
#define PR_Box printf("■")
#define PR_Gold printf("★")
#define PR_Ag printf("☆")
#define PR_FBird printf("Ю")
#define PR_DBird printf("Ф")
#define PR_Land printf("┳┳┯")
#define PR_Bg_TL printf("╔")
#define PR_Bg_TR printf("╗")
#define PR_Bg_DL printf("╚")
#define PR_Bg_DR printf("╝")
#define PR_Bg_X printf("═")
#define PR_Bg_Y printf("║")
#define PR_Blank printf(" ");
int Grade=1,C_Gold=0,C_Ag=0,Score=0,Delay_time=1000,Max_blank=9,Distance=18;
struct Birds {
int x,y;
int condition;
};
Birds*Bird=(Birds*)malloc(sizeof(Birds));
struct Bg {
int x,y;
int l_blank;
int reward[9];
Bg*pri;
Bg*next;
};
Bg*Bg1=new Bg[sizeof(Bg)];
void Position(int x,int y) {
COORD pos= {x-1,y-1};
HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out,pos);
}
void CreatBird() {
Bird->x=41;
Bird->y=10;
Bird->condition=0;
}
void CreatBg() {
Bg*Bg2=(Bg*)malloc(sizeof(Bg));
Bg1->x=90;
Bg1->y=8;
Bg2->x=Bg1->x+Distance;
Bg2->y=9;
Bg1->l_blank=Max_blank-Grade;
Bg2->l_blank=Max_blank-Grade;
Bg1->next=Bg2;
Bg1->pri=Bg2;
Bg2->next=Bg1;
Bg2->pri=Bg1;
}
void InsertBg(Bg*p) {
int temp;
Bg*Bgs=(Bg*)malloc(sizeof(Bg));
Bgs->x=p->pri->x+Distance;
Bgs->l_blank=Max_blank-Grade;
srand((int)time(0));
temp=rand();
if(temp%2==0) {
if((temp%4+p->pri->y+Max_blank-Grade)<21)Bgs->y=p->pri->y+temp%4;
else Bgs->y=p->pri->y;
} else {
if((p->pri->y-temp%4)>2)Bgs->y=p->pri->y-temp%4;
else Bgs->y=p->pri->y;
}
Bgs->pri=p->pri;
Bgs->next=p;
p->pri->next=Bgs;
p->pri=Bgs;
}
void Check_Bg(Bg*q) {
Bg*p=q;
int i=0,temp;
while(++i<=5) {
if(p->x>-4)p=p->next;
else {
srand((int)time(0));
temp=rand();
if(temp%2==0) {
if((temp%4+p->y+Max_blank-Grade)<21)p->y=p->y+temp%4;
else p->y=p->y;
p->x=p->pri->x+Distance;
p->l_blank=Max_blank-Grade;
} else {
if((p->y-temp%4)>2)p->y=p->y-temp%4;
else p->y=p->y;
p->x=p->pri->x+Distance;
p->l_blank=Max_blank-Grade;
}
}
}
}
void Loop_Bg(Bg*q) {
Bg*p=q;
int i=0;
while(++i<=5) {
p->x=p->x-1;
p=p->next;
if(Bird->x==p->x) {
Score+=1;
if(Score%4==0&&Grade<4)Grade++;
}
}
}
void Prt_Bg(Bg*q) {
Bg*p=q;
int i=0,k,j;
while(++i<=5) {
if(p->x>0&&p->x<=78) {
for(k=2; k<p->y; k++) {
Position(p->x+1,k);
PR_Box;
PR_Box;
PR_Blank
}
Position(p->x,p->y);
PR_Box;
PR_Box;
PR_Box;
PR_Blank;
Position(p->x,p->y+p->l_blank);
PR_Box;
PR_Box;
PR_Box;
PR_Blank;
k=k+p->l_blank+1;
for(k; k<=22; k++) {
Position(p->x+1,k);
PR_Box;
PR_Box;
PR_Blank;
}
Position(p->x,23);
for(k=1; k<Distance/3-2; k++)PR_Land;
}
p=p->next;
if(p->x==0) {
for(j=2; j<p->y; j++) {
Position(p->x+1,j);
PR_Blank;
PR_Blank;
}
Position(p->x+1,p->y);
PR_Blank;
PR_Blank;
PR_Blank;
Position(p->x+1,p->y+Max_blank-Grade);
PR_Blank;
PR_Blank;
PR_Blank;
j=j+Max_blank-Grade+1;
for(j; j<=22; j++) {
Position(p->x+1,j);
PR_Blank;
PR_Blank;
}
}
}
}
void PrtBg() {
int i;
Position(1,1);
PR_Bg_TL;
Position(79,1);
PR_Bg_TR;
Position(1,24);
PR_Bg_DL;
Position(79,24);
PR_Bg_DR;
for(i=3; i<=78; i+=2) {
Position(i,1);
PR_Bg_X;
Position(i,24);
PR_Bg_X;
}
}
void PrtBird() {
Position(Bird->x,Bird->y-1);
PR_Blank;
Position(Bird->x,Bird->y);
PR_FBird;
Position(38,2);
printf("Score:%d",Score);
}
int CheckYN(Bg*q) {
Bg*p=q;
int i=0;
while(++i<=5) {
if(Bird->y>23)return 0;
if(Bird->x==p->x&&Bird->y<=p->y)return 0;
if((Bird->x==p->x||Bird->x==p->x+1||Bird->x==p->x+2)&&Bird->y==p->y)return 0;
if(Bird->x==p->x&&Bird->y>p->y+p->l_blank)return 0;
if((Bird->x==p->x||Bird->x==p->x+1||Bird->x==p->x+2)&&Bird->y==p->y+p->l_blank)return 0;
p=p->next;
}
return 1;
}
void Prtfirst() {
printf("══════════════════════════════════════\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■ C++语言版 Flappy Bird\n");
printf(" ■■ ■■ 瞎搞人:侦探鼠\n");
printf(" ■■ ■■ 瞎搞日期:2019.7.3\n");
printf(" ■■ ■■ 耗时:2.46小时\n");
printf(" ■■■ ■■ 游戏说明:\n");
printf(" ■■ 1-按上箭头使鸟起飞\n");
printf(" ■■ 2-等级越高,难度越大!\n");
printf(" Ю ■■■\n");
printf("\n");
printf(" \n\n\n\n\n\n\n\n");
printf(" ┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳\n");
system("pause");
Position(1,1);
int i=0;
while(i++<40*25)PR_Blank;
}
int main() {
int i=0;
char ch;
Prtfirst();
PrtBg();
CreatBg();
InsertBg(Bg1);
InsertBg(Bg1);
InsertBg(Bg1);
CreatBird();
while(1) {
if(!CheckYN(Bg1))break;
Check_Bg(Bg1);
Prt_Bg(Bg1);
PrtBird();
Loop_Bg(Bg1);
Bird->y=Bird->y+1;
if(GetAsyncKeyState(VK_UP)) {
Position(Bird->x,Bird->y-1);
PR_Blank;
Bird->y=Bird->y-4;
}
while(i++<500);
{
Sleep(100);
}
i=0;
}
Position(38,10);
printf("Game Over!");
Position(1,25);
system("pause");
}
12.密室寻宝
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define s Sleep(800)
using namespace std;
int my_i=20,my_j=21;
int m_c_i=13,m_c_j=76;
int treasure_i=9,treasure_j=67;
int P_t_i=29,P_t_j=88;
int pyramid_i=22,pyramid_j=76,pyramid_k=1;
int School_i=50,School_j=1;
int line1=43,line2=35,line3=27,line4=19,line5=11,line6=3;
bool OK1,OK2,OK3,OK4,OK5,OK6;
char mapp[100][100]={
" ============================================== ------------------------- ",
"| | || |",
"| | || |",
"| | || |",
"| | || |",
"| cave | || |",
"| || |",
"| | || |",
"| | || |",
"|--------------- || |",
"| || |",
"| || |",
"| || |",
"| || |",
"| || |",
"| ||w:up |",
"| ||a:left |",
"| ||s:down |",
"| ||d:right |",
"| || |",
"| || |",
" ============================================== ------------------------- "
};
char cave[100][100]={
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^> ",
"Exit |",
"|---------------------------- ----------------- ------------------------- |",
"|-------------------------- | - ||----------------------| |",
"| | | | | | || | |",
"| ----------------------- | | | | | || |------------------| | |",
"| | | | | | | || |------------------| | |",
"| | -------------- | | | | || | | | |",
"| | | | | | || | |--------------- | | |",
"| ---------- ----------- -----| | | | || | | | | | | ",
"| | ------------- | | | | |-|| | | -------------| | | | ",
"| | | | | | |-------- ------------- | | | | | ",
"| | |----------- | | | | | -----------------| | | ",
"| |-------------- | |-| |-| |------ --------------| | ",
"| | | | | | |--------------------------",
"| |------------ | |---|-|---| | | |---------- | ",
"| | | |------------------| | | |--------------------- | ",
"| | | | | | | |------ | | ",
"| |-----------| | ----------| |----| | | | |----------------------| | ",
"| | | | |----| | | -----------------------------| | ",
"|---------------| | | | | ",
"|*:treasure | -----------------|-|-------------------------------------| ",
"| | | ",
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>| ",
};
char pyramid[100][100][100]={
{
"------------------------------------------------------------------------------------------",
"|up |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"------------------------------------------------------------------------------------------",
},
{
"------------------------------------------------------------------------------",
"|up |",
"|down |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"------------------------------------------------------------------------------",
},
{
"---------------------------------------------------------------------",
"|down |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"| |",
"---------------------------------------------------------------------",
},
};
char school[1000][100]={
"----------------------------------------------------",
"| |",
"| |",
"|-------------- |",
"| | |",
"| | |",
"|Class 1 | |",
"|Senior 3 | |",
"| | |",
"| |",
"|-------------- |",
"| --------------",
"| | |",
"| | |",
"| | Class 1|",
"| | Senior 2|",
"| | |",
"| |",
"| --------------",
"|-------------- |",
"| | |",
"| | |",
"|Class 1 | |",
"|Senior 1 | |",
"| | |",
"| |",
"|-------------- |",
"| --------------",
"| | |",
"| | |",
"| | Class 1|",
"| | Junior 3|",
"| | |",
"| |",
"| --------------",
"|-------------- |",
"| | |",
"| | |",
"|Class 1 | |",
"|Junior 2 | |",
"| | |",
"| |",
"|-------------- |",
"| --------------",
"| | |",
"| | |",
"| | Class 1|",
"| | Junior 1|",
"| | |",
"| |",
"| --------------",
"----------------------------------------------------",
};
void Mercury_forced_landing();
void Adventure();
void Pyramid();
void to_continue()
{
string be_continue;
be_continue=getch();
system("cls");
}
void operation()
{
string ope;
ope=getch();
if((ope=="w"||ope=="W")&&my_i>1&&mapp[my_i-1][my_j]!='-'&&mapp[my_i-1][my_j]!='|')
{
my_i--;
}
if((ope=="a"||ope=="A")&&my_j>1&&mapp[my_i][my_j-1]!='-'&&mapp[my_i][my_j-1]!='|')
{
my_j--;
}
if((ope=="s"||ope=="S")&&my_i<20&&mapp[my_i+1][my_j]!='-'&&mapp[my_i+1][my_j]!='|')
{
my_i++;
}
if((ope=="d"||ope=="D")&&my_j<46&&mapp[my_i][my_j+1]!='-'&&mapp[my_i][my_j+1]!='|')
{
my_j++;
}
}
void operation_cave(){
string ope;
ope=getch();
if((ope=="w"||ope=="W")&&m_c_i>1&&cave[m_c_i-1][m_c_j]!='-'&&cave[m_c_i-1][m_c_j]!='|'){
m_c_i--;
}
if((ope=="a"||ope=="A")&&m_c_j>1&&cave[m_c_i][m_c_j-1]!='-'&&cave[m_c_i][m_c_j-1]!='|'){
m_c_j--;
}
if((ope=="s"||ope=="S")&&m_c_i<22&&cave[m_c_i+1][m_c_j]!='-'&&cave[m_c_i+1][m_c_j]!='|'){
m_c_i++;
}
if((ope=="d"||ope=="D")&&m_c_j<75&&cave[m_c_i][m_c_j+1]!='-'&&cave[m_c_i][m_c_j+1]!='|'){
m_c_j++;
}
}
void operation_pyramid(){
string ope;
ope=getch();
if((ope=="w"||ope=="W")&&pyramid_i>1){
pyramid_i--;
}
if((ope=="a"||ope=="A")&&pyramid_j>1){
pyramid_j--;
}
int temp_i,temp_j;
if(pyramid_k==0){
temp_i=29;
temp_j=88;
}
else if(pyramid_k==1){
temp_i=22;
temp_j=76;
}
else{
temp_i=17;
temp_j=67;
}
if((ope=="s"||ope=="S")&&pyramid_i<temp_i){
pyramid_i++;
}
if((ope=="d"||ope=="D")&&pyramid_j<temp_j){
pyramid_j++;
}
}
void operation_School(){
string ope;
ope=getch();
if((ope=="w"||ope=="W")&&School_i>1&&school[School_i-1][School_j]!='-'&&school[School_i-1][School_j]!='|'&&(School_i-1!=line1||OK1==true)&&(School_i-1!=line2||OK2==true)&&(School_i-1!=line3||OK3==true)&&(School_i-1!=line4||OK4==true)&&(School_i-1!=line5||OK5==true)&&(School_i-1!=line6||OK6==true)){
School_i--;
}
if((ope=="a"||ope=="A")&&School_j>1&&school[School_i][School_j-1]!='-'&&school[School_i][School_j-1]!='|'){
School_j--;
}
if((ope=="s"||ope=="S")&&School_i<50&&school[School_i+1][School_j]!='-'&&school[School_i+1][School_j]!='|'){
School_i++;
}
if((ope=="d"||ope=="D")&&School_j<50&&school[School_i][School_j+1]!='-'&&school[School_i][School_j+1]!='|'){
School_j++;
}
}
void print(char map[100][100]) {
for(int i=0;i<22;i++){
for(int j=0;j<76;j++){
if(i==my_i&&j==my_j)
cout<<0;
else
cout<<mapp[i][j];
}
cout<<endl;
}
}
void print_cave(char cave[100][100]){
for(int i=0;i<24;i++){
for(int j=0;j<78;j++){
if(i==m_c_i&&j==m_c_j)
cout<<0;
else if(i==treasure_i&&j==treasure_j)
cout<<"*";
else
cout<<cave[i][j];
}
cout<<endl;
}
cout<<"Your coordinate:("<<m_c_i<<" , "<<m_c_j<<")"<<endl;
cout<<"THINK······"<<endl;
cout<<"one/seven dilemmas"<<endl;
}
void print_pyramid(char pyramid[100][100][100]){
if(pyramid_k==0){
for(int i=0;i<31;i++){
for(int j=0;j<90;j++){
if(i==P_t_i&&j==P_t_j){
cout<<"*";
}
else if(i==pyramid_i&&j==pyramid_j)
cout<<0;
else
cout<<pyramid[pyramid_k][i][j];
if(pyramid_i==1&&pyramid_j==1)
pyramid_k=1;
}
cout<<endl;
}
}
else if(pyramid_k==1){
for(int i=0;i<24;i++){
for(int j=0;j<78;j++){
if(i==pyramid_i&&j==pyramid_j){
cout<<0;
}
else
cout<<pyramid[pyramid_k][i][j];
if(pyramid_i==1&&pyramid_j==1)
pyramid_k=2;
if(pyramid_i==2&&pyramid_j==1)
pyramid_k=0;
}
cout<<endl;
}
}
else{
for(int i=0;i<19;i++){
for(int j=0;j<69;j++){
if(i==pyramid_i&&j==pyramid_j){
cout<<0;
}
else
cout<<pyramid[pyramid_k][i][j];
if(pyramid_i==1&&pyramid_j==1)
pyramid_k=1;
}
cout<<endl;
}
}
cout<<"Your coordinate:("<<pyramid_i<<" , "<<pyramid_j<<" , "<<pyramid_k<<")"<<endl;
cout<<"THINK······"<<endl;
cout<<"two/seven dilemmas"<<endl;
}
void print_School(char school[1000][100]){
for(int i=0;i<52;i++){
for(int j=0;j<52;j++){
if(i==School_i&&j==School_j)
printf("0");
else
printf("%c",school[i][j]);
if(OK1==false&&i==line1){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(OK2==false&&i==line2){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(OK3==false&&i==line3){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(OK4==false&&i==line4){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(OK5==false&&i==line5){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(OK6==false&&i==line6){
for(int p=0;p<52;p++)
cout<<"-";
break;
}
if(School_i==49&&School_j==38){
system("cls");
Sleep(4000);
OK1=true;
School_j--;
}
if(School_i==41&&School_j==14){
system("cls");
Sleep(4000);
OK2=true;
School_j++;
}
if(School_i==33&&School_j==38){
system("cls");
Sleep(4000);
OK3=true;
School_j--;
}
if(School_i==25&&School_j==14){
system("cls");
Sleep(4000);
OK4=true;
School_j++;
}
if(School_i==17&&School_j==38){
system("cls");
Sleep(4000);
OK5=true;
School_j--;
}
if(School_i==9&&School_j==14){
system("cls");
Sleep(4000);
OK6=true;
School_j++;
}
}
cout<<endl;
}
cout<<"Your coordinate:("<<School_i<<" , "<<School_j<<")"<<endl;
cout<<"THINK······"<<endl;
cout<<"three/seven dilemmas"<<endl;
}
void Game_background(){
cout<<" You live in Mercury and everything is so beautiful.But one day······BOOM!!! The Mercury made a forced landing."<<endl;
Sleep(2000);
cout<<" When you open your eyes,you crossed!Now you have two choices."<<endl;
Sleep(2000);
cout<<" 1、Go back to the crashed Mercury and there will be appear some Lucky Square(NOT OPEN)."<<endl;
cout<<" 2、Continue the adventure."<<endl;
cout<<" Your Answer:";
}
void Choose(){
cout << "1.exit\n2.start\n";
string choose;
choose=getch();
cout<<choose<<endl;
system("cls");
if(choose=="1")
return ;
if(choose=="2")
Adventure();
}
void Die(){
system("cls");
cout<<"YOU DIE!!!!!!!!!!"<<endl;
Sleep(1000);
cout<<"I told you THINK······";
exit(1);
}
void DIE(){
system("cls");
cout<<"You go through a long long long slide."<<endl;
Sleep(4000);
system("cls");
cout<<"Oh,no!It's Hell·Vanishing Shadow!The king of devil."<<endl;
cout<<"1、fight! 2 or other、wait for die(because you can't escape)"<<endl;
string choose;
choose=getch();
if(choose=="1"){
int HP=100,ATK=10;
int E_HP=10000,E_ATK=1000;
while(HP>0&&E_HP>0){
system("cls");
cout<<"(Your Turn):"<<endl;
int Crit=rand()%100;
if(Crit<20){
cout<<"CRIT!!!"<<endl;
cout<<"Cause "<<10*ATK<<" point of damage."<<endl;
E_HP-=10*ATK;
}
else{
cout<<"Cause "<<ATK<<" point of damage."<<endl;
E_HP-=ATK;
}
cout<<"Hell·Vanishing Shadow has "<<E_HP<<" left."<<endl;
if(E_HP<=0)
break;
Sleep(1500);
cout<<"(Enemy's turn):"<<endl;
int E_Crit=rand()%100;
if(Crit<60){
cout<<"CRIT!!!"<<endl;
cout<<"Cause "<<10*E_ATK<<" point of damage."<<endl;
HP-=10*E_ATK;
}
else
{
cout<<"Cause "<<E_ATK<<" point of damage."<<endl;
HP-=E_ATK;
}
cout<<"You have "<<HP<<" left."<<endl;
Sleep(1500);
}
if(HP<=0)
Die();
else{
cout<<"You have killed Hell·Vanishing Shadow."<<endl;
cout<<"But,the Hell·Vanishing Shadow change into Crazy · vanishing shadow!";
int Crazy_HP=100000,Crazy_ATK=10000;
while(HP>0&&Crazy_HP>0){
system("cls");
cout<<"(Your Turn):"<<endl;
int Crit=rand()%100;
if(Crit<20){
cout<<"CRIT!!!"<<endl;
cout<<"Cause "<<10*ATK<<" point of damage."<<endl;
Crazy_HP-=10*ATK;
}
else{
cout<<"Cause "<<ATK<<" point of damage."<<endl;
Crazy_HP-=ATK;
}
cout<<"Crazy·Vanishing Shadow has "<<Crazy_HP<<" left."<<endl;
if(Crazy_HP<=0)
break;
Sleep(1500);
cout<<"(Enemy's turn):"<<endl;
int E_Crit=rand()%100;
if(Crit<60){
cout<<"CRIT!!!"<<endl;
cout<<"Cause "<<10*Crazy_ATK<<" point of damage."<<endl;
HP-=10*Crazy_ATK;
}
else{
cout<<"Cause "<<Crazy_ATK<<" point of damage."<<endl;
HP-=Crazy_ATK;
}
cout<<"You have "<<HP<<" left."<<endl;
Sleep(1500);
}
if(HP<=0)
Die();
else{
cout<<"YOU WIN!";
exit(1);
}
}
}
else
Die();
}
bool Judge_cave(){
if(my_i==6&&my_j==17)
return true;
return false;
}
bool Judge_treasure(){
if(m_c_i==treasure_i&&m_c_j==treasure_j)
return true;
return false;
}
bool Judge_treasure_Pyramid(){
if(pyramid_i==P_t_i&&pyramid_j==P_t_j&&pyramid_k==0)
return true;
return false;
}
bool Judge_Exit()
{
if(m_c_i==22&&m_c_j==75)
return true;
return false;
}
bool Judge_Exit_Pyramid()
{
if(pyramid_i==10&&pyramid_j==1&&pyramid_k==2)
return true;
return false;
}
bool Judge_die()
{
if(m_c_i==1&&m_c_j==1)
return true;
return false;
}
void The_Lost_Tomb_Cave()
{
string Page[20]={"one","two","three","four","five","six","seven","eight","nine","ten"};
int page=0;
while(1)
{
system("cls");
cout<<"Note:"<<endl;
if(page==0)
{
cout<<" The Lost Tomb·Cave Ruins"<<endl;
Sleep(2000);
cout<<" During the Warring States Period,many soldiers came to this cave.They lost,after three years ,local people came and found their bones."<<endl;
Sleep(1500);
cout<<"After a year some brave hunters came to this cave.They lost,they die,the bones.One year later,lost,die,bones,the same time.Again and again······"<<endl;
Sleep(1500);
cout<<" In the Qing Dynasty,no one wants to try.Soon the cave was faded······"<<endl;
}
else if(page==9)
cout<<"2275······"<<endl<<endl<<endl<<endl;
else
cout<<endl<<endl<<endl<<endl;
cout<<" "<<Page[page]<<"/ten"<<endl<<endl;
cout<<"a:last page d:next page other:Exit[->"<<endl;
string get;
get=getch();
cout<<get<<endl;
if(get!="a"&&get!="d")
break;
if(get=="a")
{
if(page>0)
page--;
}
else
{
if(page<9)
page++;
}
}
}
void The_Lost_Tomb_Pyramid()
{
string Page[30]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int page=0;
while(1)
{
system("cls");
cout<<"Note:"<<endl;
if(page==0)
{
cout<<" The Lost Tomb·Pyramid Temple"<<endl;
Sleep(2000);
cout<<" Horu,the patron saint of the Pharaoh in ancient Egyptian mythology and the symbol of kingship and the God of revenge."<<endl;
Sleep(1500);
cout<<" '`A νουβιs,the death of the Egypt.He alone plunged the whole ancient Egypt into chaos."<<endl;
Sleep(1500);
cout<<" Horu use one hundred years subdued '`A νουβιs and take him to this Pyramid.But After that battle Horu was weak.He died."<<endl;
Sleep(1500);
cout<<"But after a year,when the local people came to the Pyramid,he became very frightend,and he was dead.'`A νουβιs was gone······"<<endl;
}
if(page==9)
cout<<"!"<<endl<<endl<<endl<<endl<<endl;
if(page==11)
cout<<"!,!"<<endl<<endl<<endl<<endl<<endl;
if(page!=0&&page!=9&&page!=11)
cout<<endl<<endl<<endl<<endl<<endl;
cout<<" "<<Page[page]<<"/twenty"<<endl<<endl;
cout<<"a:last page d:next page other:Exit[->"<<endl;
string get;
get=getch();
cout<<get<<endl;
if(get!="a"&&get!="d")
break;
if(get=="a")
{
if(page>0)
page--;
}
else
{
if(page<19)
page++;
}
}
}
void The_Lost_Tomb_School(){
string Page[30]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int page=0;
while(1)
{
system("cls");
cout<<"Note:"<<endl;
if(page==0)
{
cout<<" The Lost Tomb·Thrill School"<<endl;
Sleep(2000);
cout<<" During the school time,Buddy has split personality.He has double personalities.The fisrt personality is kind.He used it at school.But the second personality is tyrant."<<endl;
Sleep(2000);
cout<<"Buddy was so hard to control his second personality that he took medicine to control it.But,I terrible day came:"<<endl;
Sleep(2000);
cout<<"School bully took his madicine,a nightmare day came······"<<endl;
Sleep(2000);
cout<<" He began to be crazy,and the second personality began······"<<endl;
Sleep(2000);
cout<<" One year later this school change into Lunatic asylum.And This 'school' has also become a 'paradise' for";
Sleep(7000);
cout<<"——Buddy······"<<endl;
Sleep(3000);
}
else
cout<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<" "<<Page[page]<<"/one"<<endl<<endl;
cout<<"a:last page d:next page other:Exit[->"<<endl;
string get;
get=getch();
cout<<get<<endl;
if(get!="a"&&get!="d")
break;
if(get=="a")
{
if(page>0)
page--;
}
else
{
if(page<0)
page++;
}
}
}
void School()
{
system("cls");
bool flag=false;
while(flag==false)
{
print_School(school);
operation_School();
system("cls");
}
}
void Pyramid()
{
system("cls");
bool flag=false;
while(flag==false)
{
print_pyramid(pyramid);
operation_pyramid();
if(Judge_treasure_Pyramid()==true)
{
The_Lost_Tomb_Pyramid();
P_t_i=1000;
P_t_j=1000;
}
if(Judge_Exit_Pyramid()==true)
{
School();
flag=true;
}
system("cls");
}
}
void Cave()
{
bool flag=false;
while(flag==false)
{
print_cave(cave);
operation_cave();
if(Judge_treasure()==true)
{
The_Lost_Tomb_Cave();
treasure_i=1000;
treasure_j=1000;
}
if(Judge_Exit()==true)
{
Pyramid();
flag=true;
}
if(Judge_die()==true)
DIE();
system("cls");
}
}
void Adventure()
{
while(1)
{
print(mapp);
operation();
system("cls");
if(Judge_cave()==true)
{
Cave();
}
}
}
int main(){
Choose();
return 0;
}