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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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.