Computer graphics in c++

Hi,
I want to make a simple cg program in c++ of a moving circle.
The circle should move to left when left arrow key is pressed and same with other
arrow keys.
Please help .
How much programming experience do you have?
What's the problem there? Is very easy, if you know how to do it... First of all, you have to know graphics.h or other headers... then you have to control the circle using getch() to get a character by the user. Then you have to translate the code found with getch in a integer number. Using a switch case, you move the center of the circle, related on which arrow key you had digited
<graphics.h> really? That's not a standard header and was really built for DOS. It was packaged with the Borland C++ compiler in the 90s.

I'd recommend SFML. It has a lot of good tutorials on the site and provides some easy wrappers for window management and events. It has a 2d library where you can create shapes and put textures on them. I think that's what you want.

If you want to go 3D, SFML also shows you how to use OpenGL so that you can get started with a real graphics engine.
thanks for the reply..
wat's wrong with this code..
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\bgi");
char ch;
ch=getchar();
int d=(int)ch;
while(!kbhit())
{
switch(d)
{
case 68:
for(int i=250;i<500;i++)
circle(i,250,20);
cleardevice();

case 87:
for(int j=250;j>50;j--)
circle(250,j,20);
cleardevice();

case 65:
for(int k=250;k>50;k--)
circle(k,250,20);
cleardevice();

case 83:
for(int l=250;l<500;l++)
circle(250,l,20);
cleardevice();
}
}
getch();
closegraph();
}

}
instead of arrows keys i m trying for w,a,d,s keys
when i press any of the keys the alphabet itself is displayed on the screen
instead of any movement of the circle.
please help.
Why are clearing the device after you draw to it?
Topic archived. No new replies allowed.