我想做一个类似雷电的游戏,现在想要子弹(符号是*)自动从飞机发射出去,怎么写啊
#include<stdio.h>#include<stdlib.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
int map[50][40];
int x=25,y=30;
int ix,iy;
char key;
int Wait_Time=1;
int t=1;
clock_t Now_Time=clock();
void HideCursor();
void gotoxy(int x,int y);
void draw(int x,int y);
void plane();
void setmap();
void bullet(int x,int y);
void HideCursor()
{
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(hOut,&cursor_info);
}
void gotoxy(int x,int y)
{
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos{x,y};
SetConsoleCursorPosition(hOut,pos);
}
void draw(int x,int y)
{
gotoxy(x,y);
printf("&");
}
void plane()
{
int Wait_Time=1;
if(clock()-Now_Time>=Wait_Time)
{
srand((unsigned)time(NULL));
ix=rand()%25;
iy=10;
gotoxy(ix,iy);
printf("$");
Now_Time=clock();
}
}
void bullet(int x,int y)
{
if(clock()-Now_Time>=Wait_Time)
{
y=y-1;
gotoxy(x,y);
printf("*");
Now_Time=clock();
}
}
int main()
{
system("mode con cols=50 lines=40");
for(ix=0;ix<50;ix++)
for(iy=0;iy<40;iy++)
{
map[ix][iy]=0;
}
draw(x,y);
HideCursor();
while(1)
{
plane();
if(kbhit())
{
switch(getch())
{
case 'w':{gotoxy(x,y);printf(" ");map[x][y]=1;draw(x,--y);break;}
case 's':{gotoxy(x,y);printf(" ");map[x][y]=1;draw(x,++y);break;}
case 'a':{gotoxy(x,y);printf(" ");map[x][y]=1;draw(--x,y);break;}
case 'd':{gotoxy(x,y);printf(" ");map[x][y]=1;draw(++x,y);break;}
}
if(map[x][y]==1)
bullet(x,y);
}
}
}