Friday, February 24, 2017

Create a Graphical door by C (Graphics Programme)




#include<graphics.h>
#include<conio.h>
#include<dos.h>

int project1();
int project2();
main(){
int driver, mode;
driver=DETECT;
mode=0;
initgraph(&driver,&mode,"C:\\tc\\bgi");
project1();
project2();
getch();
}

int project1(){
cleardevice();
setcolor(WHITE);
rectangle(130,150,500,330);
line(130,150,310,30);
line(310,30,500,150);
setcolor(WHITE);
rectangle(145,330,480,350);
setfillstyle(8,GREEN);
floodfill(150,140,WHITE);
setcolor(WHITE);
rectangle(153,350,466,367);
setfillstyle(RED,4);
floodfill(199,361,WHITE);
setcolor(WHITE);
rectangle(167,367,450,383);
setfillstyle(BROWN,5);
floodfill(355,371,WHITE);
setcolor(WHITE);
rectangle(150,180,240,290);
setfillstyle(GREEN,7);
floodfill(191,212,WHITE);
setcolor(WHITE);
rectangle(390,180,480,290);
setfillstyle(GREEN,7);
floodfill(433,222,WHITE);
setcolor(WHITE);
rectangle(270,160,360,320);
setfillstyle(BLACK,7);
floodfill(333,222,WHITE);
}


int project2(){
for(int b=0;b<=9999;b++){
int middleX=290,middleY=170,middleYY=309;
for(int a=2;a>=0;--a){
project1();

setcolor(WHITE);
line(middleX,309,360,320); //Door down
line(middleX,170,360,163); //door up
line(middleX,middleY,middleX,middleYY); //door middle
setfillstyle(4,BLUE);
floodfill(305,181,WHITE);
middleX-=8;
delay(1000);
cleardevice();

}middleX=290;middleY=170;middleYY=309;
}}

No comments:

Post a Comment