Which Compiler are you using..?If Turbo C++..,You have to know little about the functions under graphics.h.
deepugtm
Junior Poster in Training
96 posts since Aug 2008
Reputation Points: 2
Solved Threads: 2
Actually this question has more to do with what OS(unless its, doubtfully, hardware specific).
Just use something like OpenGL or SDL, for graphics.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
I think the best graphics for beginners is allegro.I've just completed C,and I'm using it, I recommend you to try.For detail go to http://www.allegro.cc
deepugtm
Junior Poster in Training
96 posts since Aug 2008
Reputation Points: 2
Solved Threads: 2
What is with all the Turbo C++ references?!! That compiler is a non-standard relic from another millennial! It's useless!
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
int i=100,j=100,f1=1,f2=1,r=50,k;
l:
// printf("\n\nEnter the co-ordinate where from you want to start to move the circle : ");
// scanf("%d%d",&i,&j);
cleardevice();
// printf("\n\nEnter the redious : " );
// scanf("%d",&r);
// if(r<i||r<j) {printf("\nWrong entry, Try again.");goto l;}
cleardevice();
getch();
while(!kbhit())
{
setcolor(WHITE);
circle(i+1,j+1,r); // printf("%d, %d",i,j);
delay(2);
/* for(k=1;k<=10;k++)
{
setcolor(k);
circle(i+1,j+1,r-(k*r/10));
delay(1);
setcolor(BLACK);
circle(i+1,j+1,r-(k*r/10));
} */
setcolor(BLACK);
circle(i+1,j+1,r);
if(i<639-r&&f1==1)
{i++;f1=1;
}
else
{i--;
if(i==r) f1=1; else f1=-1;
}
if(j<480-r&&f2==1)
{j++;f2=1;}
else
{j--;
if(j==r) f2=1;else f2=-1;
}
}
}
Try this , Here is one single ball, read it try to upgrade into two balls
Don't use "void main()", there are two proper main function headers, and they are:
int main(int argc, char *argv[]) and int main()
Using "void main()" can cause problems, for a detailed explanation as to what kind of problems it can cause please consult google.
and for your information if you ever want to upgrade to a newer compiler, (like Visual Studio Express, or MinGW) the first thing you should try is using STANDARD C++ headers, like instead of "fstream.h" it should be #include <fstream>
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111