WELCOME IN THE SEA OF C

Here you find some good quality programs.
If any one want any type of help in C and C++ then you can mail me.
Google

Monday, January 21, 2008

A 2D Animation of a Man

#include/graphics.h/
#include/stdio.h/
#include/conio.h/
#include/math.h/
void main()
{
int n,i,j,k,gd=DETECT,gm,tx,ty;
int x,y,x1,y1,x2,y2;
int xo,yo,xmax,ymax;
float theta;
int temp,xi[20];
int a[20][2];
int b[20][2];
float sx,sy,clope[20];
clrscr();
printf("enter edges");
scanf("%d",&n);
printf("enter coordinates");
for(i=0;i<=n;i++)
{
printf("tx%d/t ty%d",i,i);
scanf("%d%d",&a[i][0],&a[i][1]);
}
a[n][0]=a[0][0];
a[n][1]=a[0][1];
initgraph(&gd,&gm," ");
line(320,0,320,480);
line(0,240,640,240);
xo=320,yo=240;
ymax=480;
for(i=0;i
{
x1=xo+a[i][0];
y1=ymax-(yo+a[i][1]);
x2=xo+a[i+1][0];
y2=ymax-(yo+a[i+1][1]);
line(x1,y1,x2,y2);
}
printf("tx\nty");
scanf("%d%d",&tx,&ty);
for(i=0;i
{
b[i][0]=a[i][0]+tx;
b[i][1]=a[i][1]+ty;
}
b[n][0]=b[0][0];
b[n][1]=b[0][1];
for(i=0;i
{
x1=xo+b[i][0];
y1=ymax-(yo+b[i][1]);
x2=xo+b[i+1][0];
y2=ymax-(yo+b[i+1][1]);
line(x1,y1,x2,y2);
}
getch();
// rotation
printf("angle");
scanf("%f",θ);
theta=(theta*3.14)/180;
for(i=0;i
{
b[i][0]=(int)(a[i][0]*cos(theta)-(a[i][1]*sin(theta)));
b[i][1]=(int)(a[i][0]*sin(theta)+(a[i][1]*cos(theta)));
}
b[n][0]=b[0][0];
b[n][1]=b[0][1];
for(i=0;i
{
x1=xo+b[i][0];
y1=ymax-(yo+b[i][1]);
x2=xo+b[i+1][0];
y2=ymax-(yo+b[i+1][1]);
line(x1,y1,x2,y2);
}
getch();
// scaling
printf("enter scaling sx,sy");
scanf("%f%f",&sx,&sy);
for(i=0;i
{
b[i][0]=(int)a[i][0]*sx;
b[i][1]=(int)a[i][1]*sy;
}
b[n][0]=b[0][0];
b[n][1]=b[0][1];
for(i=0;i
{
x1=b[i][0];
y1=ymax-b[i][1];
x2=b[i+1][0];
y2=ymax-b[i+1][1];
line(x1,y1,x2,y2);
}
getch();

0 comments: