Monday 26 December 2011

Helicopter- C Graphics program

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
void heli();

int main()
{
    initwindow(2000,2000, "First Sample");
    heli();
    getch();
}

void heli()
    {
    int xf,yf;
    int x1,y1,x2,y2,x3,y3,x4,y4;
    int j=0,i=0;
    float t;      
    t=3.14/180;
    xf=450;
    yf=160;
    while(1)
      {
      for(i=0;i<360;i++,j++)
      {
                        setcolor(15);
                        x1=xf+(175-xf)*cos(t*i)-(150-yf)*sin(t*i);
                        y1=yf+(175-xf)*sin(t*i)+(150-yf)*cos(t*i);
                        x2=xf+(700-xf)*cos(t*i)-(150-yf)*sin(t*i);
                        y2=yf+(700-xf)*sin(t*i)+(150-yf)*cos(t*i);
                        x3=xf+(700-xf)*cos(t*i)-(175-yf)*sin(t*i);
                        y3=yf+(700-xf)*sin(t*i)+(175-yf)*cos(t*i);
                        x4=xf+(175-xf)*cos(t*i)-(175-yf)*sin(t*i);
                        y4=yf+(175-xf)*sin(t*i)+(175-yf)*cos(t*i);
                       
                       
                        line(x1+j,y1,x2+j,y2);
                        line(x2+j,y2,x3+j,y3);
                        line(x3+j,y3,x4+j,y4);
                        line(x4+j,y4,x1+j,y1);
                       
                        line(450+j,160,450+j,200);
                        line(450+j,200,250+j,215);
                        line(250+j,215,250+j,250);
                        line(250+j,225,100+j,225);
                        line(100+j,225,100+j,175);
                        line(100+j,225,100+j,235);
                        line(100+j,235,250+j,235);
                       
                       
                        line(250+j,250,425+j,300);
                        line(425+j,300,475+j,300);
                        line(450+j,300,435+j,315);
                        line(450+j,300,465+j,315);
                        line(475+j,300,650+j,250);
                       
                        line(450+j,200,650+j,215);
                        line(650+j,215,650+j,250);
                       
                       
                        setcolor(0);
                        x1=xf+(175-xf)*cos(t*i)-(150-yf)*sin(t*i);
                        y1=yf+(175-xf)*sin(t*i)+(150-yf)*cos(t*i);
                        x2=xf+(700-xf)*cos(t*i)-(150-yf)*sin(t*i);
                        y2=yf+(700-xf)*sin(t*i)+(150-yf)*cos(t*i);
                        x3=xf+(700-xf)*cos(t*i)-(175-yf)*sin(t*i);
                        y3=yf+(700-xf)*sin(t*i)+(175-yf)*cos(t*i);
                        x4=xf+(175-xf)*cos(t*i)-(175-yf)*sin(t*i);
                        y4=yf+(175-xf)*sin(t*i)+(175-yf)*cos(t*i);
                       
                        line(x1+j,y1,x2+j,y2);
                        line(x2+j,y2,x3+j,y3);
                        line(x3+j,y3,x4+j,y4);
                        line(x4+j,y4,x1+j,y1);
                       
                        line(450+j,160,450+j,200);
                        line(450+j,200,250+j,215);
                        line(250+j,215,250+j,250);
                        line(250+j,225,100+j,225);
                        line(100+j,225,100+j,175);
                        line(100+j,225,100+j,235);
                        line(100+j,235,250+j,235);
                       
                       
                        line(250+j,250,425+j,300);
                        line(425+j,300,475+j,300);
                        line(450+j,300,435+j,315);
                        line(450+j,300,465+j,315);
                        line(475+j,300,650+j,250);
                        line(450+j,200,650+j,215);
                        line(650+j,215,650+j,250);
                        }
                        }
                       
     
   
   
    
     }

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More