Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Air Combat Game with C language

Shulou Source: shulou.com Published: 2022-05-31 17:14:11 09月29日 Update

This article introduces the knowledge of "how to realize air combat games in C language". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Project description and results presentation

Project description: improvements have been made in previous procedures.

For example, multiple bullets can be fired

There can be multiple enemy planes.

Aircraft Wars version 1.0

Aircraft Wars version 2.0

Now this version is version 3.0, and the functions of this version are basically perfect.

The effect picture is as follows:

Second, fire multiple bullets

The code is as follows:

# include#include#include#include#define High 25 / / size of the game # define Width 50 High / Global variable int position_x,position_y;// aircraft location int canvas [High] [Width] = {0} / / two-dimensional array stores the corresponding element / / 0 in the game canvas, space 1, aircraft 2, bullet 3, enemy plane void gotoxy (int xmagin int y) / / move the cursor to the (XMagery y) position {HANDLE handle=GetStdHandle (STD_OUTPUT_HANDLE); COORD pos; pos.X=x; pos.Y=y; SetConsoleCursorPosition (handle,pos);} void startup () / / initialization of data {position_x=High/2; position_y=Width/2 Canvas [position _ x] [position_y] = 1;} void show () / / display screen {int iLING j; gotoxy (0P0); / / move the cursor to the origin position, and redraw the screen for (iDiver0posi) below.

Tags: Bullet position enemy aircraft input user aircraft move update output space menu launch cursor related data screen score effect effect graph array Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Apple Microsoft vpn