C语言实现飞机大战

这篇文章主要为大家详细介绍了C语言实现飞机大战,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了C语言实现飞机大战的具体代码,供大家参考,具体内容如下

IiBzcmM9

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<Windows.h>

int score = 0;
int plane_col, plane_row;//·É»úλÖÃ
int bullet_col,bullet_row;//×Óµ¯µÄλÖÃ
int area_height, area_width;//ÓÎÏ·ÇøÓò  0-n-1
int enemy_col, enemy_row;
int enemy_vh, enemy_vv;
int a[100][100] = { 0 };

void gotoxy(int x, int y) {//ˢР
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;
    pos.X = x;
    pos.Y = y;
    SetConsoleCursorPosition(handle, pos);
}
void HideCursor() {
    CONSOLE_CURSOR_INFO cursor_info = { 1,0 };
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}

void startup()//³õʼ»¯ 
{
    area_height = 20;
    area_width = 30;

    plane_col = 14;
    plane_row = 10;
    
    bullet_col = 0;
    bullet_row = -1;

    enemy_col = rand() % area_width;
    enemy_row = 0;
    enemy_vh = 0;
    enemy_vv = 1;
}

//int[][] planeArray() {
//    
//    a[plane_col][plane_row] = 1;
//    for (int i = plane_col - 2; i < plane_col + 2; i++)
//        a[i][plane_row + 1] = 1;
//    a[plane_col - 1][plane_row + 2] = 1; a[plane_col + 1][plane_row + 2] = 1;
//
//    return a;
/

本文标题为:C语言实现飞机大战