1.実験プロジェクト名
航空機ゲーム
2.機能の説明パイロットプロジェクト
の新しい弾丸を含むゲーム機を、達成するために、敵の動きは、敵を打つ、画面がクリアされます。
3.プロジェクトのモジュールが導入されて
明確な画面を
void HideCuresor()
{
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void gotoxy(int x,int y)
{
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X=x;
pos.Y=y;
SetConsoleCursorPosition(handle,pos);
}
数据初始化
void startup()
{
high=100;
width=120;
pos_x=high/2;
pos_y=width/2;
bul_x=-2;
bul_y=pos_y;
ene_x=0;
ene_y=pos_y;
score=0;
}
实现子弹
void show()
{
gotoxy(0,0);
int i,j;
for(i=0;i<high;i++)
{
for(j=0;j<width;j++)
{
if((i==pos_x)&&(j==pos_y))
printf("*");
else if((i==ene_x)&&(j==ene_y))
printf("@");
else if((i==bul_x)&&(j==bul_y))
printf("|");
else
printf(" ");
}
printf("\n");
}
printf("得分:%d\n",score);
}
敵の動きは、スコアを打ちます
void updateWithoutInput()
{
if(bul_x>-1)
bul_x--;
if((bul_x==ene_x)&&(bul_y==ene_y))
{
score++;
ene_x=-1;
ene_y=rand()%width;
bul_x=-2;
}
if(ene_x>high)
{
ene_x=-1;
ene_y=rand()%width;
}
static int speed=0;
if(speed<10)
speed++;
if(speed==10)
{
ene_x++;
speed=0;
}
}
コントロール弾丸モバイル
void updateWithInput()
{
char input;
if(kbhit())
{
input=getch();
if(input=='a')
pos_y--;
if(input=='d')
pos_y++;
if(input=='w')
pos_x--;
if(input=='s')
pos_x++;
if(input==' ')
{
bul_x=pos_x-1;
bul_y=pos_y;
}
}
}
4.インターフェースの表示の実装
5.コードホスティングリンクは
https://gitee.com/scfyer/first
まとめ6.実験
最後に、前の小さな下カザフスタンの願望を達成するために少しゲームを行うには、C言語で初めてワウを、。非常に興味深い、元のソフトウェアエンジニアリングは、ゲームを選択したため。少し満足感のようなものは、また、問題が発生し、学校でこの小さなゲームを多くのことを学びました。楽しいことはハハ、ブログより取得するレポートを簡単に、あります。