Graphics programming in C

May 2017

The general purpose programming language C is the basic language in computer programming but at the same the application of this language is most widely used.C language is used to mimic text documents, mathematical and statistical operations and can also be used to create animation programs.With the help of theC language, programs which create computer graphics can be made. In the script of the C language, you can input the logic of the code that can be used for designing graphics programsfor various animation needs, like that of car animation.

Issue



I am new to graphics programming in C and would like some sample code for a basic animation to help me learn.

Solution


This is the program for car animation:

#include<graphics.h>    
#include<iostream.h>    
#include<conio.h>    
#include<dos.h>    
#include<string.h>    
#include<stdlib.h>    
void main()    
{    
int v,s;    
int gd= DETECT,gm;    
initgraph(&gd,&gm," ");    
line(0,290,634,290);    

for(int i=10;i<=634;i++)    
{    
cleardevice();    
line(130+i,200,180+i,150);    
line(180+i,150,250+i,150);    
line(250+i,150,300+i,200);    

circle(300+i,275,15);    
circle(150+i,275,15);    
rectangle(120+i,200,350+i,260);    
//line(0,275,634,275);    
line(0,290,634,290);    
delay(10);    
}    

for( i=634;i>=0;i

Note


Thanks to anu for this tip on the forum.

Related


Published by aakai1056. Latest update on February 13, 2012 at 01:24 PM by Paul Berentzen.
This document, titled "Graphics programming in C," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).