7、飞翔的小鸟
#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");
}
8、愤怒小鸟
#include <bits/stdc++.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
using namespace std;
const double pi = 3.1415926536;
int toint (float a) {
return ((int) (a * 10 + 5)) / 10;
}
void Color (int a) {
if (a == 0 || a == 14 || a == 20) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
} else if (a == 1 || a == 12) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
} else if (a == 2) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_GREEN);
} else if (a == 3) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
} else if (a == 4 || a == 11) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_RED);
} else if (a == 5 || a == 13) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
} else if (a == 7) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_GREEN|FOREGROUND_BLUE);
} else if (a == 15) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
} else if (a == 16) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
} else if (a == 17) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);
} else if (a == 8) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
} else if (a == 6) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_BLUE);
} else if (a == 9) {
SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_RED|BACKGROUND_GREEN);
}
}
void SetPos (float x, float y) {
int xx = toint (x), yy = toint (y);
COORD pos;
pos.X = yy * 2;
pos.Y = xx;
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), pos);
}
struct node {
int W, W2, S, mS;
float X, Y;
float vx, vy;
float ax, ay;
bool go, boom;
} blt[100001], pig[100001], boo[100001];
int T, yX, yY, Xy, put, K, K2, Sle, What;
int Bot, Pit, Blt, Pig, Sco, pigk, scok;
int m[41][41];
void Cout (int a, int x, int y) {
if (a == 1) {
SetPos (x, y);
Color (5);
cout << put << ' ';
}
if (y == 202) {
SetPos (pig[a].X, pig[a].Y);
cout << " ";
if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {
SetPos (pig[a].X - 2, pig[a].Y);
cout << " ";
SetPos (pig[a].X - 1, pig[a].Y);
cout << " ";
} else if (pig[a].W == 4) {
SetPos (pig[a].X, pig[a].Y - 1);
cout << " ";
} else if(pig[a].W == 5) {
SetPos (pig[a].X - 1, pig[a].Y);
cout << " ";
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << " ";
}
}
if (a == 2) {
for (int i = 0; i <= 40; i++) {
for (int j = 0; j <= 40; j++) {
if (i <= 18 && m[i][j] == 1) {
SetPos (i, j);
Color (7);
cout << "■";
}
if (m[i][j] >= 2 && m[i][j] <= 19) {
SetPos (i, j);
Color (5);
cout << "█";
m[i][j]++;
}
if (m[i][j] > 19 && m[i][j] <= 29) {
SetPos (i, j);
Color (0);
cout << "█";
m[i][j]++;
if (m[i][j] == 30) {
SetPos (i, j);
Color (0);
cout << " ";
m[i][j] = 0;
}
if (m[i][j] >= 31 && m[i][j] <= 49) {
SetPos (i, j);
Color (0);
cout << "■";
m[i][j]++;
}
if (m[i][j] == 50) {
SetPos (i, j);
Color (7);
cout << "■";
m[i][j] = 1;
}
}
}
}
}
if (y == 666) {
SetPos (blt[a].X, blt[a].Y);
Color (10 + blt[a].W);
cout<<"●";
}
Color (0);
}
void Go (int a) {
SetPos (blt[a].X, blt[a].Y);
cout << " ";
blt[a].X += blt[a].vx / 2;
blt[a].Y += blt[a].vy / 2;
blt[a].vx += blt[a].ax / 2;
blt[a].vy += blt[a].ay / 2;
if (blt[a].X >= 20) {
blt[a].X = 19;
}
if (blt[a].X > 20 || blt[a].Y > 38 || blt[a].X < 0 || blt[a].Y <= 0) {
blt[a].go = 1;
}
if (blt[a].W2 == 1 && blt[a].Y >= Xy) {
blt[a].go = 1;
Sle = 0;//地跑鸟
}
if (blt[a].W2 == 0) {
for (int i = 0; i <= blt[a].vx / 2 + 1; i++) {
if (blt[a].vx > 0 && m[toint (blt[a].X) + i][toint (blt[a].Y)] == 1) {
if (blt[a].W != 5) {
blt[a].boom = 1;
}
blt[a].X = toint (blt[a].X) + i - 1;
blt[a].Y += blt[a].vy / 2;
blt[a].vx = -blt[a].vx * 0.4;
blt[a].vy = blt[a].vy * 0.8;
if (blt[a].W == 3) {
blt[a].ax = 0.5;
}
if (blt[a].W == 7) {
blt[a].vx *= 2;
}
if (blt[a].W == 10) {
blt[a].go = 1;
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
}
if (blt[a].vx < 0 && m[toint (blt[a].X) - i][toint(blt[a].Y)] == 1) {
if (blt[a].W != 5) {
blt[a].boom = 1;
}
blt[a].X = toint (blt[a].X) + i + 1;
blt[a].Y += blt[a].vy / 2;
blt[a].vx = -blt[a].vx;
blt[a].vy=blt[a].vy * 0.8;
if (blt[a].W == 3) {
blt[a].ax = 0.5;
}
if (blt[a].W == 7) {
blt[a].vx *= 2;
}
if (blt[a].W == 10) {
blt[a].go = 1;
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
}
}
if (abs (blt[a].vx) <= 0.1 && abs (blt[a].vy) <= 0.1 && abs (blt[a].ay) <= 0.1) {
blt[a].go = 1;
if (blt[a].W == 5) {
Bot++;
boo[Bot].X = blt[a].X;
boo[Bot].Y = blt[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
blt[a].go = 1;
}
}
}
if (blt[a].go == 0) {
Cout (a, 0, 666);
}
}
void Kill (int a) {
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {
pig[a].W = 1;
}
int R = rand () % 50;
Cout (a, 202, 202);
//清除猪猪
pig[a].X += pig[a].vx / 2;
pig[a].Y += pig[a].vy / 2;
pig[a].vx += pig[a].ax / 2;
pig[a].vy += pig[a].ay / 2;
for (int i = -2; i <= pig[a].vx / 2 + 1; i++) {
if (m[toint (pig[a].X) + i][toint (pig[a].Y)] == 1) {
pig[a].X = toint (pig[a].X) + i - 1;
pig[a].Y += pig[a].vy / 2;
pig[a].vx = -pig[a].vx * 0.5;
pig[a].vy = pig[a].vy * 0.8;
}
}
for (int i = Blt - 10; i <= Blt; i++) {
if (pig[a].W == 5 && blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1
&& abs (pig[a].Y - blt[i].Y) <= 1) {
m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;
pig[a].W2++;
Sco += 2;
break;
}
if (pig[a].W == 5 && m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&
m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {
m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;
pig[a].W2++;
Sco += 2;
break;
}
if (blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {
if (pig[a].W == 6) {
Bot++;
boo[Bot].X = pig[a].X;
boo[Bot].Y = pig[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
blt[i].go = 1;
}
m[toint (pig[a].X)][toint (pig[a].Y)] = 2;
pig[a].go = 1;
Pig--;
Sco+=10;
break;
}
if (m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&
m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {
if (pig[a].W == 6) {
Bot++;
boo[Bot].X = pig[a].X;
boo[Bot].Y = pig[a].Y;
boo[Bot].S = 1;
boo[Bot].mS = 4;
}
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
if ((pig[a].W == 2 || pig[a].W == 3) && blt[i].go == 0 &&
abs (pig[a].X - 2 - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {
m[toint (pig[a].X)][toint (pig[a].Y)] = 2;
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
if ((pig[a].W == 2 || pig[a].W == 3) &&
m[toint (pig[a].X - 2)][toint (pig[a].Y)] >= 2
&& m[toint (pig[a].X - 2)][toint (pig[a].Y)] < 30) {
pig[a].go = 1;
Pig--;
Sco += 10;
break;
}
}
//弄死猪猪
if (pig[a].go == 0) {
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 &&pig[a].Y < 20) {
pig[a].W = 1;
}
int Xx = toint (pig[a].X), Xy = toint (pig[a].Y);
if (pig[a].W == 6) {
SetPos (pig[a].X, pig[a].Y);
Color (9);
cout << "TN";
Color (0);
} else {
SetPos (pig[a].X, pig[a].Y);
Color (2);
cout << "●";
if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {
SetPos (pig[a].X - 2, pig[a].Y);
Color (0);
cout << "○";
SetPos (pig[a].X - 1, pig[a].Y);
cout << "|";
} else if (pig[a].W == 4) {
SetPos (pig[a].X, pig[a].Y - 1);
Color (2);
cout << "﹃";
} else if (pig[a].W == 5) {
SetPos (pig[a].X - 1, pig[a].Y);
Color (8);
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << "▁";
if (pig[a].W2 == 0) {
cout << "▅";
} else if (pig[a].W2 == 1) {
cout << "▃";
} else if (pig[a].W2 == 2) {
cout << "▂";
} else if (pig[a].W2 == 3) {
pig[a].W = 1;
pig[a].W2 = 0;
SetPos (pig[a].X - 1, pig[a].Y - 1);
cout << " ";
}
}
}
//输出猪猪
if (pig[a].W == 2 && pig[a].X > pig[a].S) {
pig[a].W = 3;
pig[a].ax = -0.4;
pig[a].vx = 1.5;
} else if (pig[a].W == 3 && pig[a].X <= pig[a].S) {
pig[a].W = 2;
pig[a].ax = 0.4;
pig[a].vx = -1.5;
}
if ((pig[a].W == 2 || pig[a].W == 3) && (pig[a].Y <= 10 || pig[a].Y >= 38)) {
pig[a].vy *= -1;
}
if (pig[a].W == 4 && R == 0 && pig[a].X == 20) {
pig[a].vx = -((rand () % 40) / 10);
}
if(pig[a].W == 4) {
int r = rand () % 20;
for (int i = Blt - 10; i <= Blt; i++) {
if (r <= 5 && blt[i].go == 0 && pig[a].Y - blt[i].Y <= 5 &&
abs (blt[i].X - pig[a].X) <= 1.5 && r < 5) {
r = 0;
break;
}
}
if (r == 0) {
m[toint (pig[a].X)][toint (pig[a].Y) - 2] = 10;
m[toint (pig[a].X)][toint (pig[a].Y) - 3] = 2;
for (int j = toint (pig[a].Y) - 1; j >= toint (pig[a].Y) - 5; j--) {
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0 && !(blt[i].W == 3 && blt[i].boom == 1)
&& blt[i].W2 == 0 && toint (blt[i].Y) == j
&& abs (blt[i].X - pig[a].X) <= 2) {
blt[i].vy = -2;
}
}
for (int i = Pit - 50; i <= Pit; i++) {
if (pig[i].go == 0 && toint (pig[i].Y) == j && abs (pig[i].X - pig[a].X) <= 2) {
pig[i].vy = -1;
}
}
}
}
}
//移动猪猪
if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {
Cout (a, 202, 202);
pig[a].Y = 16;
}
if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {
pig[a].W = 1;
}
if (pig[a].X > 20 || pig[a].Y > 38 || pig[a].X < 0 || pig[a].Y <= 0) {
pig[a].go = 1;
Pig--;
Cout (a, 202, 202);
}
//清除猪猪
}
}
void Creat (int a, int p) {
if (a == -1 && p == -1) {
Blt++;
blt[Blt].W = What;
blt[Blt].W2 = 1;
blt[Blt].vy = 1;
blt[Blt].X = 19;
blt[Blt].Y = 0;
blt[Blt].boom = 1;
} else if (a == 0 && p == -1) {
int u = rand () % 7 + 1, U = rand() % 30;
if (u >= 5) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 1;
} else if (u == 1) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].vy = 0.5;
pig[Pit].ax = 0.5;
pig[Pit].S = rand () % 5 + 7;
pig[Pit].W = 2;
} else if (u == 2) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 4;
} else if (u == 3) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 5;
} else if (u == 4) {
Pit++;
pig[Pit].Y = rand () % 15 + 20;
pig[Pit].X = 2;
pig[Pit].ax = 0.5;
pig[Pit].W = 6;
}
if (U == 1) {
Bot++;
boo[Bot].Y = rand () % 13 + 15;
boo[Bot].X = (rand () % 4) * 3 + 8;
boo[Bot].S = 0;
boo[Bot].mS = rand () % 2 + 2;
boo[Bot].W2 = 1;
}
} else {
Blt++;
blt[Blt].W = What;
if (a == 1) {
blt[Blt].X = yX;
blt[Blt].Y = yY;
blt[Blt].ax = 0.5; //抛物线
}
blt[Blt].vx = -3.5 * sin (p * pi / 180);
blt[Blt].vy = 3 * cos (p * pi / 180);
if (p <= 45) {
blt[Blt].vy *= 1 + (0.33 - 0.01 * (45 - p));
}
if (p >= 45) {
blt[Blt].vy *= 1 + (0.33 - 0.01 * (p - 45));
}
if (blt[Blt].W == 6) {
blt[Blt].vy *= 1.2;
blt[Blt].ax = 0.4;
}
}
}
void Boom (int a) {
if (boo[a].W2 == 0) {
int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;
if (s == ms) {
return ;
}
for (int i = x - s; i <= x + s; i++) {
for (int j = y - s; j <= y + s; j++) {
float k = (i - x) * (i - x) + (j - y) * (j - y) - s * s;
if (k <= s && k >= -s && i <= 20 && j <= 38 && i >= 0 && j > 0 && m[i][j] != 1) {
m[i][j] = 2;
}
}
}
boo[a].S++;
}
if (boo[a].W2 == 1) {
int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;
if (s == ms) {
return ;
}
if (y - s > 10) {
m[x][y-s] = 31 - 31 * (boo[a].W2 - 1);
}
if (y + s < 40) {
m[x][y+s] = 31 - 31 * (boo[a].W2 - 1);
}
boo[a].S++;
}
}
void Move (int a) {
Color (5);
if (a == -2) {
SetPos (17, Xy);
cout << " ";
SetPos (18, Xy);
cout << " ";
SetPos (19, Xy);
cout << " ";
SetPos (20, Xy);
cout << " ";
}
if (a == -1) {
SetPos (17, Xy);
cout << " ";
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 0) {
SetPos (18, Xy);
cout << " ┃";
Color (What + 10);
cout << "●";
Color (5);
cout << "┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 1) {
SetPos (18, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 2) {
SetPos (18, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << "┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 3) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << "╰┳╯";
SetPos (20, Xy);
cout << " ▏";
}
if (a == 4) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
Color (What + 10);
cout << "●";
Color (5);
cout << " ▏";
}
if (a == 5) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ▏";
}
if (a == 6) {
SetPos (18, Xy);
cout << " ┃ ┃";
SetPos (19, Xy);
cout << " ╰┳╯";
SetPos (20, Xy);
cout << " ";
Color (What + 10);
cout << "●";
Color (5);
cout << " ";
}
Color (0);
}
void Start () {
char g;
Color (5);
system ("cls");
SetPos (1, 1);
cout << "------- 愤 怒 的 小 鸟 -------";
Color (0);
SetPos (3, 1);
cout << "空格瞄准,按X触发小鸟技能,←→移动弹弓";
SetPos (5, 1);
cout << "猪猪技能自动触发,空中会有墙出现。";
SetPos (7, 1);
cout << "危险值由命中率,猪的存活时间计算!";
SetPos (9, 1);
cout << "危险值点满后失败!1500分通关!";
SetPos (1, 20);
cout << "-------- 小 鸟 技 能 --------";
SetPos (3, 20);
Color (11);
cout << "●";
Color (0);
cout << ":无技能";
SetPos (5, 20);
Color (12);
cout << "●";
Color (0);
cout << ":分身!不同分身初速度大小相同,";
SetPos(6,20);cout<<" 方向不同。";
SetPos (7, 20);
Color (13);
cout << "●";
Color (0);
cout << ":加速!以当前速度做匀速直线运动,";
SetPos (8, 20);
cout << " 且免疫狙击猪的冲击。";
SetPos (9, 20);
Color (14);
cout << "●";
Color (0);
cout << ":投蛋!并获得向上速度做匀速直线";
SetPos (10, 20);
cout << " 运动,快达可以穿墙。";
SetPos (11, 20);
Color (15);
cout << "●";
Color (0);
cout << ":爆炸!";
SetPos (13, 20);
Color (16);
cout << "●";
Color (0);
cout << ":回旋!开始做向左加速运动!发射";
SetPos (14, 20);
cout << " 时获得双倍水平速度。";
SetPos (15, 20);
Color (17);
cout << "●";
Color (0);
cout << ":[被动] 弹跳力为普通鸟三倍。发射";
SetPos (16, 20);
cout << " 时获得1.5倍水平、竖直速度。";
SetPos (11, 1);
cout << "-------- 猪 猪 技 能 --------";
SetPos (13, 2);
Color (2);
cout << "●";
Color (0);
cout << ":无技能";
SetPos (14, 1);
Color (8);
cout << "▁▅";
SetPos (15, 2);
Color (2);
cout << "●";
Color (0);
cout << ":防御力为普通猪三倍";
SetPos (16, 2);
cout << "○";
SetPos (17, 2);
cout << "│:做空中简谐运动,受死范围";
SetPos (18, 2);
Color (2);
cout << "●";
Color (0);
cout << " 为普通猪两倍。";
SetPos (19, 2);
cout << " 有几率跳起或发射冲击波,冲";
SetPos (20, 1);
Color (2);
cout << "﹃●";
Color (0);
cout << ":开小鸟与同类,可以引爆TNT!";
SetPos (18, 20);
Color (5);
cout << "按 y 开始游戏!";
A:
if (kbhit ()) {
g = _getch ();
}
if(g != 'y') {
goto A;
}
}
int main () {
system ("mode con cols=79 lines=22");
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cursor_info);
srand ((unsigned)time(NULL));
St:Start ();
system ("cls");
memset (blt, 0, sizeof (blt));
memset (pig, 0, sizeof (pig));
memset (boo, 0, sizeof (boo));
memset (m, 0, sizeof (m));
T = put = K = K2 = Sle = What = Pig = Sco = 0;
pigk = scok = -1;
Xy = 4;
yX = 18;
yY = 6;
Blt = 20;
Bot = 20;
Pit = 60;
Color (7);
SetPos (19, 14);
cout << "■";
SetPos (20, 13);
cout << " █▍";
m[19][14] = m[20][13] = m[20][14] = 1;
SetPos (21, 0);
for (int i = 0; i < 39; i++) {
cout << "■";
m[21][i] = 1;
}
Color (0);
What = rand () % 5 + 1;
while (1) {
if (Sco >= 1500) {
break;
}
T++;
K = 0;
Color (0);
if (Sco != scok) {
SetPos (1, 1);
cout << "分数:" << Sco << ' ';
}
if (Pig != pigk) {
SetPos (3, 1);
cout << "危险值:";
int aa = min (Sco / 100, 10);
Pig += aa;
SetPos (3, 5);
if (Pig <= 2) {
Color (2);
} else if (Pig <= 4) {
Color (16);
} else if (Pig <= 6) {
Color (7);
} else if (Pig <= 9) {
Color (6);
} else if (Pig <= 12) {
Color (3);
} else if (Pig <= 15) {
Color (17);
} else {
Color (11);
}
for (int i = 1; i <= Pig; i++) {
cout << "■";
}
Color (0);
cout << ' ' << Pig;
for (int i = 1; i <= 5; i++) {
cout << " ";
}
if (Pig > 18) {
break;
}
Pig -= aa;
}
scok = Sco;
pigk = Pig;
if (GetAsyncKeyState (VK_LEFT)&0x8000 && Xy > 0) {
Move (-2);
Xy--;
K = 1;
}
if (GetAsyncKeyState (VK_RIGHT)&0x8000 && Xy < 10) {
Move (-2);
Xy++;
K = 1;
}
if (K == 1) {
if (put == 0 && Sle == 0) {
Move (0);
} else {
Move (-1);
}
}
if (kbhit ()) {
char g = _getch ();
if (g == 'x' || g == 'X') {
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0 && blt[i].boom == 0 && blt[i].W != 1 && blt[i].W != 7) {
blt[i].boom = 1;
if (blt[i].W == 2) {
Blt++;
blt[Blt].W = 2;
blt[Blt].vy = blt[i].vy * 1.2;
blt[Blt].vx = blt[i].vx + 1;
blt[Blt].ax = blt[i].ax;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].boom = 1;
Blt++;
blt[Blt].W = 2;
blt[Blt].vy = blt[i].vy * 0.7;
blt[Blt].vx = blt[i].vx - 1;
blt[Blt].ax = blt[i].ax;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].boom = 1;
}
if (blt[i].W == 3) {
blt[i].vy = fmax (blt[i].vy * 1.5, 2.5);
blt[Blt].vx++;
blt[i].ax = 0;
}
if (blt[i].W == 4) {
blt[i].vx = -3;
blt[i].ax = 0.1;
Blt++;
blt[Blt].boom = 1;
blt[Blt].W = 10;
blt[Blt].X = blt[i].X;
blt[Blt].Y = blt[i].Y;
blt[Blt].ax = blt[i].ax;
blt[Blt].vx = 1;
}
if (blt[i].W == 5) {
Bot++;
boo[Bot].X = blt[i].X;
boo[Bot].Y = blt[i].Y;
boo[Bot].S = 1;
boo[Bot].mS = 5;
blt[i].go = 1;
}
if (blt[i].W == 6) {
blt[i].ay = -1;
blt[i].ax = 0.3;
blt[i].vx = min (blt[i].vx / 2, (float)0);
}
break;
}
}
}
}
if (GetAsyncKeyState (' ')&0x8000 && K == 0 && Sle == 0) {
if (put <= 5) {
Move (1);
yX = 18;
yY = Xy + 1;
} else if (put <= 20) {
Move (2);
yX = 18;
yY = Xy;
} else if (put <= 40) {
Move (3);
yX = 19;
yY = Xy;
} else if (put <= 60) {
Move (4);
yX = 20;
yY = Xy;
} else if (put <= 80) {
Move (5);
yX = 20;
yY = Xy + 1;
} else {
Move (6);
yX = 20;
yY = Xy + 2;
}
if (put == 0) {
K2 = 1;
}
if (put == 90) {
K2 = -1;
}
if (K2 == 1) {
put += min (rand () % 7 + 1, 90 - put);
}
if (K2 == -1) {
put-=min(rand()%7+1,put);
}
Cout (1, 17, Xy + 2);
}
if ((!(GetAsyncKeyState (' ')&0x8000) && (put != 0)) || (put != 0 && K == 1)) {
Move (-1);
Creat (1, put);
put = 0;
yX = 18;
yY = 5;
Sle = 1;
What = rand () % 7 + 1;
Creat (-1, -1);
Sco = max (Sco - 5, 0);
}
for (int i = Blt - 10; i <= Blt; i++) {
if (blt[i].go == 0) {
Go (i);
}
}
for (int i = Bot - 10; i <= Bot; i++) {
if (boo[i].go == 0) {
Boom (i);
Cout (2, 0, 0);
}
}
for (int i = Pit - 50; i <= Pit; i++) {
if (pig[i].go == 0) {
Kill (i);
}
}
if (Sle != 0) {
Move (-1);
} else if (put == 0) {
Move (0);
}
if (T % 300 == 0) {
system ("cls");
pigk = scok = -1;
}
if (T % 100 == 0) {
Color (7);
for (int i = 0; i <= 18; i++) {
for (int j = 0; j <= 40; j++) {
if (m[i][j] == 1 && T % 100 == 0) {
SetPos (i, j);
cout << "■";
}
}
}
SetPos (19, 14);
cout << "■";
SetPos (20, 13);
cout <<" █▍";
SetPos (21, 0);
for (int i = 0; i < 39; i++) {
cout << "■";
Color (0);
}
}
if (T % min (50, (2000 - Sco) / 30) == 0) {
Pig++;
Creat (0, -1);
}
Sleep (30);
}
if (Sco < 1500) {
if (MessageBox (NULL, "很遗憾,您输了,您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {
goto St;
} else {
return 0;
}
} else {
if (MessageBox (NULL, "恭喜您赢了!您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {
goto St;
} else {
return 0;
}
}
return 0;
}
9、海岛奇胎
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD);
PROCSETCONSOLEFONT SetConsoleFont;
POINT Windowpos(){POINT pt;GetCursorPos(&pt);HWND h=GetForegroundWindow();ScreenToClient(h,&pt);pt.x=(pt.x+4)/10+0.5;pt.y=pt.y/8+0.5;swap(pt.x,pt.y);return pt;}
int mouse;POINT pt;float kx,ky;int ti(float a) {return ((int)(a*10+5))/10;}
void Print(int a){HMODULE hKernel32 = GetModuleHandle("kernel32");SetConsoleFont = (PROCSETCONSOLEFONT)GetProcAddress(hKernel32,"SetConsoleFont");SetConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE),a);}
void Setpos(float x,float y){COORD pos;pos.X=ti(y*4)/2;pos.Y=ti(x);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
//Setpos中,横5和竖5是一样的长度,在C,N中我们把y*2存入,/2输出 ,所以 支持4.5
struct node {float x,y,fx,fy;int kind,staytime,blood,CD,enemy,turn=6;bool life;} M[100001],E[100001];//Mytower Enemy Bullet
struct bullet {float x,y,vx,vy,h;int kind,staytime,enemy,endx,endy,up;bool life;} B[100001];//,ice,medical,durg,
float Espeed[7]= {-1, 0.14, 0.2, 0.08, 0.3, 0.3, 0.1};//敌人速度
float Bspeed[7]= {-1, 0.6, 0.6, 0.6, 1, 0.1, 0.6};//打塔的子弹速度
float Bfspeed[7]= {-1, 0.4, 0.4, -1, 0.3, 1, 0.4};//打敌的子弹速度
float MR[7]= {-1, 12, 10, 25, 8, 15, 20};
float ER[7]= {-1, 5, 1.8, 8, 7, 1, 10};
int MCDmax[7]= {10000, 10, 7, 60, 2, 90, 50};
int ECDmax[7]= {-1, 30, 10, 40, 25, 1, 40};
int Mblood[7]= {-1,200,150,300,250,400,300};
int Eblood[7]= {-1,50,100,30,100,10,200};
bool Zhan[50][50];
//Pk_Pb : personkill_or_placeboom
int m[51][101],n[51][101],o[51][101],T,CD,CDmax,Day,ml,mr,el,er,bl,br,money,Level=1,endless;
void Color(int a)
{
if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
if(a>=6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
}
void C(int i,int j){Color(0);
Setpos(i,j/2.0);int N=n[i][j];if(N==-1) printf(" ");if(N>=0&&N<=9) printf("%d",N);
if(N==-2) printf("+");if(N==-3) Color(5),printf("+"),n[i][j]=-1,o[i][j]=4;if(N==-4) Color(3),printf("+"),n[i][j]=-1,o[i][j]=4;
//以下字符占2格
if(N==11) Color(1),printf("О");if(N==13) Color(3),printf("◎");if(N==14) Color(4),printf("+");if(N==16) Color(5),printf("◎");
if(N==-11) Color(1),printf("⊙");if(N==-12) Color(2),printf("⊙");if(N==-13) Color(3),printf("⊙");if(N==-14) Color(4+rand()%2),printf("█");if(N==-15) Color(1),printf("●");if(N==-16) Color(5),printf("¤");
if(N==49) Color(0),printf("营");if(N==50) Color(0),printf("墙");if(N==51) Color(1),printf("●");if(N==52) Color(2),printf("■");if(N==53) Color(3),printf("▲");if(N==54) Color(4),printf("▼");if(N==55) Color(6),printf("◆");if(N==56) Color(5),printf("★");
if(N==81) Color(1),printf("○");if(N==82) Color(2),printf("□");if(N==83) Color(3),printf("△");if(N==84) Color(4),printf("▽");if(N==85) Color(6),printf("◇");if(N==86) Color(5),printf("☆");
if(N==1001) printf("╔");//if(N==1002) printf("╦");
if(N==1003) printf("╗");if(N==1004) printf("╠");if(N==1005) printf("╣");if(N==1006) printf("╚");if(N==1007) printf("╩");if(N==1008) printf("╝");
if(N==1011) printf("↖");if(N==1012) printf("↑");if(N==1013) printf("↗");if(N==1014) printf("←");if(N==1015) printf("→");if(N==1016) printf("↙");if(N==1017) printf("↓");if(N==1018) printf("↘");
}
void Map(int a){if(a==1){for(int i=1;i<=50;i++)for(int j=1;j<=100;j++){
if(n[i][j]!=m[i][j]||T%800==0){C(i,j);if(n[i][j]>=50||n[i][j]<=-10) n[i][j+1]=-1,j++;}
if(o[i][j]==1) C(i,j);if(o[i][j]>0) o[i][j]--;
}
for(int i=1;i<=50;i++)for(int j=1;j<=100;j++){m[i][j]=n[i][j];}}
}
void N(float x,float y,int w){int xx=(int)(x+0.5),yy=(int)(y*2.0+0.5);if(xx>49||yy>98||xx<1||yy<1) return;else n[xx][yy]=w;}
int Turn[9][2]={{0,0},{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
void Circle(int x,int y,int kind,int ex)
{int R;
if(kind==1){int k=M[ex].kind;R=MR[k];int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-2);
if(k==3) for(int i=0;i<=360;i+=15) R=10,N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-2);
}
if(kind==-1){int k=M[ex].kind;R=MR[k];int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-1);
if(k==3) for(int i=0;i<=360;i+=15) R=10,N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-1);
}
if(kind==2){R=ex;int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-3);
}
if(kind==-2){R=ex;int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-4);
}
}
void Cout(int a,int kind){
if(kind==1)//炮台
{
float x=M[a].x,y=M[a].y;
N(x,y,M[a].kind+50);
if(a==1) N(x,y,49);
int i=1;if(M[a].blood>=100) i=2;
for(i;i<=8;i++) N(x+Turn[i][0],y+Turn[i][1],1000+i),Zhan[(int)x+Turn[i][0]][(int)y+Turn[i][1]]=1;
int t=M[a].turn;
// N(Turn[t][0],y+Turn[t][1],1010+t);
int b=max(0,M[a].blood),bb=0;while(b>0){bb++;N(x-1,y+1-0.5*bb,b%10);b/=10;}
}
if(kind==2)//人
{
float x=E[a].x,y=E[a].y;
N(x,y,E[a].kind+80);
N(x+1,y,1012);//
Zhan[(int)x][(int)y]=Zhan[(int)x+1][(int)y]=1;
// N(x+1,y,1010+E[a].turn);
int b=max(0,E[a].blood),bb=0;while(b>0){bb++;N(x-1,y+1-0.5*bb,b%10);b/=10;}
}
if(kind==3)//对塔子弹
{
float x=B[a].x,y=B[a].y;
N(x,y,10+B[a].kind);
}
if(kind==4)//对人子弹
{
float x=B[a].x,y=B[a].y;
N(x-B[a].h,y,-10+B[a].kind);
}
}
int Find_enemy(int Who,int good_or_bad){
int ans=-1,r=rand()%2;float ansx=1e9,x;//搜敌人
if(good_or_bad>=1){float X=M[Who].x,Y=M[Who].y;
if(good_or_bad==2) X=E[Who].x,Y=E[Who].y;
for(int i=el;i<=er;i++){if(E[i].life==0) continue;x=sqrt((E[i].x-X)*(E[i].x-X)+(E[i].y-Y)*(E[i].y-Y));
if(good_or_bad==2&&E[i].kind==4) continue;
if(M[Who].kind==3&&x<10) continue;//迫击炮
if(M[Who].kind==6&&ans!=-1&&ansx>x) ansx=x;//火箭炮
if(ansx>x) ansx=x,ans=i;
if(ansx==x) {int r=rand()%2;if(r==1) ansx=x,ans=i;}}}
if(good_or_bad==0){float X=E[Who].x,Y=E[Who].y;for(int i=ml;i<=mr;i++) {if(M[i].life==0) continue;x=sqrt((M[i].x-X)*(M[i].x-X)+(M[i].y-Y)*(M[i].y-Y));if(ansx>x) ansx=x,ans=i;if(ansx==x) {int r=rand()%2;if(r==1) ansx=x,ans=i;}}}
return ans;
}
void Find_boomkill(int Who,float r,bool good_or_bad,int kill){
float x,X=B[Who].x,Y=B[Who].y;int kk=(float)kill/2.5;kill+=rand()%kk-kk/5;
if(good_or_bad==1){for(int i=el;i<=er;i++){if(E[i].life==0) continue;x=sqrt((E[i].x-X)*(E[i].x-X)+(E[i].y-Y)*(E[i].y-Y));if(r>=x) E[i].blood=min(E[i].blood-kill,Eblood[E[i].kind]+Day+50);}
}//搜敌人
else{for(int i=ml;i<=mr;i++){if(M[i].life==0) continue;x=sqrt((M[i].x-X)*(M[i].x-X)+(M[i].y-Y)*(M[i].y-Y));if(r>=x) M[i].blood-=kill;}
}//搜炮台
}
void Die(){
for(int i=ml;i<=mr;i++){
if(M[i].blood<=0) M[i].life=0;
// if(M[i].life==0&&i==ml) ml++;
}
for(int i=el;i<=er;i++){
if(E[i].blood<=0) E[i].life=0;
// if(E[i].life==0&&i==el) el++;
}
for(int i=bl;i<=br;i++){
if(B[i].x+B[i].vx<1||B[i].x+B[i].vx>49||B[i].y+B[i].vy<1||B[i].y+B[i].vy>98) {B[i].life=0;}
if(B[i].staytime>=100) B[i].life=0;
// if(B[i].life==0&&i==bl) bl++;
}
// if(el>er) el=er=0,memset(E,0,sizeof(E));if(bl>br) bl=br=0,memset(B,0,sizeof(B));
}
void Move(int a){
if(a==2)
{
for(int i=ml;i<=mr;i++){if(M[i].life==0) continue;Cout(i,1);}
for(int i=el;i<=er;i++){if(E[i].life==0) continue;Cout(i,2);}
return;
}
for(int i=ml;i<=mr;i++){
if(M[i].life==0) continue;
else{M[i].staytime++;int e=M[i].enemy;if(E[e].life==0) M[i].enemy=-1;
if(M[i].kind==5&&M[i].enemy==-1&&M[i].CD<=70&&T%2==0) M[i].CD++;
if(M[i].kind==0&&M[i].blood<=500&&T%20==0) M[i].blood++;
if(M[i].enemy==-1||M[i].kind==4) M[i].enemy=Find_enemy(i,1);//喷火器
if(M[i].enemy!=-1)
{int k=M[i].enemy;
float X=M[i].x,Y=M[i].y,Ax=E[k].x-X,Ay=E[k].y-Y;if(Ay==0) Ay=1e-6;float Turnn=abs(Ax/Ay*1.0),Dis=sqrt((E[k].x-X)*(E[k].x-X)+(E[k].y-Y)*(E[k].y-Y));
if(Dis>MR[M[i].kind]){M[i].enemy=-1;}
else
{M[i].CD++;
if((M[i].kind!=6&&M[i].CD>=MCDmax[M[i].kind])||(M[i].kind==6&&M[i].CD<=21&&M[i].CD%4==0))//火箭炮
{
if(M[i].kind==6) M[i].enemy=Find_enemy(i,1);
if(Turnn>=sqrt(2)+1){if(Ay>0) M[i].turn=2;else M[i].turn=7;}
else if(Turnn>=1.0/(sqrt(2)+1)*1.0){if(Ax>0&&Ay>0) M[i].turn=1;else if(Ax<0&&Ay>0) M[i].turn=3;else if(Ax<0&&Ay<0) M[i].turn=8;else M[i].turn=6;}
else {if(Ax>0) M[i].turn=5;else M[i].turn=4;}
br++,B[br].x=X,B[br].y=Y;
B[br].kind=-M[i].kind;///
B[br].life=1,B[br].enemy=M[i].enemy,B[br].endx=E[M[i].enemy].x,B[br].endy=E[M[i].enemy].y,B[br].staytime=0;
}
if(M[i].CD>=MCDmax[M[i].kind]) M[i].CD=0;
}
}Cout(i,1);}}
for(int i=el;i<=er;i++){
if(E[i].life==0) continue;
else{E[i].staytime++;E[i].CD++;
int e=E[i].enemy;if(M[e].life==0||(E[i].kind==4&&E[e].life==0)) E[i].enemy=-1;
// if(T%100==1) E[i].enemy=-1;
if(E[i].enemy==-1) {E[i].enemy=Find_enemy(i,0);if(E[i].kind==4) E[i].enemy=Find_enemy(i,2);}
if(E[i].enemy!=-1){int k=E[i].enemy;int Mkx=M[k].x;int Mky=M[k].y;if(E[i].kind==4) Mkx=E[k].x,Mky=E[k].y;
float X=E[i].x,Y=E[i].y;float Dis=sqrt((Mkx-X)*(Mkx-X)+(Mky-Y)*(Mky-Y));
float Ax=Mkx-X,Ay=Mky-Y,S=Espeed[E[i].kind];if(Ay==0) Ay=1e-6;float Turnn=abs(Ax/Ay*1.0);
if(Dis>ER[E[i].kind]){float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;E[i].x+=vx,E[i].y+=vy;}
else{
if(E[i].CD>=ECDmax[E[i].kind]){
// if(Turnn>=sqrt(2)+1){if(Ay>0) E[i].turn=7;else E[i].turn=2;}
// else if(Turnn>=1.0/(sqrt(2)+1)*1.0){if(Ax>0&&Ay>0) E[i].turn=8;else if(Ax<0&&Ay>0) E[i].turn=6;else if(Ax<0&&Ay<0) E[i].turn=1;else E[i].turn=3;}
// else {if(Ax>0) E[i].turn=4;else E[i].turn=5;}
if(E[i].kind==5) E[i].blood=-1;//炮灰 ///
if(E[i].kind==4){
br++,B[br].x=X,B[br].y=Y;
B[br].kind=4;///
B[br].life=1,B[br].enemy=E[i].enemy,B[br].endx=E[E[i].enemy].x,B[br].endy=E[E[i].enemy].y,B[br].staytime=0;
}
else{
br++,B[br].x=X,B[br].y=Y;
B[br].kind=E[i].kind;///
B[br].life=1,B[br].enemy=E[i].enemy,B[br].endx=M[E[i].enemy].x,B[br].endy=M[E[i].enemy].y,B[br].staytime=0;
}
E[i].CD=0;}
}
}Cout(i,2);
}
}
for(int i=bl;i<=br;i++){
if(B[i].life==0) continue;
else if(B[i].kind>0)//对塔子弹 >0
{
B[i].staytime++;
int k=B[i].enemy;
int Mkl=M[k].life,Mkx=M[k].x,Mky=M[k].y;
if(B[i].kind==4) Mkl=B[k].life,Mkx=B[k].x,Mky=B[k].y;
if(k!=-1&&Mkl==1) B[i].endx=Mkx,B[i].endy=Mky;
float kx=B[i].endx,ky=B[i].endy,X=B[i].x,Y=B[i].y;float Ax=kx-X,Ay=ky-Y,S=Bspeed[B[i].kind];float Dis=sqrt(Ax*Ax+Ay*Ay);float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;
B[i].x+=vx,B[i].y+=vy;//别改,对的!
if(Dis<=S){
//打中了,减血
B[i].x=B[i].endx,B[i].y=B[i].endy;
if(B[i].kind==1) Find_boomkill(i,1.5,0,20),Circle(B[i].endx,B[i].endy,-2,1);
if(B[i].kind==2) Find_boomkill(i,1.5,0,10),Circle(B[i].endx,B[i].endy,-2,1);
if(B[i].kind==3) Find_boomkill(i,3,0,20),Circle(B[i].endx,B[i].endy,-2,3);
if(B[i].kind==4) Find_boomkill(i,2,1,-5),Circle(B[i].endx,B[i].endy,-2,2);
if(B[i].kind==5) Find_boomkill(i,3,0,50),Circle(B[i].endx,B[i].endy,-2,3);//炮灰
if(B[i].kind==6) Find_boomkill(i,2,0,20),Circle(B[i].endx,B[i].endy,-2,2);
B[i].life=0;continue;
}
Cout(i,3);
}
else//对人子弹 <0
{
B[i].staytime++;
int k=B[i].enemy;if(k!=-1&&E[k].life==1) B[i].endx=E[k].x,B[i].endy=E[k].y;
float kx=B[i].endx,ky=B[i].endy,X=B[i].x,Y=B[i].y;float Ax=kx-X,Ay=ky-Y,S=Bfspeed[-B[i].kind];float Dis=sqrt(Ax*Ax+Ay*Ay);float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;
if(B[i].kind==-3){B[i].x+=1.0/(49.0-B[i].staytime)*Ax;B[i].y+=1.0/(49.0-B[i].staytime)*Ay;
if(T%2==0){
if(B[i].up==1){if(B[i].h<3) B[i].h++;else if(B[i].h<6) B[i].h+=0.5;else B[i].up++;}else if(B[i].up<=6) B[i].up++;else{if(B[i].h>3) B[i].h-=0.5;else B[i].h--;}}
}
else B[i].x+=vx,B[i].y+=vy;//抛物线
if(B[i].kind==-3&&B[i].staytime>=48) {B[i].x=B[i].endx,B[i].y=B[i].endy,Find_boomkill(i,5,1,30),Circle(B[i].endx,B[i].endy,2,4);B[i].life=0;continue;}
else if(B[i].kind!=-3&&Dis<=S)//打中了,减血
{
if(B[br].kind==-2) B[i].endx+=rand()%7-3,B[i].endy+=rand()%7-3;//重机枪
B[i].x=B[i].endx,B[i].y=B[i].endy;
if(B[i].kind==-1) Find_boomkill(i,2,1,20),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-2) Find_boomkill(i,2,1,20),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-4) Find_boomkill(i,2,1,5),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-5) Find_boomkill(i,3,1,120),Circle(B[i].endx,B[i].endy,2,3);
if(B[i].kind==-6) Find_boomkill(i,3,1,40),Circle(B[i].endx,B[i].endy,2,3);
B[i].life=0;continue;
}
Cout(i,4);
}
}
Die();//开始处理 life=0,前面不要有 life=0
}
void StartWar(int D)
{
for(int i=-1;i<=(int)T/1000;i++){
int XY=rand()%4,W=rand()%49+1,x,y,k,R=rand()%100;
if(Level==2) XY=3;if(Level==3) XY=3*(rand()%2);
if(XY==0) x=1,y=W;if(XY==1) x=49,y=W;if(XY==2) x=W,y=1;if(XY==3) x=W,y=49;
k=rand()%6+1;///
er++,E[er].x=x,E[er].y=y,E[er].kind=k,E[er].life=1,E[er].blood=Eblood[k]+Day;
}
}
void Start()
{Color(0);
Setpos(51,0),printf("┏━━┓┏━━┓┏━━┓┏━━┓┏━━┓┏━━┓");
Setpos(52,0),printf("┃$100┃┃$120┃┃$150┃┃$180┃┃$200┃┃$250┃");
Setpos(53,0),printf("┃ ● ┃┃ ■ ┃┃ ▲ ┃┃ ▼ ┃┃ ◆ ┃┃ ★ ┃");Setpos(53,30),printf("Money: %d ",money);
Setpos(54,0),printf("┗━━┛┗━━┛┗━━┛┗━━┛┗━━┛┗━━┛");Setpos(53,40),printf("Day: %d ",Day);
}
void Click()
{
int What;
pt=Windowpos();
if(pt.x<50||pt.y>25) return;
else What=pt.y/4+1;
if(What==1) if(money>=100) money-=100;else return;
if(What==2) if(money>=120) money-=120;else return;
if(What==3) if(money>=150) money-=150;else return;
if(What==4) if(money>=180) money-=180;else return;
if(What==5) if(money>=200) money-=200;else return;
if(What==6) if(money>=250) money-=250;else return;
Color(0),Setpos(53,30),printf("Money: %d ",money);
mr++;M[mr].x=25;M[mr].kind=What;M[mr].blood=Mblood[What];M[mr].life=1;M[mr].CD=MCDmax[What]-1;
while(mouse)
{
mouse=GetAsyncKeyState(VK_LBUTTON)&0x8000;
pt=Windowpos();
M[mr].x=min(48,max(2,(int)pt.x)),M[mr].y=min(48,max(2,(int)pt.y));
Circle(M[mr].x,M[mr].y,1,mr);
Move(2);Map(1);Sleep(30);
for(int i=0;i<=8;i++) N(M[mr].x+Turn[i][0],M[mr].y+Turn[i][1],-1),N(M[mr].x+Turn[i][0],M[mr].y+Turn[i][1]+0.5,-1);
Circle(M[mr].x,M[mr].y,-1,mr);
}
system("cls");memset(n,-1,sizeof(n));memset(m,-1,sizeof(m));Start();
}
void Menu()
{
system("mode con cols=50 lines=28");Print(1);Color(0);
Setpos(5,7);cout<<"欢迎来到 海岛奇胎 !";
Setpos(7,12);cout<<"作者:胎神大大";
Setpos(8,12);cout<<"原名:城市守卫战 3.0";
Setpos(10,2);cout<<"规则:见城市守卫战,略有调整,可以自己摸索!";
Setpos(12,5);cout<<"请选择地图:";Setpos(13,7);cout<<"1.围城 ";Setpos(14,7);cout<<"2.长城 ";Setpos(15,7);cout<<"3.王者 ";Setpos(16,7);cout<<"4.放射 ";Setpos(17,7);cout<<"5.真空(魔鬼难度)";Setpos(19,7);cout<<"输入负数则开启无尽模式";Setpos(20,9);cout<<"例:-1:无尽围城";
endless=0;A:char a=_getch();if(a=='-') {endless=1;goto A;}else if(a<'1'||a>'5') goto A;else Level=a-'0';
system("mode con cols=100 lines=56");Print(2);
}
int main(){
CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);srand((unsigned)time(NULL));
St:Menu();Start();
memset(n,-1,sizeof(n));memset(m,-1,sizeof(m));memset(M,0,sizeof(M));memset(E,0,sizeof(E));memset(B,0,sizeof(B));
T=ml=mr=el=er=bl=br=0;CDmax=160;Day=1;
money=1000;if(Level==5) money=1500;
mr++,M[mr].x=25,M[mr].y=25,M[mr].kind=0,M[mr].life=1,M[mr].blood=2000;
if(Level==2) M[mr].y=2;
if(Level==3) M[mr].x=48,M[mr].y=2;
if(Level==1) for(int i=0;i<=360;i+=30) mr++,M[mr].x=25+10*sin(3.1416*i/180),M[mr].y=25+10*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==2) for(int i=5;i<50;i+=6) mr++,M[mr].x=i,M[mr].y=20,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=i,M[mr].y=10,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==3) for(int i=-90;i<=0;i+=45) mr++,M[mr].x=48+8*sin(3.1416*i/180),M[mr].y=2+8*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=48+16*sin(3.1416*i/180),M[mr].y=2+16*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=48+24*sin(3.1416*i/180),M[mr].y=2+24*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==4) for(int i=30;i<=390;i+=60) mr++,M[mr].x=25+8*sin(3.1416*i/180),M[mr].y=25+8*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=25+15*sin(3.1416*i/180),M[mr].y=25+15*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
while(M[1].life==1)
{
T++;
memset(n,-1,sizeof(n));//这里默认全输空格
//鼠标,键盘,暂停操作
mouse=GetAsyncKeyState(VK_LBUTTON)&0x8000;
pt=Windowpos();N(pt.x,pt.y,-2);
if(mouse) Click();
if(Day>=100&&endless==0) break;
CD--;if(CD<=0){CD=CDmax;StartWar(Day);Day++;Setpos(53,40),printf("Day: %d ",Day);}
if(T%50==0) money=min(money+10,1000),Setpos(53,30),printf("Money: %d ",money);
Move(1);Map(1);Sleep(30);
}
if(Day>=100) {system("color 6E"),Sleep(1000);for(int i=1;i<=1000;i++) cout<<"YOU WIN !! ";system("pause");system("color 0F");}
else {system("color 7F"),Sleep(1000);for(int i=1;i<=1000;i++) cout<<"GAME OVER... ";system("pause");system("color 0F");}
system("cls");
goto St;
return 0;
}
10、井字棋
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
int n,m;
char a[9]={32,32,32,32,32,32,32,32,32};
for(int i=1;i<=9;i++)
{
cout<<a[0]<<"|"<<a[1]<<"|"<<a[2]<<endl;
cout<<"-+-+-"<<endl;
cout<<a[3]<<"|"<<a[4]<<"|"<<a[5]<<endl;
cout<<"-+-+-"<<endl;
cout<<a[6]<<"|"<<a[7]<<"|"<<a[8]<<endl;
n=0;
while((n<1||n>9)&&a[n-1]!='x'&&a[n-1]!='o')
{
cin>>n;
}
for(int j=1;j<=10000;j++)
{
cout<<endl;
}
a[n-1]='x';
if((a[0]=='x'&&a[1]=='x'&&a[2]=='x')||(a[3]=='x'&&a[4]=='x'&&a[5]=='x')||(a[6]=='x'&&a[7]=='x'&&a[8]=='x')||(a[0]=='x'&&a[3]=='x'&&a[6]=='x')||(a[1]=='x'&&a[4]=='x'&&a[7]=='x')||(a[2]=='x'&&a[5]=='x'&&a[8]=='x'))
{
cout<<"p1 win";
break;
}
cout<<a[0]<<"|"<<a[1]<<"|"<<a[2]<<endl;
cout<<"-+-+-"<<endl;
cout<<a[3]<<"|"<<a[4]<<"|"<<a[5]<<endl;
cout<<"-+-+-"<<endl;
cout<<a[6]<<"|"<<a[7]<<"|"<<a[8]<<endl;
m=0;
Sleep(2000);
while((m<1||m>9)&&a[m-1]!='o'&&a[m-1]!='x')
{
m=rand()%9+1;
}
cout<<m;
Sleep(1000);
for(int j=1;j<=10000;j++)
{
cout<<endl;
}
a[m-1]='o';
if((a[0]=='o'&&a[1]=='o'&&a[2]=='o')||(a[3]=='o'&&a[4]=='o'&&a[5]=='o')||(a[6]=='o'&&a[7]=='o'&&a[8]=='o')||(a[0]=='o'&&a[3]=='o'&&a[6]=='o')||(a[1]=='o'&&a[4]=='o'&&a[7]=='o')||(a[2]=='o'&&a[5]=='o'&&a[8]=='o'))
{
cout<<"p2 win";
break;
}
}
return 0;
}
11、狼人杀
#include<bits/stdc++.h>
using namespace std;
int life[7]={1,1,1,1,1,1};
int potions[5]={-1,1};
int vote[7]={0};
string name[7]={"预言家","女巫","平民","平民","狼人","狼人"};
int seer(int x,int y,int n,int p1,int p2,int l1,int l2)
{
int rescued;
int die;
int die_potions;
bool gameover=false;
while(gameover==false)
{
cout<<endl<<"下一天:----------------------------"<<endl;
for(int i=1;i<=4;i++)
{
if(i==1&&(life[l1]>=0 or life[l2]>=0))
{
cout<<"狼人:"<<endl;
srand((unsigned)time(NULL));
die=rand()%6;
while(name[die]=="狼人"||life[die]==-1) die=rand()%6;
life[die]--;
cout<<"狼人杀了"<<name[die]<<endl;
}
if(i==2&&life[x]>=0)
{
cout<<"预言家:"<<endl;
cout<<"你是预言家,请输入0~5的编号(代表相应的人)(除了"<<x<<"号)来预言"<<endl;
int res;
cin>>res;
if(name[res]=="平民"||name[res]=="女巫"||name[res]=="预言家") cout<<"好人"<<endl;
if(name[res]=="狼人") cout<<"坏人"<<endl;
}
if(i==3&&life[n]>=0)
{
cout<<"女巫:"<<endl;
int dor;
srand((unsigned)time(NULL));
dor=rand()%3;
if(dor==0)
{
die_potions=rand()%6;
while(name[die_potions]=="女巫"||life[die_potions]<=0) die_potions=rand()%6;
life[die_potions]--;
potions[dor]++;
cout<<"女巫杀了"<<name[die_potions]<<endl;
}
if(dor==1)
{
int help;
for(int i=0;i<6;i++) if(life[i]==0) life[i]++,help=i;
potions[dor]--;
cout<<"女巫救了"<<name[help]<<endl;
}
if(dor==2)
{
cout<<"没用药"<<endl;
}
}
if(i==4)
{
int sum_die=0;
cout<<"今晚";
for(int j=0;j<6;j++)
{
if(life[j]==0)
{
sum_die++;
life[j]--;
cout<<j<<"号"<<name[j]<<"死了";
}
}
if(sum_die==0) cout<<"是平安夜";
int fl=0,fp=0;
for(int j=0;j<6;j++)
{
if(life[j]==1)
{
if(name[j]=="狼人") fl++;
else fp++;
}
}
if(fl==0)
{
cout<<endl<<"平民赢了"<<endl;
gameover=true;
continue;
}
if(fp==0)
{
cout<<endl<<"狼人赢了"<<endl;
gameover=true;
continue;
}
cout<<endl<<"投票"<<endl;
int a[7]={0,0,0,0,0,0};
for(int j=0;j<6;j++)
{
if(j==x&&life[x]==1)
{
cout<<"请投0~5号你认为是狼人的";
int ps;
cin>>ps;
a[ps]++;
}
else if(life[j]==1)
{
srand((unsigned)time(NULL));
int cs;
cs=rand()%6;
while(life[cs]!=1||cs==j) cs=rand()%6;
a[cs]++;
}
}
cout<<"投票结果:"<<endl;
cout<<"0 1 2 3 4 5"<<endl;
for(int j=0;j<6;j++) cout<<a[j]<<" ";
cout<<endl;
int max=-1,mp;
for(int j=0;j<6;j++) if(a[j]>=max) max=a[j],mp=j;
cout<<mp<<"号"<<name[mp]<<"出局"<<endl<<endl;
life[mp]=-1;
int good=0,bad=0;
for(int j=0;j<6;j++)
{
if(life[j]==1&&(name[j]=="平民"||name[j]=="女巫"||name[j]=="预言家")) good++;
if(life[j]==1&&name[j]=="狼人") bad++;
}
if(bad==0)
{
cout<<"平民赢了"<<endl;
gameover=true;
}
if(good==0)
{
cout<<"狼人赢了"<<endl;
gameover=true;
}
}
}
system("pause");
}
return 0;
}
int Lycan(int x,int y,int n,int p1,int p2,int l1,int l2)
{
int rescued;
int die;
int die_potions;
bool gameover=false;
while(gameover==false)
{
cout<<endl<<"下一天:----------------------------"<<endl;
for(int i=1;i<=4;i++)
{
if(i==1&&life[x]>=0)
{
cout<<"狼人:"<<endl;
cout<<"你是狼人,请输入0~5的编号(代表相应的人)(除了"<<x<<"和"<<l1+l2-x<<"号)来杀死"<<endl;
cin>>die;
life[die]--;
cout<<"狼人杀了"<<name[die]<<endl;
}
if(i==1&&life[x]==-1&&life[l1+l2-x]>=0)
{
cout<<"狼人:"<<endl;
srand((unsigned)time(NULL));
die=rand()%6;
while(name[die]=="狼人"||life[die]==-1) die=rand()%6;
life[die]--;
cout<<"狼人杀了"<<name[die]<<endl;
}
if(i==2&&life[y]>=0)
{
cout<<"预言家:"<<endl;
cout<<"预言完毕"<<endl;
}
if(i==3&&life[n]>=0)
{
cout<<"女巫:"<<endl;
int dor;
srand((unsigned)time(NULL));
dor=rand()%3;
if(dor==0)
{
die_potions=rand()%6;
while(name[die_potions]=="女巫"||life[die_potions]<=0) die_potions=rand()%6;
life[die_potions]--;
potions[dor]++;
cout<<"女巫杀了"<<name[die_potions]<<endl;
}
if(dor==1)
{
int help;
for(int i=0;i<6;i++) if(life[i]==0) life[i]++,help=i;
potions[dor]--;
cout<<"女巫救了"<<name[help]<<endl;
}
if(dor==2)
{
cout<<"没用药"<<endl;
}
}
if(i==4)
{
int sum_die=0;
cout<<"今晚";
for(int j=0;j<6;j++)
{
if(life[j]==0)
{
sum_die++;
life[j]--;
cout<<j<<"号"<<name[j]<<"死了";
}
}
if(sum_die==0) cout<<"是平安夜";
int fl=0,fp=0;
for(int j=0;j<6;j++)
{
if(life[j]==1)
{
if(name[j]=="狼人") fl++;
else fp++;
}
}
if(fl==0)
{
cout<<endl<<"平民赢了"<<endl;
gameover=true;
continue;
}
if(fp==0)
{
cout<<endl<<"狼人赢了"<<endl;
gameover=true;
continue;
}
cout<<endl<<"投票"<<endl;
int a[7]={0,0,0,0,0,0};
for(int j=0;j<6;j++)
{
if(j==x&&life[x]==1)
{
cout<<"请投0~5号你认为是狼人的";
int ps;
cin>>ps;
a[ps]++;
}
else if(life[j]==1)
{
srand((unsigned)time(NULL));
int cs;
cs=rand()%6;
while(life[cs]!=1||cs==j) cs=rand()%6;
a[cs]++;
}
}
cout<<"投票结果:"<<endl;
cout<<"0 1 2 3 4 5"<<endl;
for(int j=0;j<6;j++) cout<<a[j]<<" ";
cout<<endl;
int max=-1,mp;
for(int j=0;j<6;j++) if(a[j]>=max) max=a[j],mp=j;
cout<<mp<<"号"<<name[mp]<<"出局"<<endl<<endl;
life[mp]=-1;
int good=0,bad=0;
for(int j=0;j<6;j++)
{
if(life[j]==1&&(name[j]=="平民"||name[j]=="女巫"||name[j]=="预言家")) good++;
if(life[j]==1&&name[j]=="狼人") bad++;
}
if(bad==0)
{
cout<<"平民赢了"<<endl;
gameover=true;
}
if(good==0)
{
cout<<"狼人赢了"<<endl;
gameover=true;
}
}
}
system("pause");
}
return 0;
}
int witch(int x,int y,int n,int p1,int p2,int l1,int l2)
{
int rescued;
int die;
int die_potions;
bool gameover=false;
while(gameover==false)
{
cout<<endl<<"下一天:----------------------------"<<endl;
for(int i=1;i<=4;i++)
{
if(i==1&&(life[l1]>=0 or life[l2]>=0))
{
cout<<"狼人:"<<endl;
srand((unsigned)time(NULL));
die=rand()%6;
while(name[die]=="狼人"||life[die]==-1) die=rand()%6;
life[die]--;
cout<<"狼人杀了"<<name[die]<<endl;
}
if(i==2&&life[y]>=0)
{
cout<<"预言家:"<<endl;
cout<<"预言完毕"<<endl;
}
if(i==3&&life[n]>=0)
{
cout<<"女巫:"<<endl;
cout<<"你是女巫,请输入d、r、n。d代表要杀、r代表要救,n代表不用药"<<endl;
char dor;
cin>>dor;
if(dor=='d')
{
cout<<"请输入0~5号你要杀的人(除了"<<n<<"号)"<<endl;
cin>>die_potions;
life[die_potions]--;
potions[0]++;
cout<<"女巫杀了"<<name[die_potions]<<endl;
}
if(dor=='r')
{
int help;
for(int i=0;i<6;i++) if(life[i]==0) life[i]++,help=i;
potions[1]--;
cout<<"女巫救了"<<name[help]<<endl;
}
if(dor=='n')
{
cout<<"没用药"<<endl;
}
}
if(i==4)
{
int sum_die=0;
cout<<"今晚";
for(int j=0;j<6;j++)
{
if(life[j]==0)
{
sum_die++;
life[j]--;
cout<<j<<"号"<<name[j]<<"死了";
}
}
if(sum_die==0) cout<<"是平安夜";
int fl=0,fp=0;
for(int j=0;j<6;j++)
{
if(life[j]==1)
{
if(name[j]=="狼人") fl++;
else fp++;
}
}
if(fl==0)
{
cout<<endl<<"平民赢了"<<endl;
gameover=true;
continue;
}
if(fp==0)
{
cout<<endl<<"狼人赢了"<<endl;
gameover=true;
continue;
}
cout<<endl<<"投票"<<endl;
int a[7]={0,0,0,0,0,0};
for(int j=0;j<6;j++)
{
if(j==x&&life[x]==1)
{
cout<<"请投0~5号你认为是狼人的";
int ps;
cin>>ps;
a[ps]++;
}
else if(life[j]==1)
{
srand((unsigned)time(NULL));
int cs;
cs=rand()%6;
while(life[cs]!=1||cs==j) cs=rand()%6;
a[cs]++;
}
}
cout<<"投票结果:"<<endl;
cout<<"0 1 2 3 4 5"<<endl;
for(int j=0;j<6;j++) cout<<a[j]<<" ";
cout<<endl;
int max=-1,mp;
for(int j=0;j<6;j++) if(a[j]>=max) max=a[j],mp=j;
cout<<mp<<"号"<<name[mp]<<"出局"<<endl<<endl;
life[mp]=-1;
int good=0,bad=0;
for(int j=0;j<6;j++)
{
if(life[j]==1&&(name[j]=="平民"||name[j]=="女巫"||name[j]=="预言家")) good++;
if(life[j]==1&&name[j]=="狼人") bad++;
}
if(bad==0)
{
cout<<"平民赢了"<<endl;
gameover=true;
}
if(good==0)
{
cout<<"狼人赢了"<<endl;
gameover=true;
}
}
}
system("pause");
}
return 0;
}
int commoner(int x,int y,int n,int p1,int p2,int l1,int l2)
{
int rescued;
int die;
int die_potions;
bool gameover=false;
while(gameover==false)
{
cout<<endl<<"下一天:----------------------------"<<endl;
for(int i=1;i<=4;i++)
{
if(i==1&&(life[l1]>=0 or life[l2]>=0))
{
cout<<"狼人:"<<endl;
srand((unsigned)time(NULL));
die=rand()%6;
while(name[die]=="狼人"||life[die]==-1) die=rand()%6;
life[die]--;
cout<<"狼人杀了"<<name[die]<<endl;
}
if(i==2&&life[y]>=0)
{
cout<<"预言家:"<<endl;
cout<<"预言完毕"<<endl;
}
if(i==3&&life[n]>=0)
{
cout<<"女巫:"<<endl;
int dor;
srand((unsigned)time(NULL));
dor=rand()%3;
if(dor==0)
{
die_potions=rand()%6;
while(name[die_potions]=="女巫"||life[die_potions]<=0) die_potions=rand()%6;
life[die_potions]--;
potions[dor]++;
cout<<"女巫杀了"<<name[die_potions]<<endl;
}
if(dor==1)
{
int help;
for(int i=0;i<6;i++) if(life[i]==0) life[i]++,help=i;
potions[dor]--;
cout<<"女巫救了"<<name[help]<<endl;
}
if(dor==2)
{
cout<<"没用药"<<endl;
}
}
if(i==4)
{
int sum_die=0;
cout<<"今晚";
for(int j=0;j<6;j++)
{
if(life[j]==0)
{
sum_die++;
life[j]--;
cout<<j<<"号"<<name[j]<<"死了";
}
}
if(sum_die==0) cout<<"是平安夜";
int fl=0,fp=0;
for(int j=0;j<6;j++)
{
if(life[j]==1)
{
if(name[j]=="狼人") fl++;
else fp++;
}
}
if(fl==0)
{
cout<<endl<<"平民赢了"<<endl;
gameover=true;
continue;
}
if(fp==0)
{
cout<<endl<<"狼人赢了"<<endl;
gameover=true;
continue;
}
cout<<endl<<"投票"<<endl;
int a[7]={0,0,0,0,0,0};
for(int j=0;j<6;j++)
{
if(j==x&&life[x]==1)
{
cout<<"请投0~5号你认为是狼人的";
int ps;
cin>>ps;
a[ps]++;
}
else if(life[j]==1)
{
srand((unsigned)time(NULL));
int cs;
cs=rand()%6;
while(life[cs]!=1||cs==j) cs=rand()%6;
a[cs]++;
}
}
cout<<"投票结果:"<<endl;
cout<<"0 1 2 3 4 5"<<endl;
for(int j=0;j<6;j++) cout<<a[j]<<" ";
cout<<endl;
int max=-1,mp;
for(int j=0;j<6;j++) if(a[j]>=max) max=a[j],mp=j;
cout<<mp<<"号"<<name[mp]<<"出局"<<endl<<endl;
life[mp]=-1;
int good=0,bad=0;
for(int j=0;j<6;j++)
{
if(life[j]==1&&(name[j]=="平民"||name[j]=="女巫"||name[j]=="预言家")) good++;
if(life[j]==1&&name[j]=="狼人") bad++;
}
if(bad==0)
{
cout<<"平民赢了"<<endl;
gameover=true;
}
if(good==0)
{
cout<<"狼人赢了"<<endl;
gameover=true;
}
}
}
system("pause");
}
return 0;
}
int main()
{
begin:
cout<<"狼人杀"<<endl;
cout<<"1个预言家 1个女巫 2个平民 2个狼人"<<endl;
srand((unsigned)time(NULL));
for(int i=1;i<=1000;i++)
{
int x=rand()%6;
int y=rand()%6;
swap(name[x],name[y]);
}
int player=rand()%6;
cout<<"你是"<<name[player]<<endl<<"您的编号是"<<player<<endl<<endl;
int l1,l2,l=1;
int y;
int n;
int p1,p2,p=1;
for(int i=0;i<6;i++)
{
if(name[i]=="狼人"&&l==1)
{
l1=i;
l++;
continue;
}
if(name[i]=="狼人"&&l==2) l2=i,l++;
if(name[i]=="预言家") y=i;
if(name[i]=="女巫") n=i;
if(name[i]=="平民"&&p==1)
{
p1=i;
p++;
continue;
}
if(name[i]=="平民"&&p==2) p2=i,p++;
}
if(player==y) seer(player,y,n,p1,p2,l1,l2);
if(player==l1 or player==l2) Lycan(player,y,n,p1,p2,l1,l2);
if(player==n) witch(player,y,n,p1,p2,l1,l2);
if(player==p1 or player==p2) commoner(player,y,n,p1,p2,l1,l2);
else return 0;
}
12、猫国建设者
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <conio.h>
#include <bitset>
using namespace std;
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define KEY_DOWM(vk_c) (GetAsyncKeyState(vk_c)&0x8000?1:0)
void color(int a){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void HideCursor(){
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void block(int x,int y){
HANDLE hCon;
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD setps;
setps.X = x;
setps.Y = y;
SetConsoleCursorPosition(hCon,setps);
}
bitset<128>pre;
bitset<128>down;
void pan(char c){
bool hahbhchdhehfhg;
if(c == 'w'){
if(!KEY_DOWN(VK_UP))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == 's'){
if(!KEY_DOWN(VK_DOWN))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == 'a'){
if(!KEY_DOWN(VK_LEFT))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == 'd'){
if(!KEY_DOWN(VK_RIGHT))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == '1'){
if(!KEY_DOWN(VK_NUMPAD1) && !KEY_DOWN('1'))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == '2'){
if(!KEY_DOWN(VK_NUMPAD2) && !KEY_DOWN('2'))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else if(c == '3'){
if(!KEY_DOWN(VK_NUMPAD3) && !KEY_DOWN('3'))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}else{
if(!KEY_DOWN(c))hahbhchdhehfhg=0;
else hahbhchdhehfhg=1;
}
if(hahbhchdhehfhg)down[c]=1;
else down[c]=0;
}
bool check(char c){
if(down[c] != pre[c]){
pre[c] = down[c];
if(down[c]){
return true;
}
}
return false;
}
int heng[31] = {0, 1, 4};
int shu[31][101] = {{0},
{0, 1, 2, 3, 4},
{0, 1},
{0, 1}
};
string hengs[31] = {"0", "营火", "小村庄", "科学", "成就", "工坊", "贸易", "独角兽"};
string shus[31][101] = {{"0"},
{"0", "采集猫薄荷", "猫薄荷田", "锻造木头", "小屋", "图书馆", "粮仓", "矿井", "工坊"},
{"0", "伐木工", "农民", "学者", "猎人", "矿工"},
{"0", "日期", "农业", "箭业", "采矿", "畜牧业", "金属加工", "行政部门", "数学", "建筑业"}
};
int shus1[101] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int shus2[101] = {0, 1, 2, 3, 4, 5};
bool z1[1010];
int hengl = 2, shul[31] = {0, 4, 0, 1};
int x = 1;
int y = 1;
int zz11 = 1;
double zz12[101][5] = {{0}, {0, 0}, {0, 10}, {0, 100}, {0, 5}, {0, 25}, {0, 70}, {0, 100}, {0, 100, 400}};
int zz13[101] = {0, 0, 1, 1, 2, 2, 2, 2, 302};
string zz14[31] = {"0", "猫薄荷", "木头", "矿物"};
int zz15[101] = {0};
int zz16[101][5] = {{0}, {0, 0}, {0, 10}, {0, 100}, {0, 5}, {0, 25}, {0, 70}, {0, 100}, {0, 100, 400}};
double zz17[101] = {0, 0, 1.12, 0, 2.5, 1.15, 1.25, 1.15, 1.15};
bool zz31[101];
int zz32[101] = {0, 30, 100, 300, 500, 500, 900};
int zz33 = 1;
int zz21[10];
int zz22 = 0;
int zz23 = 1;
double bohe1 = 0;
double mutou1 = 0;
double keji1 = 0;
double catli1 = 0;
double kuangwu1 = 0;
int cat1 = 0;
int cat2 = 0;
int bohe2 = 5000;
int mutou2 = 200;
int keji2 = 500;
int catli2 = 150;
int kuangwu2 = 250;
bool maopi1 = false;
double maopi = 0.0;
bool xiangya1 = false;
double xiangya = 0.0;
bool xinqing1 = false;
int xinqing = 100;
int tim0 = 0, tim1 = 1, tim2 = 1, tim3 = 0;
int timm1 = 0, timm2 = 0;
string tim[5] = {"0", "春季", "夏季", "秋季", "冬季"};
bool h1 = true;
bool pai1(int x1, int y1){
return shus1[x1] < shus1[y1];
}
bool pai2(int x1, int y1){
return shus2[x1] < shus2[y1];
}
void output(double x){
if(x >= 1000000){
x /= 1000000;
if((int)x != x){
if((int)(x * 10) / 10.0 != x){
printf("%.2fM", x);
}else{
printf("%.1fM", x);
}
}else{
cout << x << "M";
}
}else if(x >= 10000){
x /= 1000;
if((int)x != x){
if((int)(x * 10) / 10.0 != x){
printf("%.2fK", x);
}else{
printf("%.1fK", x);
}
}else{
cout << x << "K";
}
}else{
if((int)x != x){
if((int)(x * 10) / 10.0 != x){
printf("%.2f", x);
}else{
printf("%.1f", x);
}
}else{
cout << x;
}
}
}
void output00(){
int m1 = 3;
if(xinqing1){
color(13);
block(1, m1);
cout << " ";
block(1, m1);
cout << "幸福度:" << xinqing << "%";
m1++;
}
color(15);
block(1, m1);
cout << " ";
block(1, m1);
cout << "猫薄荷:" ;
if(bohe1 > bohe2){
bohe1 = bohe2;
}
if(bohe1 >= bohe2 * 0.9){
color(14);
}
output(bohe1);
color(7);
cout << "/";
output(bohe2);
m1++;
color(15);
block(1, m1);
cout << " ";
block(1, m1);
cout << "木头:";
if(mutou1 > mutou2){
mutou1 = mutou2;
}
if(mutou1 >= mutou2 * 0.9){
color(14);
}
output(mutou1);
color(7);
cout << "/";
output(mutou2);
m1++;
if(zz31[4]){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
cout << "矿物:";
if(kuangwu1 > kuangwu2){
kuangwu1 = kuangwu2;
}
if(kuangwu1 >= kuangwu2 * 0.9){
color(14);
}
output(kuangwu1);
color(7);
cout << "/";
output(kuangwu2);
m1++;
}
if(zz31[3]){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
color(12);
cout << "猫力:";
if(catli1 > catli2){
catli1 = catli2;
}
if(catli1 >= catli2 * 0.9){
color(14);
}else{
color(15);
}
output(catli1);
color(7);
cout << "/";
output(catli2);
m1++;
}
if(zz15[5] > 0){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
color(11);
cout << "科技点:";
if(keji1 > keji2){
keji1 = keji2;
}
if(keji1 >= keji2 * 0.9){
color(14);
}else{
color(15);
}
output(keji1);
color(7);
cout << "/";
output(keji2);
m1++;
}
if(cat2 > 0){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
cout << "小猫:";
if(cat1 == cat2){
color(14);
}
cout << cat1;
color(7);
cout << "/" << cat2;
m1++;
}
if(maopi1){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
color(13);
cout << "毛皮:";
color(15);
output(maopi);
m1++;
}
if(xiangya1){
color(15);
block(1, m1);
cout << " ";
block(1, m1);
color(13);
cout << "象牙:";
color(15);
output(xiangya);
m1++;
}
}
void output01(){
color(15);
for(int i = 4; i <= 23; i++){
block(20, i);
cout << " ";
}
}
void output02(){
color(15);
if(tim3 == 18){
tim3 = 0;
tim2++;
}
if(tim2 == 100){
tim2 = 0;
tim1++;
}
if(tim1 == 5){
tim1 = 1;
tim0++;
}
if(zz31[1]){
block(1, 1);
cout << " ";
block(1, 1);
cout << "第" << tim0 << "年," << tim[tim1] << "第" << tim2 << "天";
}else{
block(1, 1);
cout << tim[tim1];
}
}
void output0(){
for(int i = 1; i <= hengl; i++){
if(i == x){
color(0 + 15 * 16);
}else{
color(15);
}
block(i * 8 + 20, 1);
cout << " |";
block(i * 8 + 20, 1);
cout << hengs[heng[i]];
block(i * 8 + 20, 2);
cout << "-------|";
}
}
void output13(){
block(43, zz11);
color(15);
cout << " ";
block(43, zz11 + 1);
cout << " ";
block(43, zz11 + 2);
cout << " ";
}
void output12(int x1){
color(15);
if(shu[1][y] == 1){
block(43, x1);
cout << "1.采集";
}else if(shu[1][y] == 3){
block(43, x1);
cout << "1.锻造100猫薄荷";
}else{
block(43, x1);
cout << "1.建造";
int i = 1;
while(zz12[shu[1][y]][i] != 0){
block(49, x1 + i - 1);
output(zz12[shu[1][y]][i]);
cout << zz14[zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2)))];
i++;
}
}
zz11 = x1;
}
void output11(int y1){
for(int i = 1; i <= 5; i++){
if(i > shul[1]){
break;
}
if(y1 + i == y){
output12(i * 3 + 1);
color(0 + 15 * 16);
}else{
color(15);
}
block(25, i * 3 + 1);
cout << "╭——————╮";
block(25, i * 3 + 2);
cout << "| |";
block(27, i * 3 + 2);
cout << shus[1][shu[1][y1 + i]] << "(" << zz15[shu[1][y1 + i]] << ")";
block(25, i * 3 + 3);
cout << "╰——————╯";
}
}
void output1(){
if(x != 1){
cout << "???";
Sleep(500);
return;
}
output13();
if(shul[1] <= 5){
output11(0);
}else if(y < 3) {
output11(0);
}else if(y > shul[1] - 2){
output11(shul[1] - 5);
}else{
output11(y - 3);
}
}
void output31(int x3, int y3){
if(x3 == y){
block(43, x3 * 3 + 1);
if(zz31[shu[3][y3]]){
cout << "已研发";
}else{
cout << "1.研发";
output(zz32[shu[3][y3]]);
cout << "科技点";
}
color(0 + 15 * 16);
zz33 = x3 * 3 + 1;
}else{
color(15);
}
block(25, x3 * 3 + 1);
cout << "╭——————╮";
block(25, x3 * 3 + 2);
cout << "| |";
block(27, x3 * 3 + 2);
cout << shus[3][shu[3][y3]];
block(25, x3 * 3 + 3);
cout << "╰——————╯";
}
void output3(){
color(15);
block(43, zz33);
cout << " ";
int x3 = 1;
for(int i = 1; i <= shul[3]; i++){
output31(x3, i);
x3++;
}
}
void output2(){
color(15);
block(43, zz23);
cout << " ";
block(43, zz23 + 1);
cout << " ";
block(43, zz23 + 2);
cout << " ";
for(int i = 1; i <= shul[2]; i++){
if(i == y){
block(43, i * 3 + 1);
cout << "1.加";
block(43, i * 3 + 2);
cout << "2.减";
if(shu[2][i] == 4){
block(43, i * 3 + 3);
cout << "3.派出猎人";
if(catli1 > 199){
cout << "×" << (int)(catli1 / 100);
}
}
color(0 + 15 * 16);
zz23 = i * 3 + 1;
}else{
color(15);
}
block(25, i * 3 + 1);
cout << "╭——————╮";
block(25, i * 3 + 2);
cout << "| |";
block(27, i * 3 + 2);
cout << shus[2][shu[2][i]] << "(" << zz21[shu[2][i]] << ")";
block(25, i * 3 + 3);
cout << "╰——————╯";
}
}
void output_1(){
if(heng[x] == 1){
output1();
}else if(heng[x] == 3){
output3();
}else if(heng[x] == 2){
output2();
}
}
int main( ){
system("mode con cols=70 lines=25");
color(15);
HideCursor();
Sleep(1500);
cout << "欢迎来到(高仿版)猫国建设者!" << endl;
Sleep(1000);
cout << " //本游戏原型为 https://likexia.gitee.io/cat-zh#/" << endl;
Sleep(500);
cout << " //本游戏由XTW蒟蒻编制而成" << endl;
Sleep(500);
cout << endl << "请按任意键继续……";
char zzzzzzzzzzzzzzzzzzzz = getch();
system("cls");
output0();
output00();
output1();
while(true){
output00();
output02();
pan('w');
pan('s');
pan('a');
pan('d');
pan('1');
pan('2');
pan('3');
if(check('w')){
if(y > 0){
y--;
output_1();
}
}else if(check('s')){
if(y < shul[heng[x]]){
y++;
output_1();
}
}else if(check('a')){
if(y == 0 && x > 1){
x--;
output0();
output01();
output_1();
}
}else if(check('d')){
if(y == 0 && x < hengl){
x++;
output0();
output01();
output_1();
}
}else if(check('1')){
if(heng[x] == 1){
if(shu[1][y] == 1){
bohe1 += 1;
}else if(shu[1][y] == 3){
if(bohe1 >= 100){
bohe1 -= 100;
mutou1 += 1;
}
}else{
h1 = true;
int i = 1;
while(zz12[shu[1][y]][i] != 0){
if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 1){
if(bohe1 < zz12[shu[1][y]][i]){
h1 = false;
break;
}
}else if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 2){
if(mutou1 < zz12[shu[1][y]][i]){
h1 = false;
break;
}
}else if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 3){
if(kuangwu1 < zz12[shu[1][y]][i]){
h1 = false;
break;
}
}else{
block(1, 19);
cout << zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2)));
cout << "?????";
Sleep(1500);
}
i++;
}
if(h1){
i = 1;
while(zz12[shu[1][y]][i] != 0){
if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 1){
zz15[shu[1][y]]++;
bohe1 -= zz12[shu[1][y]][i];
zz12[shu[1][y]][i] = (int)(pow(zz17[shu[1][y]], zz15[shu[1][y]]) * zz16[shu[1][y]][i] * 100 + 0.5) / 100.0;
}else if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 2){
zz15[shu[1][y]]++;
mutou1 -= zz12[shu[1][y]][i];
zz12[shu[1][y]][i] = (int)(pow(zz17[shu[1][y]], zz15[shu[1][y]]) * zz16[shu[1][y]][i] * 100 + 0.5) / 100.0;
}else if(zz13[shu[1][y]] % (int)(pow(10, i * 2)) / (int)(pow(10, (i * 2 - 2))) == 3){
zz15[shu[1][y]]++;
kuangwu1 -= zz12[shu[1][y]][i];
zz12[shu[1][y]][i] = (int)(pow(zz17[shu[1][y]], zz15[shu[1][y]]) * zz16[shu[1][y]][i] * 100 + 0.5) / 100.0;
}
i++;
}
if(shu[1][y] == 4){
cat2 += 2;
catli2 += 75;
if(!z1[1]){
hengl++;
heng[2] = 2;
heng[3] = 4;
shul[2] = 1;
z1[1] = true;
shul[1]++;
shu[1][5] = 5;
output0();
}
}else if(shu[1][y] == 5){
keji2 += 250;
if(!z1[2]){
hengl++;
heng[3] = 3;
heng[4] = 4;
shu[2][2] = 3;
shul[2]++;
z1[2] = true;
}
}else if(shu[1][y] == 6){
bohe2 += 5000;
mutou2 += 200;
kuangwu2 += 250;
}else if(shu[1][y] == 7){
if(!z1[3]){
shul[2]++;
shu[2][shul[2]] = 5;
sort(shu[2] + 1, shu[2] + shul[2] + 1, pai2);
shul[1]++;
shu[1][shul[1]] = 8;
sort(shu[1] + 1, shu[1] + shul[1] + 1, pai1);
z1[3] = true;
}
}
}
}
output1();
}else if(heng[x] == 2){
if(zz22 > 0){
zz21[shu[2][y]]++;
zz22--;
output2();
}
}else if(heng[x] == 3){
if(keji1 >= zz32[shu[3][y]]){
zz31[shu[3][y]] = true;
keji1 -= zz32[shu[3][y]];
if(shu[3][y] == 1){
shul[3] = 1;
shu[3][1] = 2;
output_1();
}else if(shu[3][y] == 2) {
shul[3] = 2;
shu[3][1] = 3;
shu[3][2] = 4;
shu[2][2] = 2;
shu[2][3] = 3;
shul[2]++;
shul[1]++;
shu[1][6] = 6;
}else if(shu[3][y] == 3){
shu[3][y] = 5;
shul[2]++;
shu[2][shul[2]] = 4;
sort(shu[2] + 1, shu[2] + 1 + shul[2], pai2);
xinqing1 = true;
}else if(shu[3][y] == 4){
shu[3][y] = 6;
shul[1]++;
shu[1][shul[1]] = 7;
sort(shu[1] + 1, shu[1] + 1 + shul[1], pai1);
}
output3();
}
}
}else if(check('2')){
if(heng[x] == 1){
}else if(heng[x] == 2){
if(zz21[shu[2][y]] > 0){
zz21[shu[2][y]]--;
zz22++;
output2();
}
}
}else if(check('3')){
if(heng[x] == 1){
}else if(heng[x] == 2){
if(shu[2][y] == 4 && catli1 >= 100){
catli1 -= 100;
srand(time(NULL));
int sui1 = (rand() % 2001) + 3000;
int sui2 = (rand() % 1001);
int sui3 = (rand() % 3);
maopi1 = true;
maopi += sui1 / 100.0;
if(sui3 == 0){
xiangya1 = true;
xiangya += sui2 / 100.0;
}
}
}
}
if(tim1 == 1){
bohe1 += zz15[2] * 0.063 * 1.5;
}else if(tim1 == 4){
bohe1 += zz15[2] * 0.063 * 0.25;
}else{
bohe1 += zz15[2] * 0.063;
}
bohe1 -= cat1 * 0.4;
mutou1 += zz21[1] * 0.009 * xinqing / 100;
bohe1 += zz21[2] * 0.5 * xinqing / 100;
keji1 += zz21[3] * 0.0175 * (1 + 0.1 * zz15[5]) * xinqing / 100;
catli1 += zz21[4] * 0.03 * xinqing / 100;
kuangwu1 += zz21[5] * 0.025 * (1 + 0.2 * zz15[7]) * xinqing / 100;
if(maopi > 0){
maopi -= cat1 * 0.005;
if(maopi < 0){
maopi = 0;
}
}
if(xiangya > 0){
xiangya -= cat1 * 0.0035;
if(xiangya < 0){
xiangya = 0;
}
}
if(!xinqing1 && cat1 > 4){
xinqing1 = true;
}
xinqing = 100 - max(cat1 * 2 - 10, 0);
if(maopi > 0){
xinqing += 10;
}
if(xiangya > 0){
xinqing += 10;
}
if(bohe1 <= 0 && cat1 > 0){
timm2 = 0;
bohe1 = 0;
timm1++;
if(timm1 == 54){
cat1--;
if(zz22 <= 0){
for(int i = 1; i <= shul[2]; i++){
if(zz21[shu[2][i]] > 0){
zz21[shu[2][i]]--;
break;
}
}
}else{
zz22--;
}
timm1 = 0;
}
}else{
timm1 = 0;
if(cat2 > cat1){
timm2++;
if(timm2 == 108){
cat1++;
zz22++;
timm2 = 0;
}
}
}
if(z1[30] == 0 && cat2 >= 8){
hengs[2] = "村庄";
z1[30]++;
}
Sleep(100);
tim3++;
}
return 0;
}
未完待续……