Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I...................?

Status
Not open for further replies.

qweas

Programmer
Feb 12, 2002
42
GB
weas (Programmer) Jul 20, 2002
Can i program games with C++ and if so how do i create the graphics environment? Please have you any answers or suggestions of how to acces the design features because i have created the main program but i don't know how to include or make the graphics environment into my game.

Thanks.
 
If you are using Turbo C, then the library <graphics.h> can be used.
It allows to draw line, circle, polygon and other elementary shapes.
Colors are also available.

The lines below gives a very elementary idea to start with graphics
------------
You can animate the figures by erasing them and drawing them repeatedly.
the following is a pseudo code -

draw(oldx1 , oldy1, oldx2, oldy2, in_red_ color);
while ( !kbhit())
{
draw(oldx1 , oldy1, oldx2, oldy2, in_black_ color); //Used to erase
sleep(1);
newx1 = oldx1 + 1;
newx2 = oldx2 + 1;
newy1 = oldy1 + 1;
newy2 = oldy2 + 1;
draw(newx1, newy1, newx2, newy2, in_red_color); //To redraw in new position
oldx1 = newx1;
oldx2 = newx2;
oldy1 = newy1;
oldy2 = newy2;
}

----
draw() can be a user defined function calling line() and setcolor(int color)

For user inputs, you can detect the keyboard keys and the mouse buttons.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top