This is a screenshot of the effect :

Partial source code :
#include <iostream> #include <time.h> #include <windows.h> #define W 1 // upper
#define S 2 // lower #define A 3 // Left #define D 4 // right #define L 4 // Tanks have 4 Life void
HideCursor() { // hide cursor CONSOLE_CURSOR_INFO cursor_info = { 1,0 };
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } void
GoToxy(int x, int y) { // Cursor movement ,X,Y Horizontal representation , Ordinate COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } // global variable int
map[50][40];// Map 2D array int B_num; // Bullet number int Pos;
// Enemy tank generation position ,-1 To the left ,0 For the middle ,1 To the right ,2 For my tank position int Speed = 7; // Game speed int Enemy; // An enemy that has not yet appeared
const char* Tank_Model[3][4] ={ {"◢┃ ◣", "◢╦ ◣", "◢╦◣", "◢╦◣"}, {"╠ █╣", "╠
█╣", "━█╣", "╠█━"}, {"◥╩ ◤", "◥┃ ◤", "◥╩◤", "◥╩◤"} }; // Tank class Tank{ public:
int x, y; // Central coordinates int Direction; // direction int Model; // Model int Revival; // Resurrection times int
Num; // Enemy tank number bool Type; // This parameter of our tank is 1 bool Exist; // Survival as 1, Do not survive as 0 }AI_tank[6],
my_tank; // bullet class Bullet{ public: int x, y; // coordinate int Direction; // direction bool
Exist; //1 For existence ,0 non-existent bool Type; //0 For enemy bullets ,1 For our bullets }bullet[50] ; // Basic function void
GoToxy(int x, int y); // Cursor movement void HideCursor(); // hide cursor void Key(); // keyboard entry void
Init(); // initialization void Pause(); // suspend void Show(); // Print frame void Print_Map(); // Print map
void Cheak_Game(); // Test the outcome of the game void GameOver(); // game over // Tank void Creat_AI_T(Tank*
AI_tank); // Build tank void Creat_My_T(Tank* my_tank); void Move_AI_T(Tank*
AI_tank);// Tank movement void Move_My_T(int turn); void Clear_T(int x, int y); // Clear tank
void Print_T(Tank tank); // Print tank bool Cheak_T(Tank tank, int direction);
// Detection obstacle ,1 hinder // bullet void Creat_AI_B(Tank* tank); // Enemy tanks fired bullets void Creat_My_B(Tank
tank);// Our tanks fired bullets void Move_B(Bullet bullet[50]); // Bullet movement void Break_B(Bullet*
bullet); // Bullet collision void Print_B(int x, int y);// Print bullet void Clear_B(int x, int y);
// Clear the bullet int Cheak_B(int x, int y); // Situation in front of the bullet void Show() { // Print frame std::cout << "
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"; std::cout <<
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\n"; for (int i = 0; i < 48; i++) {
std::cout << "▕ ▏\n"; } std::cout << " ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔";
std::cout << "▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n"; } void Print_Map() { //
Print map int Map[50][40] = { //map Value in : 0 It can pass through land ,1 For brick ,6 For wall ,100~105 For enemy tanks ,200 For my tank , {
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0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,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,4
}, {
4,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,4
}, {
4,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,4
}, {
4,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,4
}, {
4,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,9,9,9,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,9,9,9,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,9,9,9,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
}, {
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
} }; for (int i = 0; i < 50; i++) for (int j = 0; j < 40; j++) map[i][j] =
Map[i][j]; for (int i = 0; i < 50; i++) for (int j = 0; j < 40; j++) if
(map[i][j] == 1) { GoToxy(2 * j, i); std::cout << "▓"; } else if (map[i][j] ==
6) { GoToxy(2 * j, i); std::cout << "■"; } GoToxy(38, 46); std::cout << " ◣◢";
GoToxy(38, 47); std::cout << "◣█ ◢"; GoToxy(38, 48); std::cout << "◢█ ◣"; }
void Cheak_Game() { // None of the enemy tanks survived if (Enemy <= 0 && !AI_tank[0].Exist &&
!AI_tank[1].Exist && !AI_tank[2].Exist && !AI_tank[3].Exist &&
!AI_tank[4].Exist && !AI_tank[5].Exist) GameOver(); if (my_tank.Revival >=
L)// I've run out of resurrection times GameOver();// game over } void GameOver() { bool home = 1; while (home) {
GoToxy(37, 21); std::cout << " game over !"; if (GetAsyncKeyState(0xD) & 0x8000) {
// enter key system("cls"); // Clear screen Show(); Init(); // initialization break; } else if
(GetAsyncKeyState(0x1B) & 0x8000) //Esc Key exit exit(0); } } void Creat_My_T(Tank*
my_tank) {// Build my tank my_tank->x = 15; my_tank->y = 47; my_tank->Direction = 1; //
my_tank->Model = 0; my_tank->Exist = 1; my_tank->Type = 1; Print_T(*my_tank);
// Print my tank } void Move_My_T(int turn) {//turn by Key() The direction value passed in by the function Clear_T(my_tank.x,
my_tank.y); my_tank.Direction = turn; if (Cheak_T(my_tank, my_tank.Direction))
// Our tanks have no obstacles in the current direction switch (turn) { case W: my_tank.y--; break; // upper case S:
my_tank.y++; break; // lower case A: my_tank.x--; break; // Left case D: my_tank.x++;
break; // right } Print_T(my_tank); } void Print_T(Tank tank) {// Print for (int i = 0;
i < 3; i++) { GoToxy((tank.x - 1) * 2, tank.y - 1 + i);// To the left of the tank's central coordinates , Upper, middle and lower lines Print
std::cout << Tank_Model[i][tank.Direction - 1]; // The address is printed , Address string for (int j = 0;
j < 3; j++) if (tank.Type)// If for my tank map[tank.y + j - 1][tank.x + i - 1] = 200;
// stay map The upper enemy value is 100~105, We are 200 else map[tank.y + j - 1][tank.x + i - 1] = 100
+tank.Num; // This can be done through map Value read tank number } } void Creat_AI_T(Tank* AI_tank) { AI_tank->x =
19 + 17 * (Pos); //pos Generate position for tank ,-1 Left position ,0 For the middle ,1 Right ,2 For my tank position AI_tank->y = 2;
AI_tank->Direction = 2; // Direction down AI_tank->Revival++; // Resurrection times +1 AI_tank->Exist =
1;// existence Pos++; Enemy--; if (Pos == 2) // Cycle reset (pos Can only be -1,0,1) Pos = -1;
Print_T(*AI_tank); return; } void Move_AI_T(Tank* AI_tank) { if
(AI_tank->Exist) { // existence Clear_T(AI_tank->x, AI_tank->y); if (Cheak_T(*AI_tank,
AI_tank->Direction))// Accessibility ahead switch (AI_tank->Direction) { case W: AI_tank->y--;
break; // upper case S: AI_tank->y++; break; // lower case A: AI_tank->x--; break; // Left
case D: AI_tank->x++; break; // right } else {// There are obstacles ahead for (int i = rand() % 4 + 1; i
<= 4; i++) if (Cheak_T(*AI_tank, i)){ // Circular judgment , return 1 Can pass AI_tank->Direction = i;
break; } } Print_T(*AI_tank); // Print enemy tanks } } bool Cheak_T(Tank tank, int
direction) { // Detect obstacles in front of the tank , return 1 Is passable switch (direction) { case W: if (map[tank.y -
2][tank.x] == 0 && map[tank.y - 2][tank.x - 1] == 0 && map[tank.y - 2][tank.x +
1] == 0) return 1; else return 0; case S: if (map[tank.y + 2][tank.x] == 0 &&
map[tank.y + 2][tank.x - 1] == 0 && map[tank.y + 2][tank.x + 1] == 0) return 1;
else return 0; case A: if (map[tank.y][tank.x - 2] == 0 && map[tank.y -
1][tank.x - 2] == 0 && map[tank.y + 1][tank.x - 2] == 0) return 1; else return
0; case D: if (map[tank.y][tank.x + 2] == 0 && map[tank.y - 1][tank.x + 2] == 0
&& map[tank.y + 1][tank.x + 2] == 0) return 1; else return 0; default: return
0; } } void Clear_T(int x, int y) { // Clear tank for (int i = 0; i <= 2; i++) for
(int j = 0; j <= 2; j++) {// Clear the map occupied by the tank map[y + j - 1][x + i - 1] = 0; GoToxy(2
* x + 2 * j - 2, y + i - 1); std::cout << " "; } } // keyboard entry void Key() { // Up, down, left and right keys
if (GetAsyncKeyState('W') & 0x8000) Move_My_T(W); else if
(GetAsyncKeyState('S') & 0x8000) Move_My_T(S); else if (GetAsyncKeyState('A') &
0x8000) Move_My_T(A); else if (GetAsyncKeyState('D') & 0x8000) Move_My_T(D);
// Bullet firing else if (GetAsyncKeyState('P') & 0x8000) { Creat_My_B(my_tank); } else
if (GetAsyncKeyState(0x1B) & 0x8000)// Esc Key exit exit(0); else if
(GetAsyncKeyState(0x20) & 0x8000)// Space pause Pause(); } void Pause() { // suspend while
(1) { if (GetAsyncKeyState(0xD) & 0x8000) { // Press enter to continue break; } else if
(GetAsyncKeyState(0x1B) & 0x8000) //Esc Key exit exit(0); } } void Creat_AI_B(Tank*
tank){ // The enemy fired bullets if (!(rand() % 10)) { // In each subsequent game cycle 10 One in ten bullets could be fired
Creat_My_B(*tank); } } void Creat_My_B(Tank tank) { switch (tank.Direction) {
case W: bullet[B_num].x = tank.x; bullet[B_num].y = tank.y - 2;
bullet[B_num].Direction = 1;//1 Indicates up break; case S: bullet[B_num].x = tank.x;
bullet[B_num].y = tank.y + 2; bullet[B_num].Direction = 2;//2 Indicates down break; case
A: bullet[B_num].x = tank.x - 2; bullet[B_num].y = tank.y;
bullet[B_num].Direction = 3;//3 Indicates left break; case D: bullet[B_num].x = tank.x +
2; bullet[B_num].y = tank.y; bullet[B_num].Direction = 4;//4 Indicates right break; }
bullet[B_num].Exist = 1; // Bullet presence bullet[B_num].Type = tank.Type;
// Bullets fired by our tanks bullet.Type=1 B_num++; if (B_num == 50) // If the bullet number increases to 50 number , Then start numbering again
B_num = 0; // Considering that it is impossible to exist on the map at the same time 50 Bullet , So array element settings 50 individual } void Move_B(Bullet bullet[50]) {
// Bullet movement for (int i = 0; i < 50; i++) { if (bullet[i].Exist) {// If the bullet is present if
(map[bullet[i].y][bullet[i].x] == 0) { Clear_B(bullet[i].x,
bullet[i].y);// The current position of the bullet is unobstructed , Erase bullet pattern switch (bullet[i].Direction) {// The bullet changes to the next coordinate case
W:(bullet[i].y)--; break; case S:(bullet[i].y)++; break; case
A:(bullet[i].x)--; break; case D:(bullet[i].x)++; break; } } // Determine the current position of the bullet if
(map[bullet[i].y][bullet[i].x] == 0) // Bullet coordinate accessibility Print_B(bullet[i].x,
bullet[i].y);// Print else Break_B(&bullet[i]); // Bullet collision for (int j = 0; j < 50; j++)
// Collision judgment between bullets , If our bullets collide with enemy bullets, they will be deleted , If it's two enemy bullets, ignore it if (bullet[j].Exist && j != i &&
(bullet[i].Type || bullet[j].Type) && bullet[i].x == bullet[j].x && bullet[i].y
== bullet[j].y) { // The same two of our bullets can't collide bullet[j].Exist = 0; bullet[i].Exist = 0;
Clear_B(bullet[j].x, bullet[j].y); break; } } } } void Break_B(Bullet* bullet)
{ int x = bullet->x; int y = bullet->y; // Bullet coordinates int i; if (map[y][x] == 1) {
// The bullet hit the brick if (bullet->Direction == A || bullet->Direction == D) // If the bullet is horizontal for (i
= -1; i <= 1; i++) if (map[y + i][x] == 1) { map[y + i][x] = 0; GoToxy(2 * x, y
+ i); std::cout << " "; } if (bullet->Direction == W || bullet->Direction == S)
// The bullet moves up or down for (i = -1; i <= 1; i++) if (map[y][x + i] == 1) {
// If the bullet hits a brick, there are bricks on both sides , Then delete the brick , If not, ignore map[y][x + i] = 0; // Broken brick GoToxy(2 * (x + i), y);
std::cout << " "; } bullet->Exist = 0; // The bullet doesn't exist } else if (map[y][x] == 4 ||
map[y][x] == 6) // A bullet hits a border or an indestructible square bullet->Exist = 0; else if (bullet->Type ==1
&& map[y][x] >= 100 && map[y][x] <= 105) { // Our bullets hit the enemy tank AI_tank[(int)map[y][x]
% 100].Exist = 0; bullet->Exist = 0; Clear_T(AI_tank[(int)map[y][x] % 100].x,
AI_tank[(int)map[y][x] % 100].y); // Clear tank } else if (bullet->Type == 0 &&
map[y][x] == 200) { // If enemy bullets hit my tank my_tank.Exist = 0; bullet->Exist = 0;
Clear_T(my_tank.x, my_tank.y); my_tank.Revival++; // The number of resurrection times of our tanks is increased 1 } else if
(map[y][x] == 9) { // The bullet hit the nest bullet->Exist = 0; GoToxy(38, 46); std::cout << " ";
GoToxy(38, 47); std::cout << " "; GoToxy(38, 48); std::cout << "◢◣ ";
GameOver(); } } int Cheak_B(int x, int y) {// Current position of bullet if (map[y][x] == 0)
return 1; else return 0; } void Print_B(int x, int y){ GoToxy(2 * x, y);
std::cout << "o"; } void Clear_B(int x, int y){ GoToxy(2 * x, y); if
(Cheak_B(x, y) == 1) {// The current coordinates of the bullet are in the open space std::cout << " "; } } void Init() { // initialization
Enemy = 24; my_tank.Revival = 0; // My tank resurrection times are 0 Pos = 0; B_num = 0; Print_Map();
Creat_My_T(&my_tank); for (int i = 0; i < 50; i++) {// bullet bullet[i].Exist = 0; }
for (int i = 0; i <= 5; i++) {// Enemy tanks AI_tank[i].Revival = 0; AI_tank[i].Exist =
0; // Initialization tanks don't survive , use Creat_AI_T() Build non viable tanks AI_tank[i].Num = i; AI_tank[i].Type = 0;
} } int main() { int i; int gap[16] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
// Interval array , Used to control speed HideCursor(); // hide cursor Show(); // Print frame Init(); // initialization while(1) { if
(gap[0]++ % Speed == 0) { // Speed adjustment , Cheak_Game(); // Game outcome detection for (i = 0; i <= 5;
i++) {// Enemy tank movement cycle if (gap[i + 7]++ % 3 == 0) Move_AI_T(&AI_tank[i]); } for (i =
0; i <= 5; i++)// Build enemy tanks if (AI_tank[i].Exist == 0 && AI_tank[i].Revival < 4 &&
gap[i+1]++ % 50 == 0) { // An enemy tank has only 4 Life // After the tank died, it was established at an interval of time
Creat_AI_T(&AI_tank[i]); break; } for (i = 0; i <= 5; i++) if
(AI_tank[i].Exist) Creat_AI_B(&AI_tank[i]); if (my_tank.Exist && gap[14]++ % 2
== 0) Key(); if (my_tank.Exist == 0 && my_tank.Revival < L && gap[15]++ % 15 ==
0)// Resurrection of our tanks Creat_My_T(&my_tank); Move_B(bullet); } Sleep(5); } return 0; }

Technology