《打飞机》
2026-03-18 21:23:30
发布于:江苏
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <ctime>
using namespace std;
int w = 40;
int h = 20;
int px,py;
int bx,by;
int ex,ey;
bool b;
int s;
bool g;
void gotoxy(int x,int y){
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(std_output_handle),pos);
}
void init(){
g = false;
px = w / 2;
py = h - 2;
b = false;
ex = rand() % (w - 2) + 1;
ey = 1;
s = 0;
}
void draw(){
gotoxy(0,0);
for(int i = 0; i < w; i++){
cout << "-";
}
cout << "\n";
for(int y = 1; y < h; y++){
for(int x = 0; x < h; x++){
if(x == 0 || x == w - 1){
cout << "|";
}else if(x == px && y == py){
cout << "A";
}else if(x == ex && y == ey){
cout << "O";
}else if(x == bx && y == by){
cout << "|";
}else{
cout << " ";
}
}
cout << "\n";
}
for(int i = 0; i < w; i++){
cout << "-";
}
cout << "\n";
cout << "得分:" << s << " 控制: A左 D右 W发射子弹 ESC退出" << "\n";
}
int main(){
return 0;
}
宝子们可以放在Dev里面。
喜欢的话点个赞吧。

全部评论 1
炸坦克
昨天 来自 重庆
1



















有帮助,赞一个