I decided to start making my first game tonight, with the old turbo c graphics library. I was thinking snake but i thought pong might be a bit easier.
I've got the first paddle working so far, without out it flying off the screen, lol
Code:
#include <graphics.h>
int main(void)
{
int left=0,top=240,right=10,bot=270;
int driver=DETECT,mode;
char c;
initgraph(&driver, &mode, "");
outtextxy(280,180,"Pong in the making");
outtextxy(280,200, "PRESS Q TO QUIT");
outtextxy(280,220, "2 - UP 8 -DOWN");
bar(left,top,right,bot);
c=getche();
while(1)
{
switch(c)
{
case '2': if(top != 450)
{
top+=30;
bot+=30;
cleardevice();
bar(left,top,right,bot);
c=getche();
}
break;
case '8': if(top != 0)
{
top-=30;
bot-=30;
cleardevice();
bar(left,top,right,bot);
c=getche();
}
break;
case'q': break;
default: c=getche();
break;
}
if (c== 'q') break;
if (c=='2' && top==450)
c=getche();
if(c=='8' && top==0)
c=getche();
}
closegraph();
return 0;
}
Edit; whoops, the attached exe isn't working, I must have attached the wrong one.
edit 2, actually, i needed to put the graphics drivers in the zip to make this program run on other pcs :o