You are using a version without Ads of this website. Please, consider donating:

### How can you shoot projectiles in turbo C?

my teacher said that we need to make a "space invaders" like game on turbo c and i can't firgure it out how to manipulate the keys..what i've done so far is this

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485`` ``````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(); }``````

this is only the "X" shooting...but my teacher asked to do is make the "Y" shoot and has a colision detection.thanks
Topic archived. No new replies allowed.