so i have to make a "Space invaders" like game (just a simple one though) but i dont know what codes should i use
this is the code :
void movingX()
{
int xcol = 1, xrow = 1;
int ycol = 40, yrow = 24;
int xbombcol = xcol, xbombrow = xrow + 1, xbombstat = 0;
char ch;
clrscr();
gotoxy(xcol, xrow); putch('X');
gotoxy(ycol, yrow); putch('Y');
gotoxy(ycol-3, yrow); printf("<-");
gotoxy(ycol+2, yrow); printf("->");
do
{
if (xrow % 2 !=0)
{
if (xcol < 80)
{
delay(10); gotoxy(xcol,xrow); putch(' ');
xcol++; gotoxy(xcol, xrow); putch('X');
}
else
{
gotoxy(xcol,xrow); putch(' '); xrow++;
gotoxy(xcol,xrow); putch('X');
}
}
else if (xrow % 2 == 0)
{
if(xcol > 1)
{
delay(10); gotoxy(xcol,xrow); putch(' ');
xcol--; gotoxy(xcol, xrow); putch('X');
}
else
{
gotoxy(xcol,xrow); putch(' '); xrow++;
gotoxy(xcol,xrow); putch('X');
}
}
if (xbombstat == 0)
{
xbombstat = 1;
gotoxy(xbombcol, xbombrow); putch('*');
}
if (xbombstat == 1 && xbombrow <= 24)
{
gotoxy(xbombcol, xbombrow); putch(' '); xbombrow++;
gotoxy(xbombcol, xbombrow); putch('*');
}
if (xbombrow == 24)
{
if (xbombcol == ycol)
{
gotoxy(35, 12); puts("YOU LOOSE");
xrow = 24;
}
gotoxy(xbombcol, xbombrow); putch(' ');
xbombcol = xcol; xbombrow = xrow;
xbombstat = 0;
}
if (kbhit())
{
ch = getch();
switch(ch)
{
case 75 : if (ycol > 1)
{
gotoxy(ycol, yrow); putch(' '); ycol--;
gotoxy(ycol, yrow); putch('Y');
}break;
case 77 : if (ycol < 80)
{
gotoxy(ycol, yrow); putch(' '); ycol++;
gotoxy(ycol, yrow); putch('Y');
}break;
}
}
}while (xrow <24);
puts("END OF LOOP!!!!");
getch();
}
so basically, the "X" is moving and shooting "bombs" i can move the Y but i cannot let it shoot..that is my problem how to shoot(or fire projectile)
Cheers!