SSJ CGR Micro
SSJ CGR Micro
Functions used:
1. Line
Purpose:-Line function is used to draw the line on the screen.
Syntax: line(x1,y1,x2,y2);
Example:-line(100,100,200,100);
2. Rectangle
Purpose:- Rectangle function is used to draw the rectangle on the screen. X1,y1 are the lower
left co-ordinates of the rectangle and the x2,y2 are the upper right co-ordinates of the
rectangle.
Syntax:– rectangle(x1,,y1,x2,y2);
Example:– rectangle(100,100,200,200);
3. Circle
Purpose: Circle function is used to draw the circle on the screen
Syntax:– circle(x,y,radius);
Example:circle(100,100,50);
4. Getmaxx
Purpose:-getmaxxreturns the maximum x co-ordinate on the screen
Syntax:getmaxx();
Example:-maxx=getmaxx();
5. Getmaxy
Purpose:-getmaxy returns the maximum y co-ordinate on the screen
Syntax:getmaxy();
Example:-maxy=getmaxy();
6. Setcolor
Purpose:-setcolor is to set color of the objects which is to be drawn after this setcolor line.
Syntax:setcolor(COLOR); Example:-setcolor(RED);
7. Closegraph
Purpose:-closegraph function shut down the graphic system Syntax:closegraph();
8. Cleardevice
Purpose: cleardevice function is used to clear the contents or graphic images on the screen in
graphics mode.
Syntax:cleardevice(); Example:cleardevice();
Program code:-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
void main()
{
int gdriver=DETECT, gmode,i,j,x,y,x1,y1;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
cleardevice();
printf("\n\n\n\n\n");
printf("W");delay(50);
printf("E");delay(50);
printf("L");delay(50);
printf("C");delay(50);
printf("O");delay(50);
printf("M");delay(50);
printf("E");delay(50);
printf(" ");delay(50);
printf("T");delay(50);
printf("O");delay(50);
printf(" ");delay(50);
printf("T");delay(50);
printf("H");delay(50);
printf("E");delay(50);
printf(" ");delay(50);
printf("R");delay(50);
printf("O");delay(50);
printf("C");delay(50);
printf("K");delay(50);
printf("E");delay(50);
printf("T");delay(50);
printf(" ");delay(50);
printf("L");delay(50);
printf("A");delay(50);
printf("U");delay(50);
printf("N");delay(50);
printf("C");delay(50);
printf("H");delay(50);
printf("I");delay(50);
printf("N");delay(50);
printf("G");delay(50);
printf(" ");delay(50);
printf("E");delay(50);
printf("V");delay(50);
printf("E");delay(50);
printf("N");delay(50);
printf("T");delay(50);
printf(".");delay(50);
printf("\n
T");delay(50);
printf("H");delay(50);
printf("E");delay(50);
printf(" ");delay(50);
printf("R");delay(50);
printf("O");delay(50);
printf("C");delay(50);
printf("K");delay(50);
printf("E");delay(50);
printf("T");delay(50);
printf(" ");delay(50);
printf("'");delay(50);
printf("L");delay(50);
printf("V");delay(50);
printf("M");delay(50);
printf("-");delay(50);
printf("0");delay(50);
printf("2");delay(50);
printf("'");delay(50);
printf(" ");delay(50);
printf("I");delay(50);
printf("S");delay(50);
printf(" ");delay(50);
printf("R");delay(50);
printf("E");delay(50);
printf("A");delay(50);
printf("D");delay(50);
printf("Y");delay(50);
printf(" ");delay(50);
printf("T");delay(50);
printf("O");delay(50);
printf(" ");delay(50);
printf("B");delay(50);
printf("E");delay(50);
printf(" ");delay(50);
printf("L");delay(50);
printf("A");delay(50);
printf("U");delay(50);
printf("N");delay(50);
printf("C");delay(50);
printf("H");delay(50);
printf("E");delay(50);
printf("D");delay(50);
printf("!");delay(50);
printf("\n
I");delay(50);
printf("T");delay(50);
printf(" ");delay(50);
printf("W");delay(50);
printf("I");delay(50);
printf("L");delay(50);
printf("L");delay(50);
printf(" ");delay(50);
printf("L");delay(50);
printf("A");delay(50);
printf("U");delay(50);
printf("N");delay(50);
printf("C");delay(50);
printf("H");delay(50);
printf(" ");delay(50);
printf("I");delay(50);
printf("N");delay(50);
printf(" ");delay(50);
printf("F");delay(50);
printf("E");delay(50);
printf("W");delay(50);
printf(" ");delay(50);
printf("S");delay(50);
printf("E");delay(50);
printf("C");delay(50);
printf("O");delay(50);
printf("N");delay(50);
printf("D");delay(50);
printf("S");delay(50);
printf(".");delay(2000);
cleardevice();
x1=getmaxx()/2-30; y1=getmaxy()/2-80;
gotoxy(x1,y1); settextstyle(4,0,10); outtextxy(x1-
40,y1,"10");delay(1000);cleardevice();
outtextxy(x1,y1,"9");delay(1000);cleardevice();
outtextxy(x1,y1,"8");delay(1000);cleardevice();
outtextxy(x1,y1,"7");delay(1000);cleardevice();
outtextxy(x1,y1,"6");delay(1000);cleardevice();
outtextxy(x1,y1,"5");delay(1000);cleardevice();
outtextxy(x1,y1,"4");delay(1000);cleardevice();
outtextxy(x1,y1,"3");delay(1000);cleardevice();
outtextxy(x1,y1,"2");delay(1000);cleardevice();
outtextxy(x1,y1,"1");delay(1000);cleardevice();
outtextxy(x1,y1,"0");delay(1000);cleardevice();
j=0;
while(j<950 && !kbhit())
{
//Space setcolor(BLACK);
setfillstyle(SOLID_FILL,BLA
CK); rectangle(0,-480+j,640,-
101+j); floodfill(1,-
479+j,BLACK); //Celestial
Bodies
for(i=0;i<=50;i++)
{
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,WHITE); }
//Moon setcolor(WHITE);
setfillstyle(SOLID_FILL,WHI
TE);
if(j<=400)
{
circle(150,-350+j,50);
floodfill(150,-301+j,WHITE);
}
else
{
circle(110+(j/8),50,-27+(j/5));
floodfill(110+(j/8),99,WHITE);
}
//Sky setcolor(CYAN);
setfillstyle(SOLID_FILL,CY
AN);
//rectangle(0,0+j,640,190+j);
//floodfill(1,1+j,CYAN);
circle(320,140+j,350);
if(j<=400)
{
floodfill(320,0+j,CYAN);
}
else
{
floodfill(320,-200+j,CYAN);
}
//Clouds setcolor(WHITE);
setfillstyle(SOLID_FILL,WHI
TE);
ellipse(235,-100+j,0,180,25,20);
ellipse(260,-80+j,260,90,15,20);
ellipse(235,-60+j,180,360,22,15);
ellipse(215,-80+j,90,270,20,20);
floodfill(235,-46+j,WHITE);
floodfill(235,-119+j,WHITE);
ellipse(535,-100+j,0,180,25,20);
ellipse(560,-80+j,260,90,15,20);
ellipse(535,-60+j,180,360,22,15);
ellipse(515,-80+j,90,270,20,20);
floodfill(535,-46+j,WHITE);
floodfill(535,-119+j,WHITE);
ellipse(100,50+j,0,180,25,20);
ellipse(125,70+j,260,90,15,20);
ellipse(100,90+j,180,360,22,15);
ellipse(80,70+j,90,270,20,20);
floodfill(100,104+j,WHITE);
floodfill(100,31+j,WHITE);
ellipse(400,50+j,0,180,25,20);
ellipse(425,70+j,260,90,15,20);
ellipse(400,90+j,180,360,22,15);
ellipse(380,70+j,90,270,20,20);
floodfill(400,104+j,WHITE);
floodfill(400,31+j,WHITE); //Land
setcolor(GREEN);
setfillstyle(SOLID_FILL,GREEN);
rectangle(0,191+j,640,480+j);
floodfill(1,192+j,GREEN);
//Rocket i=j/8; setcolor(BLUE);
setfillstyle(SOLID_FILL,YELLOW
);
arc(320,259-i,40,130,10);
ellipse(320,355-i,105,155,30,107);
ellipse(320,355-i,25,75,30,107);
rectangle(292,310-i,348,435-i);
floodfill(320,309-i,BLUE);
floodfill(320,250-i,BLUE);
circle(320,342-i,15);
circle(320,342-i,20);
circle(320,393-i,9); circle(320,393-
i,12); line(292,314-i,348,314-i);
line(292,370-i,348,370-i);
line(292,374-i,348,374-i);
line(292,412-i,348,412-i);
floodfill(320,315-i,BLUE);
floodfill(320,369-i,BLUE);
floodfill(320,375-i,BLUE);
floodfill(320,411-i,BLUE);
setfillstyle(SOLID_FILL,BLUE);
floodfill(320,413-i,BLUE);
floodfill(320,434-i,BLUE);
floodfill(320,312-i,BLUE);
floodfill(320,372-i,BLUE);
rectangle(297,435-i,315,446-i); line(297,442-
i,315,442-i); int p[]={297,446-i,294,453-
i,318,453-i,315,446-i}; drawpoly(4,p);
rectangle(325,435-i,343,446-i); line(325,442-
i,343,442-i); int p1[]={325,446-i,322,453-
i,346,453-i,343,446-i}; drawpoly(4,p1);
floodfill(306,439-i,BLUE);
floodfill(306,450-i,BLUE);
floodfill(334,439-i,BLUE);
floodfill(334,450-i,BLUE);
setfillstyle(SOLID_FILL,BLACK);
floodfill(306,444-i,BLUE);
floodfill(334,444-i,BLUE);
floodfill(320,323-i,BLUE);
floodfill(320,361-i,BLUE);
floodfill(320,404-i,BLUE);
setfillstyle(SOLID_FILL,LIGHTC
YAN); floodfill(320,342-i,BLUE);
floodfill(320,393-i,BLUE); //Left
setfillstyle(SOLID_FILL,RED);
arc(305,355-i,108,190,37);
arc(242,355-i,300,350,27);
arc(282,425-i,120,180,53);
line(230,425-i,291,425-i);
arc(312,355-i,121,190,37);
arc(249,355-i,300,350,27);
arc(289,425-i,120,180,53); //Right
arc(335,355-i,350,70,37);
arc(398,355-i,190,240,27);
arc(358,425-i,0,60,53);
line(349,425-i,410,425-i);
arc(328,355-i,350,59,37);
arc(391,355-i,190,240,27);
arc(351,425-i,0,60,53);
floodfill(291,327-i,BLUE);
floodfill(349,327-i,BLUE);
setfillstyle(SOLID_FILL,LIGHTG
RAY); floodfill(291,322-i,BLUE);
floodfill(349,322-i,BLUE);
//Left ellipse(306,453-
i,180,270,10,20); ellipse(306,453-
i,270,360,10,20); ellipse(306,453-
i,180,270,7,16); ellipse(306,453-
i,270,360,7,16); //Right
ellipse(334,453-i,180,270,10,20);
ellipse(334,453-i,270,360,10,20);
ellipse(334,453-i,180,270,7,16);
ellipse(334,453-i,270,360,7,16);
setfillstyle(SOLID_FILL,LIGHTRE
D); floodfill(306,454-i,BLUE);
floodfill(334,454-i,BLUE);
setfillstyle(SOLID_FILL,RED);
floodfill(306,471-i,BLUE);
floodfill(334,471-i,BLUE);
j=j+10;
delay(210);
if(j<950)
cleardevice();
}
getch();
closegraph();
}
Output :
Conclusion:
By applying various concepts of computer graphics, we implemented an animation
which shows a launch pad near the city. While implementing we have faced different
difficulties; for example, while creating an object like rocket we preferred to create it
in parts and then displayit in such a way that the coordinates will get arranged to show
the whole object. Predictingco-ordinates for different objects is also tricky which will
be easier after practicing different algorithm and concepts used in computer graphics.