这是一个最简单的飞机大战游戏,只涉及到少量的c语法知识,理解起来不难。
需要使用大量全局变量,重点把握如何正确使用全局变量
采用devc++编写,该编译软件可完美运行
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
#define console 20
int width,high,position_x,position_y,bullet_x,bullet_y,score;
int enemy_x,enemy_y,enemy_x1,enemy_y1;
void updatewithoutinput();
void updatewithinput();
void startup();
void show();
void gotoxy(int x,int y);//需要调用windows.h里面的函数定义该函数
void hidecursor();//同上
int main(void){
hidecursor();//隐藏光标
startup();
while(1){
show();
updatewithoutinput();
updatewithinput();
}
return 0;
}
void hidecursor(){
//隐藏光标
CONSOLE_CURSOR_INFO cursor_info={
1,0};//第二个值为0表示隐藏光标
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void gotoxy(int x,int y){