#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[