无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!

这篇具有很好参考价值的文章主要介绍了无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

个程序的源码没有什么技术要求,一般至少能看懂95%,因为博主是大一上学期写着玩的,当写了一周,还拿它参加了学校的创意编程比赛,结果第一用的ui,直接降维打击了,拿了个二等奖

 无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!

 无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!

操作方法游戏内都有

注意事项:1在动画时不能乱按
     2小怪设计的初衷是躲避,因此碰到就直接死(主要是我当初没想到我能把敌方子弹射击出来)
     3子弹按的速度过快会在某个点停下来,困难模式基本不会有这种情况,狂按就完了
     4由于小怪主要设计是躲避,所以子弹给的比较少,到BOSS时会自动增加,足够用
     5积分达到200时BOSS就会出现,BOSS四个技能,其中激光碰到大概率会直接死
     6尽量选择普通和困难,简单模式太弱智了

游戏思路:控制光标移动,通过坐标定点输出起到子弹移动,飞机移动效果和动画效果。
                 以不同数组分别存放我方与敌方的子弹坐标,理论上增加数组就可以增加子弹种类


缺点:就是移动僵硬,不能使长按速度保持稳定,所以点按玩起来效果更好。
          我方飞机不够没观,敌机种类较少
          没有音效(是一个遗憾)

大家有什么问题欢迎评论或私信问我哦,博主现在大一,一般一天之内就可以回复。

因为这个程序是一个多月前写的,有些重要的东西我可能没有说,欢迎提问!

头文件:

#include<iostream>
#include<Windows.h>
#include<conio.h>
#include<cstdlib>
#include<time.h>
#include<stdlib.h>
#include<cmath>
#include"menu.h"
 
//飞机活动大小
#define width 80
#define height 40
//窗口大小
#define t_width 120
#define t_height 40
 
void gotoxy(short x, short y);
void Game();
 
void enemyAppear(char arr[width + 10][height]);
void enemyMove(char arr[width + 10][height]);
 
void bulletMove(char arr[width + 10][height]);
void BOSSgame();
void shotBOSS(char arr[width + 10][height]);
void difficulty();
 
void cartoonStartMenu();
void start_menu();
void game_menu();
void cartoonGameMenu();
void end_menu();
void success_menu();
void BOSScartoon();
void printBOSS();

全局变量:

这部分主要是调节难度用的

extern int score = 0;
extern int bullet = 99999;
extern int HP = 100000;
extern int BOSSHP = 500;
extern int damage = 3;
extern int enemySpeed = 10;
extern int BOSSspeed = 15;
extern int Number = 4;
extern int BOSS = 0;
 

最难的部分:

该部分是我认为命令行实现按键移动的关键,如果只是想试玩一下只要知道函数功能就够了

深入了解handle(句柄)我推荐:控制台API函数----HANDLE、SetConsoleCursorPosition、SetConsoleTextAttribute_weixin_30901729的博客-CSDN博客

//清除光标
void clearCursor()
{
	HANDLE hOut;
	CONSOLE_CURSOR_INFO cur = { 1,0 };
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorInfo(hOut, &cur);
}
 
 
//使光标移动到指定位置
void gotoxy(short x, short y)
{
	HANDLE hOut;
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD pos = { x,y };
	SetConsoleCursorPosition(hOut, pos);
}

存子弹和飞机位置的数组:

char enemyArr[width + 10][height] = { 0 };
char myBulletArr[width + 10][height] = { 0 };

我方飞机的子弹射击,移动

//飞机图像
void printPlane(short x, short y)
{
	gotoxy(x, y);
	cout << "*";//头
	gotoxy(x, y + 1);
	cout << "*";//尾
	gotoxy(x - 1, y + 1);
	cout << "*";//左翼
	gotoxy(x + 1, y + 1);
	cout << "*";//右翼
}
 
 
class myPlane
{
public:
	//头的坐标
	short x = width / 2;
	short y = height / 2;
 
 
 
	//初始化飞机
	void initMyPlane()
	{
		printPlane(x, y);
	}
 
	//清除飞机移动前位置图像
	void clearMyplane()
	{
		gotoxy(x, y);
		cout << " ";//头
		gotoxy(x, y + 1);
		cout << " ";//尾
		gotoxy(x - 1, y + 1);
		cout << " ";//左翼
		gotoxy(x + 1, y + 1);
		cout << " ";//右翼
	}
 
 
	//射击
	void shoot(char myArr[width + 10][height])
	{
		if (bullet == 0)
			return;
		myArr[x][y - 1] = '*';
		gotoxy(x, y - 1);
		cout << "*";
		bullet--;
		gotoxy(width + (t_width - width) / 2, 9);
		cout << "   ";
		gotoxy(width + (t_width - width) / 2, 9);
		cout << bullet;
	}
 
	//飞机移动+游戏中的菜单栏功能实现
	void myPlaneMove(char arr[width + 10][height])
	{
		//判断是否有键盘操作
		if (_kbhit())
		{
			char move;
			move = _getch();
			switch (move)
			{
			case 'w':
				if (BOSS == 1)
					if (y == 16)
						break;
				//判断是否是边界
				if (y == 1)
					break;
				//清除原图像
				clearMyplane();
				y--;
				//打印新位置
				printPlane(x, y);
				break;
			case 'a':
				if (x - 1 == 1)
					break;
				clearMyplane();
				x--;
				printPlane(x, y);
				break;
			case 's':
				if (y + 1 == height - 2)
					break;
				clearMyplane();
				y++;
				printPlane(x, y);
				break;
			case 'd':
				if (x + 1 == width - 2)
					break;
				clearMyplane();
				x++;
				printPlane(x, y);
				break;
			case 'j':
				shoot(myBulletArr);
			case 'W':
				if (BOSS == 1)
					if (y == 16)
						break;
				//判断是否是边界
				if (y == 1)
					break;
				//清除原图像
				clearMyplane();
				y--;
				//打印新位置
				printPlane(x, y);
				break;
			case 'A':
				if (x - 1 == 1)
					break;
				clearMyplane();
				x--;
				printPlane(x, y);
				break;
			case 'S':
				if (y + 1 == height - 2)
					break;
				clearMyplane();
				y++;
				printPlane(x, y);
				break;
			case 'D':
				if (x + 1 == width - 2)
					break;
				clearMyplane();
				x++;
				printPlane(x, y);
				break;
            //控制射击
			case 'J':
				shoot(myBulletArr);
			}
		}
	}
};
 
myplane p;//创捷我方飞机

难度参数设置:

//难度选择
void difficulty()
{
	gotoxy(t_width / 2 - 5, t_height / 2 - 4);
	cout << "1.简单模式";
	gotoxy(t_width / 2 - 5, t_height / 2);
	cout << "2.普通模式";
	gotoxy(t_width / 2 - 5, t_height / 2 + 4);
	cout << "3.困难模式";
	char choice;
	choice = _getch();
	switch (choice)
	{
	case '1':
		enemySpeed = 50;
		BOSSspeed = 25;
		HP = 1000;
		damage = 5;
		bullet = 50;
		Number = 2;
		break;
	case '2':
		enemySpeed = 10;
		BOSSspeed = 15;
		HP = 500;
		damage = 3;
		bullet = 30;
		Number = 4;
		break;
	case '3':
		enemySpeed = 8;
		BOSSspeed = 5;
		HP = 100;
		damage = 2;
		bullet = 10;
		Number = 6;
		break;
	}
 
}

子弹功能实现:

void shotEnemy(char enemyArr[width + 10][height], char myArr[width + 10][height])
{
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (myArr[i][j] == '*' || myArr[i][j] == '@')
			{
				//碰头
				if (enemyArr[i][j - 2] == '+')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰左翼
				else if (enemyArr[i][j - 2] == 'p')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰右翼
				else if (enemyArr[i][j - 2] == 'q')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰头
				if (enemyArr[i][j - 1] == '+')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i - 1][j - 2] = 0;
					enemyArr[i + 1][j - 2] = 0;
					enemyArr[i][j - 2] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i - 1, j - 2);
					cout << " ";
					gotoxy(i + 1, j - 2);
					cout << " ";
					gotoxy(i, j - 2);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
 
				}
 
				//碰左翼
				else if (enemyArr[i][j - 1] == 'p')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i - 1][j] = 0;
					enemyArr[i - 1][j - 1] = 0;
					enemyArr[i - 2][j - 1] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i - 1, j);
					cout << " ";
					gotoxy(i - 1, j - 1);
					cout << " ";
					gotoxy(i - 2, j - 1);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
				}
 
				//碰右翼
				else if (enemyArr[i][j - 1] == 'q')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i + 1][j] = 0;
					enemyArr[i + 1][j - 1] = 0;
					enemyArr[i + 2][j - 1] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i + 1, j);
					cout << " ";
					gotoxy(i + 1, j - 1);
					cout << " ";
					gotoxy(i + 2, j - 1);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
				}
 
 
 
			}
		}
}
 
//子弹移动
void bulletMove(char myArr[width + 10][height])
{
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (myArr[i][j] == '*')
			{
				myArr[i][j] = 0;
				myArr[i][j - 1] = '*';
				gotoxy(i, j - 1);
				cout << "*";
				gotoxy(i, j);
				cout << " ";
			}
 
		}
 
	//清除触界子弹
	for (int k = 1; k < width; k++)
	{
		if (myArr[k][1] == '*')
		{
			gotoxy(k, 1);
			cout << " ";
			myArr[k][1] = 0;
		}
	}
}

敌机设置:

//随机出现敌机
void enemyAppear(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	//随机敌机数量
	int number = rand() % 6 + Number;
	//随机敌机位置
	for (int i = 0; i < number; i++)
	{
		short x = rand() % (width - 4) + 2;
		//防止敌机重叠
		if (enemyArr[x][2] == '+' || enemyArr[x - 1][2] == '+' || enemyArr[x + 1][2] == '+' || enemyArr[x - 2][2] == '+' || enemyArr[x + 2][2] == '+')
			continue;
		short y = 2;
		enemyArr[x][y] = '+';
		enemyArr[x][y - 1] = 'T';
		enemyArr[x - 1][y - 1] = 'q';
		enemyArr[x + 1][y - 1] = 'p';
 
		gotoxy(x, y);
		cout << "+";//头
		gotoxy(x, y - 1);
		cout << "T";//尾   
		gotoxy(x - 1, y - 1);
		cout << "q";//右翼     //+++ 
		gotoxy(x + 1, y - 1);  // 0   
		cout << "p";//左翼
 
	}
}
 
void enemyMove(char enemyArr[width + 10][height])
{
	for (int i = width; i > 0; i--)
		for (int j = height - 3; j > 0; j--)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j - 1] = 0;
				enemyArr[i - 1][j - 1] = 0;
				enemyArr[i + 1][j - 1] = 0;
 
				enemyArr[i][j] = 'T';
				enemyArr[i][j + 1] = '+';
				enemyArr[i - 1][j] = 'q';
				enemyArr[i + 1][j] = 'p';
				gotoxy(i, j - 1);
				cout << " ";
				gotoxy(i - 1, j - 1);
				cout << " ";
				gotoxy(i + 1, j - 1);
				cout << " ";
				gotoxy(i, j + 1);
				cout << "+";
				gotoxy(i, j);
				cout << "T";
				gotoxy(i - 1, j);
				cout << "q";
				gotoxy(i + 1, j);
				cout << "p";
			}
		}
 
	//清除触界敌机
	for (int i = 0; i < width; i++)
	{
		if (enemyArr[i][height - 2] == '+')
		{
			enemyArr[i][height - 2] = 0;
			enemyArr[i][height - 3] = 0;
			enemyArr[i + 1][height - 3] = 0;
			enemyArr[i - 1][height - 3] = 0;
			gotoxy(i, height - 2);
			cout << " ";
			gotoxy(i - 1, height - 3);
			cout << " ";
			gotoxy(i + 1, height - 3);
			cout << " ";
			gotoxy(i, height - 3);
			cout << " ";
			score++;
		}
	}
}
 
//判断是否触碰敌机
bool judgeEnemy(short x, short y, char enemyArr[width + 10][height])
{
	if (enemyArr[x][y] == '+' || enemyArr[x][y] == 'p' || enemyArr[x][y] == 'q' || enemyArr[x - 1][y + 1] == '+' || enemyArr[x - 1][y + 1] == 'p' || enemyArr[x - 1][y + 1] == 'q'
		|| enemyArr[x + 1][y + 1] == '+' || enemyArr[x + 1][y + 1] == 'p' || enemyArr[x + 1][y + 1] == 'q' || enemyArr[x][y + 1] == '+' || enemyArr[x][y + 1] == 'p' || enemyArr[x][y + 1] == 'q')
	{
		return true;
	}
	else
	{
 
		gotoxy(width + (t_width - width) / 2, 11);
		cout << HP << "    ";
		return false;
	}
}

函数整合:

void Game()
{
	//存储敌机坐标
	system("cls");
	difficulty();
	system("cls");
	cartoonStartMenu();
	game_menu();
	p.initMyPlane();
	while (true)
	{
		enemyAppear(enemyArr);
        //这里可能有点难理解,可以先把外层循环去掉只看内层循环
        //Sleep(1)是停止1ms也就是说每enemySpeed毫秒子弹,敌军移动一次
        //把外层循环加进来就是10*enemySpeed毫秒敌军出现一次
        //这样写的目的是使得每一毫秒程序都能检测是否有按键移动射击操作
		for (int i = 0; i < 10; i++)
		{
 
			for (int j = 0; j < enemySpeed; j++) {
				p.myPlaneMove(enemyArr);
				if (judgeEnemy(p.x, p.y, enemyArr))
				{
					end_menu();
				}
				Sleep(1);
			}
			bulletMove(myBulletArr);
			shotEnemy(enemyArr, myBulletArr);
			enemyMove(enemyArr);
			gotoxy(width + (t_width - width) / 2, 7);
			cout << score;
            //分数大于200进入BOSS战
			if (score > 200)
				BOSSgame();
		}
	}
 
}

BOSS功能的实现:

大家在这里可以充分发挥自己的创造力啊>_<

//BOSS子弹移动
void enemyBulletMove(char enemyArr[width + 10][height])
{
	for (int i = width; i > 0; i--)
		for (int j = height - 3; j > 0; j--)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j] = 0;
				enemyArr[i][j + 1] = '+';
 
				gotoxy(i, j);
				cout << " ";
 
				gotoxy(i, j + 1);
				cout << "+";
				judgeBOSSBullet(p.x, p.y, enemyArr);
			}
		}
 
	//清除触界敌军子弹
	for (int i = 0; i < width; i++)
	{
		if (enemyArr[i][height - 2] == '+')
		{
			enemyArr[i][height - 2] = 0;
 
			gotoxy(i, height - 2);
			cout << " ";
		}
	}
}
 
 
//持续射击
void keepShooting(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int j = 0; j < 100; j++)
	{
		int x = rand() % 78 + 1;
		gotoxy(x, 16);
		cout << "+";
		enemyArr[x][16] = '+';
		gotoxy(79 - x, 16);
		cout << "+";
		enemyArr[79 - x][16] = '+';
		for (int j = 0; j < BOSSspeed; j++)
		{
			Sleep(1);
			p.myPlaneMove(enemyArr);
		}
		enemyBulletMove(enemyArr);
		bulletMove(myBulletArr);
		shotBOSS(myBulletArr);
	}
}
 
 
//技能1
void skillA(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int z = 0; z < 3; z++)
	{
		for (int i = width / 2 - 5; i > 2; i--)
		{
			gotoxy(i, 16);
			cout << "+";
			enemyArr[i][16] = '+';
			gotoxy((width - i - 1), 16);
			cout << "+";
			enemyArr[width - i - 1][16] = '+';
			for (int j = 0; j < BOSSspeed; j++)
			{
				Sleep(1);
				p.myPlaneMove(enemyArr);
			}
			enemyBulletMove(enemyArr);
			bulletMove(myBulletArr);
			shotBOSS(myBulletArr);
		}
	}
 
}
 
 
//技能2
void skillB(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int z = 0; z < 3; z++)
	{
		int x = rand() % 76 + 2;
		gotoxy(x, 16);
		cout << "!";
		gotoxy(79 - x, 16);
		cout << "!";
		for (int k = 0; k < 10; k++)
		{
			for (int j = 0; j < BOSSspeed; j++)
			{
				Sleep(1);
				p.myPlaneMove(enemyArr);
			}
			enemyBulletMove(enemyArr);
			bulletMove(myBulletArr);
			shotBOSS(myBulletArr);
		}
		for (int i = 16; i < height - 1; i++)
		{
			gotoxy(x, i);
			cout << "+";
			enemyArr[x][i] = '+';
			gotoxy(x + 1, i);
			cout << "+";
			enemyArr[x + 1][i] = '+';
			gotoxy(x - 1, i);
			cout << "+";
			enemyArr[x - 1][i] = '+';
			gotoxy(79 - x, i);
			cout << "+";
			enemyArr[79 - x][i] = '+';
			gotoxy(79 - x - 1, i);
			cout << "+";
			enemyArr[79 - x - 1][i] = '+';
			gotoxy(79 - x + 1, i);
			cout << "+";
			enemyArr[79 - x + 1][i] = '+';
		}
	}
}
 
//技能3
void skillC(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	int x = rand() % 6 + 37;
	gotoxy(x, 16);
	cout << "+";
	enemyArr[x][16] = '+';
	gotoxy(79 - x, 16);
	cout << "+";
	enemyArr[79 - x][16] = '+';
	p.myPlaneMove(enemyArr);
	enemyBulletMove(enemyArr);
	bulletMove(myBulletArr);
	shotBOSS(myBulletArr);
	for (int j = 0; j < 50; j++)
	{
		int dir = rand() % 2 - 1;
		x = x + dir;
		gotoxy(x, 16);
		cout << "+";
		enemyArr[x][16] = '+';
		gotoxy(79 - x, 16);
		cout << "+";
		enemyArr[79 - x][16] = '+';
		for (int j = 0; j < BOSSspeed; j++)
		{
			Sleep(1);
			p.myPlaneMove(enemyArr);
		}
		enemyBulletMove(enemyArr);
		bulletMove(myBulletArr);
		shotBOSS(myBulletArr);
	}
}
 
 
//BOSS血条
void BOSSHPcartoon()
{
	gotoxy(13, 1);
	cout << "HP:";
	gotoxy(16, 1);
	for (int i = 0; i < BOSSHP / 10; i++)
		cout << "▇";
	cout << "    ";
}
 
//射击BOSS检测
void shotBOSS(char myArr[width + 10][height])
{
	//尾部
	for (int i = 9; i < 14; i++)
	{
		if (myArr[i][4] == '*')
		{
			BOSSHP = BOSSHP - damage / 2;
			myArr[i][4] = 0;
			gotoxy(i, 4);
			cout << " ";
		}
		if (myArr[79 - i][4] == '*')
		{
			BOSSHP = BOSSHP - damage / 2;
			myArr[79 - i][4] = 0;
			gotoxy(79 - i, 4);
			cout << " ";
		}
	}
	//中后部
	for (int i = 14; i < 18; i++)
	{
		if (myArr[i][6] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][6] = 0;
			gotoxy(i, 6);
			cout << " ";
		}
		if (myArr[79 - i][6] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][6] = 0;
			gotoxy(79 - i, 6);
			cout << " ";
		}
	}
	//中前部
	for (int i = 18; i < 29; i++)
	{
		if (myArr[i][11] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][11] = 0;
			gotoxy(i, 11);
			cout << " ";
		}
		if (myArr[79 - i][11] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][11] = 0;
			gotoxy(79 - i, 11);
			cout << " ";
		}
	}
	for (int i = 27; i < 40; i++)
	{
		if (myArr[i][13] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][13] = 0;
			gotoxy(i, 13);
			cout << " ";
		}
		if (myArr[79 - i][13] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][13] = 0;
			gotoxy(79 - i, 13);
			cout << " ";
		}
	}
	//头后部
	for (int i = 31; i < 40; i++)
	{
		if (myArr[i][15] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[i][15] = 0;
			gotoxy(i, 15);
			cout << " ";
		}
		if (myArr[79 - i][15] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[79 - i][15] = 0;
			gotoxy(79 - i, 15);
			cout << " ";
		}
	}
	//头部
	for (int i = 37; i < 40; i++)
	{
		if (myArr[i][16] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[i][16] = 0;
			gotoxy(i, 16);
			cout << " ";
		}
		if (myArr[79 - i][16] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[79 - i][16] = 0;
			gotoxy(79 - i, 16);
			cout << " ";
		}
	}
	BOSSHPcartoon();
	if (BOSSHP <= 0)
		success_menu();
}
 
 
void BOSSshot(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	while (true)
	{
		int i = rand() % 4;
		switch (i)
		{
		case 0:
			keepShooting(enemyArr);
			break;
		case 1:
			skillA(enemyArr);
			break;
		case 2:
			skillB(enemyArr);
			break;
		case 3:
			skillC(enemyArr);
			break;
		}
	}
}

BOSS函数整合:

void BOSSgame()
{
	BOSS = 1;
	bullet = 1000;
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j] = 0;
				enemyArr[i - 1][j - 1] = 0;
				enemyArr[i + 1][j - 1] = 0;
				enemyArr[i][j - 1] = 0;
 
 
				gotoxy(i - 1, j - 1);
				cout << " ";
				gotoxy(i + 1, j - 1);
				cout << " ";
				gotoxy(i, j - 1);
				cout << " ";
				gotoxy(i, j);
				cout << " ";
			}
		}
 
	BOSScartoon();
	BOSSHPcartoon();
	BOSSshot(enemyArr);
}

菜单,动画的实现:

这个动画。。。嘿嘿,其实没啥学的必要,我是图省事这么写的,你们肯定有更好的办法来实现

大家看看上面的菜单就行了,可以直接看后面的main函数

//开始菜单
void start_menu()
{
	for (int i = t_height - 1; i >= t_height / 2 - 4; i--)
	{
		gotoxy(t_width / 2 - 5, i + 1);
		cout << "        ";
		gotoxy(t_width / 2 - 5, i);
		cout << "飞机大战";
		if (i < t_height - 2 - 4)
		{
			gotoxy(t_width / 2 - 6, i + 5);
			cout << "          ";
			gotoxy(t_width / 2 - 6, i + 4);
			cout << "y.进入游戏";
 
		}
		if (i < t_height - 2 - 8)
		{
			gotoxy(t_width / 2 - 6, i + 9);
			cout << "          ";
			gotoxy(t_width / 2 - 6, i + 8);
			cout << "n.退出游戏";
		}
		Sleep(300);
	}
	while (true)
	{
		if (_kbhit())
		{
			char input = _getch();
 
 
			switch (input)
			{
			case 'n':
				system("cls");
				cout << "退出成功" << endl;
				exit(0);
				break;
			case 'N':
				system("cls");
				cout << "退出成功" << endl;
				exit(0);
				break;
			case 'y':
				system("cls");
				cout << "进入游戏" << endl;
				Sleep(1000);
				system("cls");
				Game();
 
				break;
			
			case 'Y':
				system("cls");
				cout << "进入游戏" << endl;
				Sleep(1000);
				system("cls");
				Game();
 
				break;
			}
		}
		
	}
}
 
void cartoonStartMenu()
{
 
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "************";
	Sleep(1000);
	system("cls");
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "************";
	Sleep(1000);
	system("cls");
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "     **     ";
	Sleep(1000);
	system("cls");
}
 
 
//地图框架和右菜单
void game_menu()
{
	//框架
	gotoxy(0, 0);
	for (int i = 0; i < width; i++)
		cout << "#";
	gotoxy(0, height - 1);
	for (int i = 0; i < width; i++)
		cout << "#";
	for (int i = 0; i < height; i++)
	{
		gotoxy(0, i);
		cout << "#";
	}
	for (int i = 0; i < height; i++)
	{
		gotoxy(width - 1, i);
		cout << "#";
	}
 
 
	//右部菜单
	gotoxy(width + (t_width - width) / 2 - 6, 5);
	cout << "代号:NJTECH";
	gotoxy(width + (t_width - width) / 2 - 6, 7);
	cout << "得分:";
	gotoxy(width + (t_width - width) / 2 - 6, 9);
	cout << "子弹:";
	gotoxy(width + (t_width - width) / 2 - 6, 11);
	cout << "血量:";
 
	gotoxy(width, 13);
	cout << "                   **                   ";
	gotoxy(width, 14);
	cout << "                   **                   ";
	gotoxy(width, 15);
	cout << "                   **                   ";
	gotoxy(width, 16);
	cout << "                  ****                  ";
	gotoxy(width, 17);
	cout << "                 ******                 ";
	gotoxy(width, 18);
	cout << "            *  ****  ****  *            ";
	gotoxy(width, 19);
	cout << "           ******************           ";
	gotoxy(width, 20);
	cout << "          ****   ******   ****          ";
	gotoxy(width, 21);
	cout << "       **************************       ";
	gotoxy(width, 22);
	cout << "             ****      ****             ";
	gotoxy(width, 23);
	cout << "               **      **               ";
	gotoxy(width, 24);
	cout << "                *      *                ";
	//规则
	gotoxy(width + (t_width - width) / 2 - 14, 28);
	cout << "w 前进";
	gotoxy(width + (t_width - width) / 2 - 14, 30);
	cout << "s 后退";
	gotoxy(width + (t_width - width) / 2 - 14, 32);
	cout << "d 右移";
	gotoxy(width + (t_width - width) / 2 - 14, 34);
	cout << "a 左移";
	gotoxy(width + (t_width - width) / 2 - 14, 36);
	cout << "j 射击";
}
 
 
 
void cartoonGameMenu()
{
	for (int i = 0; i < height / 2; i++)
	{
		gotoxy(0, i);
		for (int j = 0; j < t_width; j++)
		{
			cout << "▇";
		}
		gotoxy(0, height - i - 1);
		for (int k = 0; k < t_width; k++)
		{
			cout << "▇";
		}
		Sleep(100);
	}
	system("cls");
	Sleep(1000);
	for (int i = 0; i < t_width; i++)
	{
		for (int j = 0; j < t_height; j++)
		{
			cout << "▇";
			if (j == t_width - 1)
				cout << endl;
		}
	}
	Sleep(1000);
	system("cls");
	Sleep(1000);
 
}
 
void BOSScartoon()
{
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	printBOSS();
}
 
void end_menu()
{
	system("cls");
	Sleep(3000);
	gotoxy(width / 2 - 8, height - 1);
	cout << "你失败了,但这不是你的过错,只是这次的英雄并不是你......";
	Sleep(300);
	for (int i = height - 2; i > 18; i--)
	{
		gotoxy(width / 2 - 8, i + 1);
		cout << "                                                        ";
		gotoxy(width / 2 - 8, i);
		cout << "你失败了,但这不是你的过错,只是这次的英雄并不是你......";
		Sleep(300);
	}
	
	Sleep(10000000);
}
 
void success_menu()
{
	for (int i = 16; i > 1; i--)
	{
		gotoxy(2, i);
		cout << "                                                                     ";
		Sleep(100);
	}
	Sleep(1000);
	gotoxy(width / 2 - 3, 2);
	cout << "游戏胜利";
	Sleep(300);
	for (int i = 3; i < 17; i++)
	{
		gotoxy(width / 2 - 3, i - 1);
		cout << "        ";
		gotoxy(width / 2 - 3, i);
		cout << "游戏胜利";
		Sleep(300);
	}
	Sleep(100000);
}
 
void printBOSS()
{
	gotoxy(0, 0);
	for (int i = 0; i < width; i++)
		cout << "#";
	gotoxy(0, height - 1);
	for (int i = 0; i < width; i++)
		cout << "#";
	for (int i = 0; i < height; i++)
	{
		gotoxy(0, i);
		cout << "#";
	}
	for (int i = 0; i < height; i++)
	{
		gotoxy(width - 1, i);
		cout << "#";
	}
	for (int i = 2; i < 16; i++)
	{
		gotoxy(37, i);
		cout << "\\ ++ /";
		if (i > 2)
		{
			gotoxy(33, i - 1);
			cout << "\\  \\  ++  /  /";
 
		}
		if (i > 3)
		{
			gotoxy(30, i - 2);
			cout << "\\ \\  \\   ++   /  / /";
		}
		if (i > 4)
		{
			gotoxy(27, i - 3);
			cout << "+++++++************+++++++";
			gotoxy(27, i - 4);
			cout << "                          ";
		}
		if (i > 5)
		{
			gotoxy(32, i - 4);
			cout << "****************";
			gotoxy(32, i - 5);
			cout << "                ";
		}
		if (i > 6)
		{
			gotoxy(18, i - 5);
			cout << "***  ***00******   ******   ******00***  ***";
			gotoxy(18, i - 6);
			cout << "                                            ";
		}
		if (i > 7)
		{
			gotoxy(19, i - 6);
			cout << "******00****   **  ****  **   ****00******";
			gotoxy(19, i - 7);
			cout << "                                          ";
		}
		if (i > 8)
		{
			gotoxy(24, i - 7);
			cout << "*****    *00*      *00*    *****";
			gotoxy(24, i - 8);
			cout << "                                ";
		}
		if (i > 9)
		{
			gotoxy(22, i - 8);
			cout << "****   ****0000* ** *0000****   ****";
			gotoxy(22, i - 9);
			cout << "                                    ";
		}
		if (i > 10)
		{
			gotoxy(23, i - 9);
			cout << "*********0000***  ***0000*********";
			gotoxy(23, i - 10);
			cout << "                                  ";
		}
		if (i > 11)
		{
			gotoxy(14, i - 10);
			cout << "*********** ************    ************ ***********";
			gotoxy(14, i - 11);
			cout << "                                                    ";
		}
		if (i > 12)
		{
			gotoxy(14, i - 11);
			cout << "********   ***  *  *  *      *  *  *  ***   ********";
			gotoxy(14, i - 12);
			cout << "                                                    ";
		}
		if (i > 13)
		{
			gotoxy(9, i - 12);
			cout << "************       ******    ****    ******       ************";
			gotoxy(9, i - 13);
			cout << "                                                              ";
		}
		Sleep(300);
	}
 
 
 
}

main函数实现:

int main()
{
	system("mode con cols=120 lines=40");
	clearCursor();
	cartoonGameMenu();
	start_menu();
	cartoonStartMenu();
	game_menu();
	BOSSgame();
}

附加:

感谢“杨某一辰”提出的建议杨某一辰的博客_CSDN博客-c++,一些有趣的东西,c领域博主杨某一辰擅长c++,一些有趣的东西,c,等方面的知识,杨某一辰关注c++,区块链,c语言,人工智能领域.https://blog.csdn.net/langhat?type=blog

以下是他提供的改进代码

#include<iostream>
#include<Windows.h>
#include<conio.h>
#include<cstdlib>
#include<time.h>
#include<stdlib.h>
#include<cmath>
 
//飞机活动大小
#define width 80
#define height 40
//窗口大小
#define t_width 120
#define t_height 40
using namespace std;
 
void gotoxy(short x, short y);
void Game();
 
void enemyAppear(char arr[width + 10][height]);
void enemyMove(char arr[width + 10][height]);
 
void bulletMove(char arr[width + 10][height]);
void BOSSgame();
void shotBOSS(char arr[width + 10][height]);
void difficulty();
 
void cartoonStartMenu();
void start_menu();
void game_menu();
void cartoonGameMenu();
void end_menu();
void success_menu();
void BOSScartoon();
void printBOSS();
 
extern int score = 0;
extern int bullet = 99999;
extern int HP = 100000;
extern int BOSSHP = 500;
extern int damage = 3;
extern int enemySpeed = 10;
extern int BOSSspeed = 15;
extern int Number = 4;
extern int BOSS = 0;
 
//清除光标
void clearCursor()
{
	HANDLE hOut;
	CONSOLE_CURSOR_INFO cur = { 1,0 };
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorInfo(hOut, &cur);
}
 
 
//使光标移动到指定位置
void gotoxy(short x, short y)
{
	HANDLE hOut;
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD pos = { x,y };
	SetConsoleCursorPosition(hOut, pos);
}
 
char enemyArr[width + 10][height] = { 0 };
char myBulletArr[width + 10][height] = { 0 };
 
//飞机图像
void printPlane(short x, short y)
{
	gotoxy(x, y);
	cout << "*";//头
	gotoxy(x, y + 1);
	cout << "*";//尾
	gotoxy(x - 1, y + 1);
	cout << "*";//左翼
	gotoxy(x + 1, y + 1);
	cout << "*";//右翼
}
 
 
class myPlane
{
public:
	//头的坐标
	short x = width / 2;
	short y = height / 2;
 
 
 
	//初始化飞机
	void initMyPlane()
	{
		printPlane(x, y);
	}
 
	//清除飞机移动前位置图像
	void clearMyplane()
	{
		gotoxy(x, y);
		cout << " ";//头
		gotoxy(x, y + 1);
		cout << " ";//尾
		gotoxy(x - 1, y + 1);
		cout << " ";//左翼
		gotoxy(x + 1, y + 1);
		cout << " ";//右翼
	}
 
 
	//射击
	void shoot(char myArr[width + 10][height])
	{
		if (bullet == 0)
			return;
		myArr[x][y - 1] = '*';
		gotoxy(x, y - 1);
		cout << "*";
		bullet--;
		gotoxy(width + (t_width - width) / 2, 9);
		cout << "   ";
		gotoxy(width + (t_width - width) / 2, 9);
		cout << bullet;
	}
 
	//飞机移动+游戏中的菜单栏功能实现
	void myPlaneMove(char arr[width + 10][height])
	{
		//判断是否有键盘操作
		if (_kbhit())
		{
			char move;
			move = _getch();
			switch (move)
			{
			case 'w':
				if (BOSS == 1)
					if (y == 16)
						break;
				//判断是否是边界
				if (y == 1)
					break;
				//清除原图像
				clearMyplane();
				y--;
				//打印新位置
				printPlane(x, y);
				break;
			case 'a':
				if (x - 1 == 1)
					break;
				clearMyplane();
				x--;
				printPlane(x, y);
				break;
			case 's':
				if (y + 1 == height - 2)
					break;
				clearMyplane();
				y++;
				printPlane(x, y);
				break;
			case 'd':
				if (x + 1 == width - 2)
					break;
				clearMyplane();
				x++;
				printPlane(x, y);
				break;
			case 'j':
				shoot(myBulletArr);
			case 'W':
				if (BOSS == 1)
					if (y == 16)
						break;
				//判断是否是边界
				if (y == 1)
					break;
				//清除原图像
				clearMyplane();
				y--;
				//打印新位置
				printPlane(x, y);
				break;
			case 'A':
				if (x - 1 == 1)
					break;
				clearMyplane();
				x--;
				printPlane(x, y);
				break;
			case 'S':
				if (y + 1 == height - 2)
					break;
				clearMyplane();
				y++;
				printPlane(x, y);
				break;
			case 'D':
				if (x + 1 == width - 2)
					break;
				clearMyplane();
				x++;
				printPlane(x, y);
				break;
            //控制射击
			case 'J':
				shoot(myBulletArr);
			}
		}
	}
};
 
myPlane p;//创捷我方飞机
 
//难度选择
void difficulty()
{
	gotoxy(t_width / 2 - 5, t_height / 2 - 4);
	cout << "1.简单模式";
	gotoxy(t_width / 2 - 5, t_height / 2);
	cout << "2.普通模式";
	gotoxy(t_width / 2 - 5, t_height / 2 + 4);
	cout << "3.困难模式";
	char choice;
	choice = _getch();
	switch (choice)
	{
	case '1':
		enemySpeed = 50;
		BOSSspeed = 25;
		HP = 1000;
		damage = 5;
		bullet = 50;
		Number = 2;
		break;
	case '2':
		enemySpeed = 10;
		BOSSspeed = 15;
		HP = 500;
		damage = 3;
		bullet = 30;
		Number = 4;
		break;
	case '3':
		enemySpeed = 8;
		BOSSspeed = 5;
		HP = 100;
		damage = 2;
		bullet = 10;
		Number = 6;
		break;
	}
 
}
 
void shotEnemy(char enemyArr[width + 10][height], char myArr[width + 10][height])
{
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (myArr[i][j] == '*' || myArr[i][j] == '@')
			{
				//碰头
				if (enemyArr[i][j - 2] == '+')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰左翼
				else if (enemyArr[i][j - 2] == 'p')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰右翼
				else if (enemyArr[i][j - 2] == 'q')
				{
					myArr[i][j] = '@';
 
					gotoxy(i, j - 1);
					cout << "*";
				}
				//碰头
				if (enemyArr[i][j - 1] == '+')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i - 1][j - 2] = 0;
					enemyArr[i + 1][j - 2] = 0;
					enemyArr[i][j - 2] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i - 1, j - 2);
					cout << " ";
					gotoxy(i + 1, j - 2);
					cout << " ";
					gotoxy(i, j - 2);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
 
				}
 
				//碰左翼
				else if (enemyArr[i][j - 1] == 'p')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i - 1][j] = 0;
					enemyArr[i - 1][j - 1] = 0;
					enemyArr[i - 2][j - 1] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i - 1, j);
					cout << " ";
					gotoxy(i - 1, j - 1);
					cout << " ";
					gotoxy(i - 2, j - 1);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
				}
 
				//碰右翼
				else if (enemyArr[i][j - 1] == 'q')
				{
					myArr[i][j] = 0;
					enemyArr[i][j - 1] = 0;
					enemyArr[i + 1][j] = 0;
					enemyArr[i + 1][j - 1] = 0;
					enemyArr[i + 2][j - 1] = 0;
 
 
					gotoxy(i, j - 1);
					cout << " ";
					gotoxy(i + 1, j);
					cout << " ";
					gotoxy(i + 1, j - 1);
					cout << " ";
					gotoxy(i + 2, j - 1);
					cout << " ";
					gotoxy(i, j);
					cout << " ";
				}
 
 
 
			}
		}
}
 
//子弹移动
void bulletMove(char myArr[width + 10][height])
{
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (myArr[i][j] == '*')
			{
				myArr[i][j] = 0;
				myArr[i][j - 1] = '*';
				gotoxy(i, j - 1);
				cout << "*";
				gotoxy(i, j);
				cout << " ";
			}
 
		}
 
	//清除触界子弹
	for (int k = 1; k < width; k++)
	{
		if (myArr[k][1] == '*')
		{
			gotoxy(k, 1);
			cout << " ";
			myArr[k][1] = 0;
			Beep(500,150);
		}
	}
}
 
//随机出现敌机
void enemyAppear(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	//随机敌机数量
	int number = rand() % 6 + Number;
	//随机敌机位置
	for (int i = 0; i < number; i++)
	{
		short x = rand() % (width - 4) + 2;
		//防止敌机重叠
		if (enemyArr[x][2] == '+' || enemyArr[x - 1][2] == '+' || enemyArr[x + 1][2] == '+' || enemyArr[x - 2][2] == '+' || enemyArr[x + 2][2] == '+')
			continue;
		short y = 2;
		enemyArr[x][y] = '+';
		enemyArr[x][y - 1] = 'T';
		enemyArr[x - 1][y - 1] = 'q';
		enemyArr[x + 1][y - 1] = 'p';
 
		gotoxy(x, y);
		cout << "+";//头
		gotoxy(x, y - 1);
		cout << "T";//尾   
		gotoxy(x - 1, y - 1);
		cout << "q";//右翼     //+++ 
		gotoxy(x + 1, y - 1);  // 0   
		cout << "p";//左翼
 
	}
}
 
void enemyMove(char enemyArr[width + 10][height])
{
	for (int i = width; i > 0; i--)
		for (int j = height - 3; j > 0; j--)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j - 1] = 0;
				enemyArr[i - 1][j - 1] = 0;
				enemyArr[i + 1][j - 1] = 0;
 
				enemyArr[i][j] = 'T';
				enemyArr[i][j + 1] = '+';
				enemyArr[i - 1][j] = 'q';
				enemyArr[i + 1][j] = 'p';
				gotoxy(i, j - 1);
				cout << " ";
				gotoxy(i - 1, j - 1);
				cout << " ";
				gotoxy(i + 1, j - 1);
				cout << " ";
				gotoxy(i, j + 1);
				cout << "+";
				gotoxy(i, j);
				cout << "T";
				gotoxy(i - 1, j);
				cout << "q";
				gotoxy(i + 1, j);
				cout << "p";
			}
		}
 
	//清除触界敌机
	for (int i = 0; i < width; i++)
	{
		if (enemyArr[i][height - 2] == '+')
		{
			enemyArr[i][height - 2] = 0;
			enemyArr[i][height - 3] = 0;
			enemyArr[i + 1][height - 3] = 0;
			enemyArr[i - 1][height - 3] = 0;
			gotoxy(i, height - 2);
			cout << " ";
			gotoxy(i - 1, height - 3);
			cout << " ";
			gotoxy(i + 1, height - 3);
			cout << " ";
			gotoxy(i, height - 3);
			cout << " ";
			score++;
		}
	}
}
 
//判断是否触碰敌机
bool judgeEnemy(short x, short y, char enemyArr[width + 10][height])
{
	if (enemyArr[x][y] == '+' || enemyArr[x][y] == 'p' || enemyArr[x][y] == 'q' || enemyArr[x - 1][y + 1] == '+' || enemyArr[x - 1][y + 1] == 'p' || enemyArr[x - 1][y + 1] == 'q'
		|| enemyArr[x + 1][y + 1] == '+' || enemyArr[x + 1][y + 1] == 'p' || enemyArr[x + 1][y + 1] == 'q' || enemyArr[x][y + 1] == '+' || enemyArr[x][y + 1] == 'p' || enemyArr[x][y + 1] == 'q')
	{
		Beep(1000,30);
		return true;
	}
	else
	{
 
		gotoxy(width + (t_width - width) / 2, 11);
		cout << HP << "    ";
		return false;
	}
}
 
void Game()
{
	//存储敌机坐标
	system("cls");
	difficulty();
	system("cls");
	cartoonStartMenu();
	game_menu();
	p.initMyPlane();
	while (true)
	{
		enemyAppear(enemyArr);
        //这里可能有点难理解,可以先把外层循环去掉只看内层循环
        //Sleep(1)是停止1ms也就是说每enemySpeed毫秒子弹,敌军移动一次
        //把外层循环加进来就是10*
        //这样写的目的是使得每一毫秒程序enemySpeed毫秒敌军出现一次都能检测是否有按键移动射击操作
		for (int i = 0; i < 10; i++)
		{
 
			for (int j = 0; j < enemySpeed; j++) {
				p.myPlaneMove(enemyArr);
				if (judgeEnemy(p.x, p.y, enemyArr))
				{
					end_menu();
				}
				Beep(750,5);
			}
			Beep(750,5);
			bulletMove(myBulletArr);
			shotEnemy(enemyArr, myBulletArr);
			enemyMove(enemyArr);
			gotoxy(width + (t_width - width) / 2, 7);
			cout << score;
            //分数大于200进入BOSS战
			if (score > 200){
				Beep(1000,300);
				Beep(250,300);
				BOSSgame();
			}
		}
	}
 
}
 
//BOSS子弹移动
void enemyBulletMove(char enemyArr[width + 10][height])
{
	for (int i = width; i > 0; i--)
		for (int j = height - 3; j > 0; j--)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j] = 0;
				enemyArr[i][j + 1] = '+';
 
				gotoxy(i, j);
				cout << " ";
 
				gotoxy(i, j + 1);
				cout << "+";
			}
		}
 
	//清除触界敌军子弹
	for (int i = 0; i < width; i++)
	{
		if (enemyArr[i][height - 2] == '+')
		{
			enemyArr[i][height - 2] = 0;
 
			gotoxy(i, height - 2);
			cout << " ";
			Beep(350,300);
		}
	}
}
 
 
//持续射击
void keepShooting(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int j = 0; j < 100; j++)
	{
		int x = rand() % 78 + 1;
		gotoxy(x, 16);
		cout << "+";
		enemyArr[x][16] = '+';
		gotoxy(79 - x, 16);
		cout << "+";
		enemyArr[79 - x][16] = '+';
		for (int j = 0; j < BOSSspeed; j++)
		{
			Sleep(1);
			p.myPlaneMove(enemyArr);
		}
		enemyBulletMove(enemyArr);
		bulletMove(myBulletArr);
		shotBOSS(myBulletArr);
		Beep(756,150);
	}
}
 
 
//技能1
void skillA(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int z = 0; z < 3; z++)
	{
		for (int i = width / 2 - 5; i > 2; i--)
		{
			gotoxy(i, 16);
			cout << "+";
			enemyArr[i][16] = '+';
			gotoxy((width - i - 1), 16);
			cout << "+";
			enemyArr[width - i - 1][16] = '+';
			for (int j = 0; j < BOSSspeed; j++)
			{
				Sleep(1);
				p.myPlaneMove(enemyArr);
			}
			enemyBulletMove(enemyArr);
			bulletMove(myBulletArr);
			shotBOSS(myBulletArr);
		}
	}
 
}
 
 
//技能2
void skillB(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	for (int z = 0; z < 3; z++)
	{
		int x = rand() % 76 + 2;
		gotoxy(x, 16);
		cout << "!";
		gotoxy(79 - x, 16);
		cout << "!";
		for (int k = 0; k < 10; k++)
		{
			for (int j = 0; j < BOSSspeed; j++)
			{
				Sleep(1);
				p.myPlaneMove(enemyArr);
			}
			enemyBulletMove(enemyArr);
			bulletMove(myBulletArr);
			shotBOSS(myBulletArr);
		}
		for (int i = 16; i < height - 1; i++)
		{
			gotoxy(x, i);
			cout << "+";
			enemyArr[x][i] = '+';
			gotoxy(x + 1, i);
			cout << "+";
			enemyArr[x + 1][i] = '+';
			gotoxy(x - 1, i);
			cout << "+";
			enemyArr[x - 1][i] = '+';
			gotoxy(79 - x, i);
			cout << "+";
			enemyArr[79 - x][i] = '+';
			gotoxy(79 - x - 1, i);
			cout << "+";
			enemyArr[79 - x - 1][i] = '+';
			gotoxy(79 - x + 1, i);
			cout << "+";
			enemyArr[79 - x + 1][i] = '+';
		}
	}
}
 
//技能3
void skillC(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	int x = rand() % 6 + 37;
	gotoxy(x, 16);
	cout << "+";
	enemyArr[x][16] = '+';
	gotoxy(79 - x, 16);
	cout << "+";
	enemyArr[79 - x][16] = '+';
	p.myPlaneMove(enemyArr);
	enemyBulletMove(enemyArr);
	bulletMove(myBulletArr);
	shotBOSS(myBulletArr);
	for (int j = 0; j < 50; j++)
	{
		int dir = rand() % 2 - 1;
		x = x + dir;
		gotoxy(x, 16);
		cout << "+";
		enemyArr[x][16] = '+';
		gotoxy(79 - x, 16);
		cout << "+";
		enemyArr[79 - x][16] = '+';
		for (int j = 0; j < BOSSspeed; j++)
		{
			Sleep(1);
			p.myPlaneMove(enemyArr);
		}
		enemyBulletMove(enemyArr);
		bulletMove(myBulletArr);
		shotBOSS(myBulletArr);
	}
}
 
 
//BOSS血条
void BOSSHPcartoon()
{
	gotoxy(13, 1);
	cout << "HP:";
	gotoxy(16, 1);
	for (int i = 0; i < BOSSHP / 10; i++)
		cout << "▇";
	cout << "    ";
}
 
//射击BOSS检测
void shotBOSS(char myArr[width + 10][height])
{
	//尾部
	for (int i = 9; i < 14; i++)
	{
		if (myArr[i][4] == '*')
		{
			BOSSHP = BOSSHP - damage / 2;
			myArr[i][4] = 0;
			gotoxy(i, 4);
			cout << " ";
		}
		if (myArr[79 - i][4] == '*')
		{
			BOSSHP = BOSSHP - damage / 2;
			myArr[79 - i][4] = 0;
			gotoxy(79 - i, 4);
			cout << " ";
		}
	}
	//中后部
	for (int i = 14; i < 18; i++)
	{
		if (myArr[i][6] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][6] = 0;
			gotoxy(i, 6);
			cout << " ";
		}
		if (myArr[79 - i][6] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][6] = 0;
			gotoxy(79 - i, 6);
			cout << " ";
		}
	}
	//中前部
	for (int i = 18; i < 29; i++)
	{
		if (myArr[i][11] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][11] = 0;
			gotoxy(i, 11);
			cout << " ";
		}
		if (myArr[79 - i][11] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][11] = 0;
			gotoxy(79 - i, 11);
			cout << " ";
		}
	}
	for (int i = 27; i < 40; i++)
	{
		if (myArr[i][13] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[i][13] = 0;
			gotoxy(i, 13);
			cout << " ";
		}
		if (myArr[79 - i][13] == '*')
		{
			BOSSHP = BOSSHP - damage;
			myArr[79 - i][13] = 0;
			gotoxy(79 - i, 13);
			cout << " ";
		}
	}
	//头后部
	for (int i = 31; i < 40; i++)
	{
		if (myArr[i][15] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[i][15] = 0;
			gotoxy(i, 15);
			cout << " ";
		}
		if (myArr[79 - i][15] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[79 - i][15] = 0;
			gotoxy(79 - i, 15);
			cout << " ";
		}
	}
	//头部
	for (int i = 37; i < 40; i++)
	{
		if (myArr[i][16] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[i][16] = 0;
			gotoxy(i, 16);
			cout << " ";
		}
		if (myArr[79 - i][16] == '*')
		{
			BOSSHP = BOSSHP - 2 * damage;
			myArr[79 - i][16] = 0;
			gotoxy(79 - i, 16);
			cout << " ";
		}
	}
	BOSSHPcartoon();
	if (BOSSHP <= 0)
		success_menu();
}
 
 
void BOSSshot(char enemyArr[width + 10][height])
{
	srand((unsigned int)time(NULL));
	while (true)
	{
		int i = rand() % 4;
		switch (i)
		{
		case 0:
			keepShooting(enemyArr);
			break;
		case 1:
			skillA(enemyArr);
			break;
		case 2:
			skillB(enemyArr);
			break;
		case 3:
			skillC(enemyArr);
			break;
		}
	}
}
 
void BOSSgame()
{
	BOSS = 1;
	bullet = 1000;
	for (int i = 2; i < width; i++)
		for (int j = 2; j < height; j++)
		{
			if (enemyArr[i][j] == '+')
			{
				enemyArr[i][j] = 0;
				enemyArr[i - 1][j - 1] = 0;
				enemyArr[i + 1][j - 1] = 0;
				enemyArr[i][j - 1] = 0;
 
 
				gotoxy(i - 1, j - 1);
				cout << " ";
				gotoxy(i + 1, j - 1);
				cout << " ";
				gotoxy(i, j - 1);
				cout << " ";
				gotoxy(i, j);
				cout << " ";
			}
		}
 
	BOSScartoon();
	BOSSHPcartoon();
	BOSSshot(enemyArr);
}
 
//开始菜单
void start_menu()
{
	for (int i = t_height - 1; i >= t_height / 2 - 4; i--)
	{
		gotoxy(t_width / 2 - 5, i + 1);
		cout << "        ";
		gotoxy(t_width / 2 - 5, i);
		cout << "飞机大战";
		if (i < t_height - 2 - 4)
		{
			gotoxy(t_width / 2 - 6, i + 5);
			cout << "          ";
			gotoxy(t_width / 2 - 6, i + 4);
			cout << "y.进入游戏";
 
		}
		if (i < t_height - 2 - 8)
		{
			gotoxy(t_width / 2 - 6, i + 9);
			cout << "          ";
			gotoxy(t_width / 2 - 6, i + 8);
			cout << "n.退出游戏";
		}
		Sleep(300);
	}
	while (true)
	{
		if (_kbhit())
		{
			char input = _getch();
 
 
			switch (input)
			{
			case 'n':
				system("cls");
				cout << "退出成功" << endl;
				exit(0);
				break;
			case 'N':
				system("cls");
				cout << "退出成功" << endl;
				exit(0);
				break;
			case 'y':
				system("cls");
				cout << "进入游戏" << endl;
				Sleep(1000);
				system("cls");
				Game();
 
				break;
			
			case 'Y':
				system("cls");
				cout << "进入游戏" << endl;
				Sleep(1000);
				system("cls");
				Game();
 
				break;
			}
		}
		
	}
}
 
void cartoonStartMenu()
{
 
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "************";
	Sleep(1000);
	system("cls");
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "           *";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "************";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "*           ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "************";
	Sleep(1000);
	system("cls");
	gotoxy(t_width / 2 - 8, t_height / 2 - 6);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 5);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 4);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 3);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 2);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 - 1);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 1);
	cout << "     **     ";
	gotoxy(t_width / 2 - 8, t_height / 2 + 2);
	cout << "     **     ";
	Sleep(1000);
	system("cls");
}
 
 
//地图框架和右菜单
void game_menu()
{
	//框架
	gotoxy(0, 0);
	for (int i = 0; i < width; i++)
		cout << "#";
	gotoxy(0, height - 1);
	for (int i = 0; i < width; i++)
		cout << "#";
	for (int i = 0; i < height; i++)
	{
		gotoxy(0, i);
		cout << "#";
	}
	for (int i = 0; i < height; i++)
	{
		gotoxy(width - 1, i);
		cout << "#";
	}
 
 
	//右部菜单
	gotoxy(width + (t_width - width) / 2 - 6, 5);
	cout << "代号:NJTECH";
	gotoxy(width + (t_width - width) / 2 - 6, 7);
	cout << "得分:";
	gotoxy(width + (t_width - width) / 2 - 6, 9);
	cout << "子弹:";
	gotoxy(width + (t_width - width) / 2 - 6, 11);
	cout << "血量:";
 
	gotoxy(width, 13);
	cout << "                   **                   ";
	gotoxy(width, 14);
	cout << "                   **                   ";
	gotoxy(width, 15);
	cout << "                   **                   ";
	gotoxy(width, 16);
	cout << "                  ****                  ";
	gotoxy(width, 17);
	cout << "                 ******                 ";
	gotoxy(width, 18);
	cout << "            *  ****  ****  *            ";
	gotoxy(width, 19);
	cout << "           ******************           ";
	gotoxy(width, 20);
	cout << "          ****   ******   ****          ";
	gotoxy(width, 21);
	cout << "       **************************       ";
	gotoxy(width, 22);
	cout << "             ****      ****             ";
	gotoxy(width, 23);
	cout << "               **      **               ";
	gotoxy(width, 24);
	cout << "                *      *                ";
	//规则
	gotoxy(width + (t_width - width) / 2 - 14, 28);
	cout << "w 前进";
	gotoxy(width + (t_width - width) / 2 - 14, 30);
	cout << "s 后退";
	gotoxy(width + (t_width - width) / 2 - 14, 32);
	cout << "d 右移";
	gotoxy(width + (t_width - width) / 2 - 14, 34);
	cout << "a 左移";
	gotoxy(width + (t_width - width) / 2 - 14, 36);
	cout << "j 射击";
}
 
 
 
void cartoonGameMenu()
{
	for (int i = 0; i < height / 2; i++)
	{
		gotoxy(0, i);
		for (int j = 0; j < t_width; j++)
		{
			cout << "▇";
		}
		gotoxy(0, height - i - 1);
		for (int k = 0; k < t_width; k++)
		{
			cout << "▇";
		}
		Sleep(100);
	}
	system("cls");
	Sleep(1000);
	for (int i = 0; i < t_width; i++)
	{
		for (int j = 0; j < t_height; j++)
		{
			cout << "▇";
			if (j == t_width - 1)
				cout << endl;
		}
	}
	Sleep(1000);
	system("cls");
	Sleep(1000);
 
}
 
void BOSScartoon()
{
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "****";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "****";
	}
	Sleep(1000);
	for (int i = 0; i < 9; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 - 8 + i);
		cout << "    ";
	}
	for (int i = 0; i < 3; i++)
	{
		gotoxy(width / 2 - 1, t_height / 2 + 2 + i);
		cout << "    ";
	}
	Sleep(1000);
	printBOSS();
}
 
void end_menu()
{
	system("cls");
	Sleep(3000);
	gotoxy(width / 2 - 8, height - 1);
	cout << "你失败了,但这不是你的过错,只是这次的英雄并不是你......";
	Sleep(300);
	for (int i = height - 2; i > 18; i--)
	{
		gotoxy(width / 2 - 8, i + 1);
		cout << "                                                        ";
		gotoxy(width / 2 - 8, i);
		cout << "你失败了,但这不是你的过错,只是这次的英雄并不是你......";
		Sleep(300);
	}
	
	Sleep(10000000);
}
 
void success_menu()
{
	for (int i = 16; i > 1; i--)
	{
		gotoxy(2, i);
		cout << "                                                                     ";
		Sleep(100);
	}
	Sleep(1000);
	gotoxy(width / 2 - 3, 2);
	cout << "游戏胜利";
	Sleep(300);
	for (int i = 3; i < 17; i++)
	{
		gotoxy(width / 2 - 3, i - 1);
		cout << "        ";
		gotoxy(width / 2 - 3, i);
		cout << "游戏胜利";
		Sleep(300);
	}
	Sleep(100000);
}
 
void printBOSS()
{
	gotoxy(0, 0);
	for (int i = 0; i < width; i++)
		cout << "#";
	gotoxy(0, height - 1);
	for (int i = 0; i < width; i++)
		cout << "#";
	for (int i = 0; i < height; i++)
	{
		gotoxy(0, i);
		cout << "#";
	}
	for (int i = 0; i < height; i++)
	{
		gotoxy(width - 1, i);
		cout << "#";
	}
	for (int i = 2; i < 16; i++)
	{
		gotoxy(37, i);
		cout << "\\ ++ /";
		if (i > 2)
		{
			gotoxy(33, i - 1);
			cout << "\\  \\  ++  /  /";
 
		}
		if (i > 3)
		{
			gotoxy(30, i - 2);
			cout << "\\ \\  \\   ++   /  / /";
		}
		if (i > 4)
		{
			gotoxy(27, i - 3);
			cout << "+++++++************+++++++";
			gotoxy(27, i - 4);
			cout << "                          ";
		}
		if (i > 5)
		{
			gotoxy(32, i - 4);
			cout << "****************";
			gotoxy(32, i - 5);
			cout << "                ";
		}
		if (i > 6)
		{
			gotoxy(18, i - 5);
			cout << "***  ***00******   ******   ******00***  ***";
			gotoxy(18, i - 6);
			cout << "                                            ";
		}
		if (i > 7)
		{
			gotoxy(19, i - 6);
			cout << "******00****   **  ****  **   ****00******";
			gotoxy(19, i - 7);
			cout << "                                          ";
		}
		if (i > 8)
		{
			gotoxy(24, i - 7);
			cout << "*****    *00*      *00*    *****";
			gotoxy(24, i - 8);
			cout << "                                ";
		}
		if (i > 9)
		{
			gotoxy(22, i - 8);
			cout << "****   ****0000* ** *0000****   ****";
			gotoxy(22, i - 9);
			cout << "                                    ";
		}
		if (i > 10)
		{
			gotoxy(23, i - 9);
			cout << "*********0000***  ***0000*********";
			gotoxy(23, i - 10);
			cout << "                                  ";
		}
		if (i > 11)
		{
			gotoxy(14, i - 10);
			cout << "*********** ************    ************ ***********";
			gotoxy(14, i - 11);
			cout << "                                                    ";
		}
		if (i > 12)
		{
			gotoxy(14, i - 11);
			cout << "********   ***  *  *  *      *  *  *  ***   ********";
			gotoxy(14, i - 12);
			cout << "                                                    ";
		}
		if (i > 13)
		{
			gotoxy(9, i - 12);
			cout << "************       ******    ****    ******       ************";
			gotoxy(9, i - 13);
			cout << "                                                              ";
		}
		Sleep(300);
	}
 
 
 
}
 
int main()
{
	system("mode con cols=120 lines=40");
	clearCursor();
	cartoonGameMenu();
	start_menu();
	cartoonStartMenu();
	game_menu();
	BOSSgame();
}

 文章来源地址https://www.toymoban.com/news/detail-453330.html

到了这里,关于无任何格外需求的命令行C++飞机大战,内含BOSS,动画,万行代码!免费奉上!的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • JavaScript实现飞机发射子弹详解(内含源码)

    文本主要讲解如何利用JavaScript实现飞机发射子弹,实现过程以及源码讲解。实现效果图如下: 首先,找到飞机和子弹的UI图,gif图最好,这里我用的是jpg图。 飞机: 子弹: 2.把这两个UI图放在代码文件夹中 3.创建初始子弹数和飞机的img,这里我创建的是十个子弹和一架飞机

    2024年02月04日
    浏览(39)
  • 【JAVA】飞机大战

    代码和图片放在这个地址了: https://gitee.com/r77683962/fighting/tree/master 20231016: 1、原来画面比较闪烁,使用双缓冲解决了; 2、当前服务端和客户端可以分别操作不同友方飞机; 3、日志打印自己定义了下格式; 20231003: 1、添加背景音乐; 20231001: 1、现在子弹打中飞机,飞机

    2024年02月08日
    浏览(40)
  • 【c语言】飞机大战终

    效果演示

    2024年02月03日
    浏览(35)
  • 【c语言】飞机大战(1)

    提前准备好游戏要的素材,可以到爱给网去找,飞机大战我们需要的是一个我方战机图片,一个背景图,三个敌方战机的图,我方战机的图片,敌方战机的图片,并且将图片和.cpp放在同一文件夹下. 这里创建.cpp的文件是因为要用到图形库,所以创建.cpp的文件,然后图片格式

    2024年02月04日
    浏览(32)
  • scratch飞机大战

    今天scratch作品是飞机大战。 我们做一个基础版的飞机大战,要实现的操作有:我们的飞机可以按左右键进行左右移动,但是不能上下移动,然后飞机一直在发射子弹,如果子弹碰到下落的敌机就可以获得得分,如果被敌机碰到了就算失败,游戏结束。 首先第一步,我们要从

    2024年02月09日
    浏览(62)
  • QT实现飞机大战-2

    1.制作子弹类 创建子弹文件和类 添加子弹类中的成员函数和成员属性 实现成员函数 测试子弹 1.1创建子弹文件夹和类 创建Bullet类以及生成对应的文件 创建好后生成bullet.h 和 bullet.cpp两个文件 1.2添加子弹的成员函数和成员属性 战机发射子弹,子弹发射后会向上移动,移动到地

    2024年01月22日
    浏览(39)
  • 飞机大战python代码

    下面附有源代码,一个简单运用python的应用。 图片可自己自由调配 部分模块需要去从python的软件包去下载,可以去从清华和北大还有阿里的云仓库中获取镜像链接,下载速度会快点。 源代码如下并有详细注释:

    2024年02月03日
    浏览(29)
  • python实现飞机大战

    2024年03月24日
    浏览(48)
  • python学习-飞机大战

    一、pygame正确安装 1.安装:pip install pygame 2.验证安装:python -m pygame.examples.aliens;安装ok即会出现如下图所示动画 二、使用pygame创建图像窗口 1.游戏的初始化和退出;要使用pygame提供的所有功能之前,必须先调用init方法;在游戏结束,需要调用quit方法 2.在游戏中,所有可见的

    2024年02月11日
    浏览(75)
  • Python飞机大战(完整版)

    简介:一共分为2个py文件,分别是主类、和精灵类 飞机大战图片地址:链接: https://pan.baidu.com/s/18T6n9JFIDxBqYX9CnHi7ZQ  密码: tqbr 注释:项目启动后如果报libpng warning: iCCP: known incorrect sRGB profile无须处理,不会影响项目和代码,视觉洁癖可以直接百度搜索这个错误提示,网上有解

    2024年02月12日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包