Hi I'm trying to make a little pingpong game..(just for fun),
But how do I make the two bats, run seperatly from eachother.
You can go up and down, but only with one at a time.
And another thing, how do i get the game to go faster??, I'm thinking of when I move the bats up and down.
Can it be made an easier way...
tx
my code so far:--------------------------
int delay(int);
void startgrafiksystem(void); /* Graphics Start */
void slutgrafiksystem(void); /* Graphics Ends */
void g_rectangle(int xstart, int ystart, int xtil, int ytil);
/* my retangle function*/
void bane(void) /* makes the box for playing */
{
setcolor(WHITE);
g_rectangle(50, 30, getmaxx()-50, getmaxy()-30);
/* (50,30),(589,449) */
}
int main()
{
int a,b,c,d,*pa,*pb,*pc,*pd, ch; /* [350,320,610,470] */
int e,f,g,h,*pe,*pf,*pg,*ph;
int count = 0;
char c1[6];
pa = &a; pb = &b; pc = &c; pd = &d;
pe = &e; pf = &f; pg = &g; ph = &h;
*pa=569; *pb = 200; *pc=579; *pd=250;
*pe=60; *pf = 200; *pg=70; *ph=250;
startgrafiksystem(); /* Opens the Graphic */
bane(); /* makes the box for the field */
do
{
if(!kbhit())
{
sprintf(c1, "%d", count++);
gotoxy(1,1);
printf("%s", c1);
g_rectangle(a,b,c,d);
g_rectangle(e,f,g,h);
switch(bioskey(0))
{
case 0x5000: /* ARROW DOWN */
setcolor(BLACK);
g_rectangle(a,b,c,d);
setcolor(WHITE);
b-=1; d-=1;
g_rectangle(a,b,c,d);
break;
case 0x4800: /* ARROW UP */
setcolor(BLACK);
g_rectangle(a,b,c,d);
setcolor(WHITE);
b+=1; d+=1;
g_rectangle(a,b,c,d);
break;
case 0x1e61: /* a */
setcolor(BLACK);
g_rectangle(e,f,g,h);
setcolor(WHITE);
f+=1; h+=1;
g_rectangle(e,f,g,h);
break;
case 0x2c7a: /* z */
setcolor(BLACK);
g_rectangle(e,f,g,h);
setcolor(WHITE);
f-=1; h-=1;
g_rectangle(e,f,g,h);
break;
case 0x5300: /* DEL key */
clrscr();
gotoxy(300,220);
printf("System is shuting down!!");
delay(1200);
slutgrafiksystem();
return 0;
default:
break;
}
}
}while(ch !='q');
getch();
slutgrafiksystem();
return 0;
}