以下是一个简单的C语言打飞机游戏的源代码示例:
```c
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#define WIDTH 20
#define HEIGHT 15
int x, y; // 飞机的坐标
int bulletX, bulletY; // 子弹的坐标
int enemyX, enemyY; // 敌机的坐标
int score; // 得分
void gotoxy(int x, int y) {
COORD pos = {x, y};
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, pos);
}
void hideCursor() {
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void startup() {
x = WIDTH / 2;
y = HEIGHT - 1;
bulletX = x;
bulletY = y - 1;
enemyX = rand() % WIDTH;
enemyY = 0;
score = 0;
}
void show() {

7678

被折叠的 条评论
为什么被折叠?



