#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<math.h>
void main()
{
int gd,gm;
int x,y;
int i,j,kk;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(WHITE);
line(0,400,640,400);
rectangle(300,330,340,400);
rectangle(310,320,330,330);
setcolor(4);
line(319,280,319,398);
line(320,280,320,398);
rectangle(320,280,330,300);
outtextxy(340,280,"PRESS ANY KEY TO IGNITE THE ROCKET");
getch();
for(j=400;j<640;j++)
{
cleardevice();
setcolor(WHITE);
line(0,j,640,j);
rectangle(300,j-70,340,j);
rectangle(310,j-80,330,j-70);
setcolor(RED);
line(319,280,319,400);
line(320,280,320,400);
rectangle(320,280,330,300);
setcolor(YELLOW);
circle(325,300,2);
delay(5);
}
for(i=400;i>340;i--)
{
cleardevice();
setcolor(RED);
line(319,i,319,i-120);
line(320,i,320,i-120);
rectangle(320,i-120,330,i-100);
setcolor(YELLOW);
circle(325,i-100,2);
delay(25);
}
cleardevice();
kk=0;
for(j=100;j<350;j++)
{
if(j%20==0)
{
setcolor(kk);
kk=kk+3;
delay(50);
}
ellipse(320,30,0,360,j+100,j+0);
}
for(j=100;j<350;j++)
{
if(j%20==0)
{
setcolor(BLACK);
delay(2);
}
ellipse(320,30,0,360,j+100,j+0);
}
cleardevice();
for(i=0;i<70;i++)
{
setcolor(i);
settextstyle(GOTHIC_FONT,HORIZ_DIR,6);
outtextxy(110,150,"HAPPY NEWYEAR");
delay(90);
}
getch();
}
Tuesday, May 12, 2009
Graphics program to Display Animation (Fireworks)
Subscribe to:
Post Comments (Atom)
22 comments:
hey man...this was really great one....lolz..
ur welcome, will post more such programs soon!
when i hit RUN, the program wont run though i fixed the errors.. hehe please help. SCHOOL WORK
thanks in advance very helpful!
I have checked the code before posting it, but i'll still check it once again. Which compiler are you using? and what errors are you getting? get back to me with this information and I may be able to help you out!
hey !!! but i have run it on turbo c....it works..
I've checked the code once again, there are absolutely no errors.
hello there! hehe. :) I tried to run your program but it said there "function 'delay' should have a prototype" I am new using c/c++ so yeah. hehe~ i don't know what to do. ^.^ keke~ great. keke~
this was so amazing......i love it.
it was awesome...gr8 wrk.
Whoever said he/she was facing the compiler error: "function delay should have a prototype" should try to include the "dos.h" header.
i.e. #include
It'll work perfectly!!:D
How to create a .exe out of this program ?
so cool.... i love it.
#include
must be prefixed
I am student of MCA I am doing a program for my college project, It an animation program, to show rocket is move from one planet to another but I dont able to resolve the issue in it. Is anybody help me in it. pls
I am putting my code also, Thank you,
#include
#include
#include
#include
#include
#include
#define PI 3.14
#define n 3
float cord[10][3], ans[10][3];
float tMat[3][3]={ 1,0,0,
0,1,0,
0,0,1 };
float tMat1[3][3]={ 1,0,0,
0,1,0,
0,0,1 };
int angle;
void clear()
{
tMat1[0][0]=1;
tMat1[0][1]=0;
tMat1[0][2]=0;
tMat1[1][0]=0;
tMat1[1][1]=1;
tMat1[1][2]=0;
tMat1[2][0]=0;
tMat1[2][1]=0;
tMat1[2][2]=1;
}
void getPoints()
{ cord[0][0]=0;
cord[0][1]=0;
cord[0][2]=1;
cord[1][0]=30;
cord[1][1]=30;
cord[1][2]=1;
cord[2][0]=30;
cord[2][1]=-30;
cord[2][2]=1;
}
void drawPolygon(float ans[][3])
{ int i;
for(i=0;i<n-1;i++)
line(getmaxx()/2+ans[i][0],getmaxy()/2-ans[i][1],getmaxx()/2+ans[i+1][0], getmaxy()/2-ans[i+1][1]);
line(getmaxx()/2+ans[0][0],getmaxy()/2-ans[0][1],getmaxx()/2+ans[i][0],getmaxy()/2-ans[i][1]);
}
void mul(float mat1[][3],float mat2[][3],float ans[][3])
{ int i,j,k;
float sum;
for(i=0;i<n;i++)
{ sum=0;
for(j=0;j<3;j++)
{ sum=0;
for(k=0;k<3;k++) sum+=mat1[i][k]*mat2[k][j];
ans[i][j]=sum;
}
}
}
void rot_trans(float tx,float ty,float angle)
{
float ans1[10][3];
tMat[2][0]=tx;
tMat[2][1]=ty;
//cout<<"angle:"<<angle;
angle*=PI/180;
tMat1[0][0]=cos(angle);
tMat1[0][1]=sin(angle);
tMat1[1][0]=-sin(angle);
tMat1[1][1]=cos(angle);
mul(tMat,tMat1,ans1);
mul(cord,ans1,ans);
}
void rotate(float angle)
{
clear();
int i;
angle*=PI/180;
tMat1[0][0]=cos(angle);
tMat1[0][1]=sin(angle);
tMat1[1][0]=-sin(angle);
tMat1[1][1]=cos(angle);
mul(cord,tMat1,ans);
}
void copy(float from[][3],float to[][3])
{
for(int inx=0;inx<n;inx++)
{
to[inx][0]=from[inx][0];
to[inx][1]=from[inx][1];
to[inx][2]=1;
//to[inx][2]=from[inx][2];
}
clear();
}
void translate(int tx,int ty,int draw)
{
int i;
tMat[2][0]=tx;
tMat[2][1]=ty;
mul(cord,tMat,ans);
}
int sign(int a)
{
if(a<0)
return -1;
else if(a==0)
return 0;
else
return 1;
}
void earth(float midx,float midy,int radius)
{
circle((getmaxx()/2)+midx,(getmaxy()/2)+midy,radius);
}
void mars(float midx,float midy,int radius)
{
circle((getmaxx()/2)+midx,(getmaxy()/2)+midy,radius);
}
void bezier (int x[][2])
{
int i=1;
int flag=i;
double t;
for (t = 0.0; t < 1.0; t += 0.0005)
{
double xt = pow (1-t, 3) * x[0][0] + 3 * t * pow (1-t, 2) * x[1][0] +
3 * pow (t, 2) * (1-t) * x[2][0] + pow (t, 3) * x[3][0];
double yt = pow (1-t, 3) * x[0][1] + 3 * t * pow (1-t, 2) * x[1][1] +
3 * pow (t, 2) * (1-t) * x[2][1] + pow (t, 3) * x[3][1];
setcolor(WHITE);
if(i%155==0)
{
flag++;
}
rot_trans(xt,-yt,flag);
i++;
drawPolygon(ans);
setcolor(WHITE);
earth(200,0,30);
mars(-200,0,30);
}
return;
}
void main()
{
float sx,sy,tx,ty,r;
int ctr,i, choice, gdriver = DETECT, gmode;
char axis;
detectgraph(&gdriver,&gmode);
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
getPoints();
cleardevice();
drawPolygon(cord);
angle=1;
rotate(330);
copy(ans,cord);
line(getmaxx()/2, 0, getmaxx()/2, getmaxy());
line(0,getmaxy()/2, getmaxx(), getmaxy()/2);
int x[4][2];
x[0][0]=200;
x[0][1]=0;
x[1][0]=80;
x[1][1]=-80;
x[2][0]=-90;
x[2][1]=-70;
x[3][0]=-300;
x[3][1]=0;
earth(200,0,30);
mars(-200,0,30);
bezier(x);
copy(ans,cord);
for(i=0;i<n;i++)
{
cout<<ans[i][0]<<endl;
cout<<ans[i][1]<<endl;
cout<<ans[i][2]<<endl;
}
getch();
}
awesomeeee
thanks
GREAT&GORGEOUS!!!
******************************************************************************
WANT PROGS FOR COMPUTER GRAPHICS OF HIGHER QUALITY..
It does not work on turbo c++ ....
I did add dos.h and there are no errors. Why doesnt it work?.. Please help
Thank you for sharing this blog site it is very useful for giving the information about
Sharing Knowledge
Question and Answer
Tutorialspoint
Java Online Training
C++ Online Training
Python Online Training
why this programme is not running on my desktop it showing me 25 errors plzzzz help mi
Same problem program has no errors but output is not cmng ..
Post a Comment