The first lesson on aircraft procedures

Source: Internet
Author: User

1 C Language Program Basic statement to complete the function of the experience (combined with aircraft games or other software)

The data output includes the character output function Putchar () and the format output function printf (), the data input includes the character input function GetChar () and the format input function scanf ()

Aircraft software default:printf ("\ n error, please re-select ... \ n");

void print (int [][n]);//Output function

void Movebul (int [][n]);//bullet Move function

void Movepla (int [][n]);//enemy Movement function

void setting (void);//Set function

void menu (void);//Menu function

These are the first panels to start with and the functional design if the output error re-entered like the above default.printf and so on

2 Aircraft games (or other software) how is the basic C language statement used in last semester's study?

First, determine the structure is the sequential structure selection structure cycle structure I think the three structures here have some embodiment, such as want to adjust the speed of the aircraft rintf ("\ n Flight speed: 1. Fast 2.3. Slow >>");

Switch (Getche ())

{

Case ' 1 ': speed=2;

Break

Case ' 2 ': speed=3;

Break

And then, like printf scanf, this set of break case, these are causal relationships.




3 analysis of the structure of aircraft games (or other software).


1) has the main menu interface, can let the user choose Start, exit, difficulty level, view user integration function;


2) The aircraft can pass a, S, D, W or up or down keys to control the direction of movement, using the space bar to launch bullets;


3) The screen randomly appears from top to bottom of the enemy bullets;


4) When hitting the enemy bullets, the points plus 1;


This program can also adjust the speed of the bullet plane speed, etc.

The following is the source code for the aircraft program:

#include

#include

#include

#include

#define N 35

void print (int [][n]);//Output function

void Movebul (int [][n]);//bullet Move function

void Movepla (int [][n]);//enemy Movement function

void setting (void);//Set function

void menu (void);//Menu function

int scr[22][n]={0},pl=9,width=24,speed=3,density=30,score=0,death=0;//Global Variables: interface, my machine initial position, interface width, enemy speed, enemy plane density, score, death

Main (void)

{

menu ();

int i=0,j=0;

Scr[21][pl]=1;

scr[0][5]=3;

while (1) {if (Kbhit ()) switch (Getch ())//control move around and enter menu

{case ' a ': Case ' a ': if (pl>0) scr[21][pl]=0,scr[21][--pl]=1;break;

Case ' d ': Case ' d ': if (pl<22;i++) {a[i][width-1]=4;

for (j=0;j<22;i++)

for (j=0;j=0;i--)//from the last line up is to avoid the enemy aircraft directly rushed to the group.

for (j=0;j> ");

Switch (Getche ())

{

Case ' 1 ': width=34;break;

Case ' 2 ': width=24;break;

default:printf ("\ n error, please re-select ... \ n");

Sw=1;

}

}

while (SW);

Do

{

sw=0;

printf ("\ n Please select enemy aircraft density: 1.2. Medium 3. Small >>");

Switch (Getche ())

{

Case ' 0 ':d ensity=10;

Break

Case ' 1 ':d ensity=20;

Break;case ' 2 ':d ensity=30;

Break;case ' 3 ':d ensity=40;break;

default:printf ("\ n error, please re-select ... \ n");

Sw=1;

}

}

while (SW);

Do

{

sw=0;

printf ("\ nthe enemy aircraft speed: 1. Fast 2.3. Slow >>");

Switch (Getche ())

{

Case ' 1 ': speed=2;

Break

Case ' 2 ': speed=3;

Break

Case ' 3 ': speed=4;

Break

default:printf ("\ n error, please re-select ... \ n");

Sw=1;

}

}

while (SW);

for (i=0;i<22;i++)

for (j=0;j<45;j++)

scr[i][j]=0;

Scr[21][pl=9]=1;

printf ("\ n Press any key to save ...");

Getch ();

}

void menu (void)

{

printf ("Description: Press a D to control my flight, W fired bullets \ n set: Please press esc\n to start the game: any key \ n by Yan_xu");

if (Getch () ==27) setting ();

}


The first lesson on aircraft procedures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.