• 大小: 0.01M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-13
  • 语言: C/C++
  • 标签: 打飞机  

资源简介

较简单,游戏是靠躲,无法攻击

资源截图

代码片段和文件信息


#include
#include
#include
#include
#include
using namespace std;
typedef struct frame{
COORD position[2];
int flag;
}frame; 
void SetPos(COORD a){ 
HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out a);
}
void SetPos(int i int j){
COORD pos={i j};
SetPos(pos);
}
void HideCursor(){
CONSOLE_CURSOR_INFO cursor_info = {1 0}; 
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE) &cursor_info);
}
void drawRow(int y int x1 int x2 char ch){
SetPos(x1y);
for(int i = 0; i <= (x2-x1); i++)
cout<}
void drawRow(COORD a COORD b char ch){
if(a.Y == b.Y)
drawRow(a.Y a.X b.X ch);
else{
SetPos(0 25);
cout<<“error code 01:无法填充行,因为两个坐标的纵坐标(x)不相等“;
system(“pause“);
}
}
void drawCol(int x int y1 int y2 char ch){
int y=y1;
while(y!=y2+1){
SetPos(x y);
cout< y++;
}
}
void drawCol(COORD a COORD b char ch){
if(a.X == b.X)
drawCol(a.X a.Y b.Y ch);
else{
SetPos(0 25);
cout<<“error code 02:无法填充列,因为两个坐标的横坐标(y)不相等“;
system(“pause“);
}
}
void drawframe(COORD a COORD  b char row char col){
drawRow(a.Y a.X+1 b.X-1 row);
drawRow(b.Y a.X+1 b.X-1 row);
drawCol(a.X a.Y+1 b.Y-1 col);
drawCol(b.X a.Y+1 b.Y-1 col);

void drawframe(int x1 int y1 int x2 int y2 char row char col){
COORD a={x1 y1};
COORD b={x2 y2};
drawframe(a b row col);

void drawframe(frame frame char row char col){
COORD a = frame.position[0];
COORD b = frame.position[1];
drawframe(a b row col);
}
void drawPlaying(){
drawframe(0 0 48 24 ‘=‘ ‘|‘);
drawframe(49 0 79 4 ‘-‘ ‘|‘);
drawframe(49 4 79 9 ‘-‘ ‘|‘);
drawframe(49 9 79 20 ‘-‘ ‘|‘);
drawframe(49 20 79 24 ‘-‘ ‘|‘);
SetPos(52 6);
cout<<“得分:“;
SetPos(52 7);
cout<<“称号:“;
SetPos(5210);
cout<<“操作方式:“;
SetPos(5212);
cout<<“  asdw 控制战机移动。“;
SetPos(5214);
cout<<“  p 暂停游戏。“;
SetPos(5216);
cout<<“  e 退出游戏。“;
}
int random(int a int b){
int c=(rand() % (a-b))+ a;
return c;
}
COORD random(COORD a COORD b){
int x=random(a.X b.X);
int y=random(a.Y b.Y);
COORD c={x y};
return c;
}
bool  judgeCoordInframe(frame frame COORD spot){
if(spot.X>=frame.position[0].X)
if(spot.X<=frame.position[1].X)
if(spot.Y>=frame.position[0].Y)
if(spot.Y<=frame.position[0].Y)
return true;
return false;
}
void printCoord(COORD a){
cout<<“( “<}
void printframeCoord(frame a){
printCoord(a.position[0]);
cout<<“ - “;
printCoord(a.position[1]);
}
int drawMenu(){
SetPos(30 1);
cout<<“P l a n e  W a r“;
drawRow(3 0 79 ‘-‘);
drawRow(5 0 79 ‘-‘);
SetPos(28 4);
cout<<“w 和 s 选择, k 确定“;
SetPos(15 11);
cout<<“1. 简单的敌人“;
SetPos(15 13);
cout<<“2. 冷酷的敌人“;
drawRow(20 0 79 ‘-‘);
drawRow(22 0 79 ‘-‘);
SetPos(47 11);
cout<<“简单的敌人:“;
SetPos(51 13);
cout<<“简单敌人有着较慢的移动速度。“;

评论

共有 条评论