1、#include#include#include#include#includeusing namespace std;/打飞机源码亲测可用/ all the structures =*/typedef struct FrameCOORD position2;int flag;Frame;/*= all the functions =*/void SetPos(COORD a)/ set cursor HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(out, a);void SetPos(int i, in
2、t j)/ set cursorCOORD pos=i, j;SetPos(pos);void HideCursor()CONSOLE_CURSOR_INFO cursor_info = 1, 0; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), /把第 y 行,x1, x2) 之间的坐标填充为 chvoid drawRow(int y, int x1, int x2, char ch)SetPos(x1,y);for(int i = 0; i =frame.position0.X)if(spot.X=frame.position0.
3、Y)if(spot.Y“;drawFrame(45, 9, 79, 17, =, |);while(1) if( _kbhit() )char x=_getch();switch (x)case w :if( j = 13)SetPos(12, j);cout“;SetPos(51, 13);cout“;SetPos(51, 13);cout= rank )flag_enemy = 0;/* 输出得分 */printScore();void Game:GameOver()system(“cls“);COORD p1=28,9;COORD p2=53,15;drawFrame(p1, p2, =
4、, |);SetPos(36,12);string str=“Game Over!“;for(int i=0; istr.size(); i+)Sleep(80);coutstri;Sleep(1000);system(“cls“);drawFrame(p1, p2, =, |);SetPos(31, 11);cout“击落敌机:“score/5“ 架“;SetPos(31, 12);cout“得 分:“score;SetPos(31, 13);cout“获得称号:“title;SetPos(30, 16);Sleep(1000);cout“继续? 是(y)| 否(n)“;as:char x=
5、_getch();if (x = n)exit(0);else if (x = y)system(“cls“);Game game;int a = drawMenu();if(a = 2)game.rank = 20;system(“cls“);drawPlaying();game.Playing();else goto as;/*= the main function =*/int main()/游戏准备srand(int)time(0); /随机种子HideCursor(); /隐藏光标Game game;int a = drawMenu();if(a = 2)game.rank = 20;system(“cls“);drawPlaying();game.Playing();