You are on page 1of 2

SUJAL MORADIYA

21ID01IT021

PROJECT
Design and development of a mini project or presentation in the area of computer
graphics. (It will include animation in 2D, 3D and various shapes.)

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

int main()
{
int gd = DETECT, gm;
int i, x, y, flag=0;
initgraph(&gd, &gm, "");

x = getmaxx()/2;
y = 30;
while (!kbhit())
{
if(y >= getmaxy()-30 || y <= 30)
flag = !flag;

setcolor(GREEN);
setfillstyle(SOLID_FILL, GREEN);
rectangle(x, y, x + 100, y + 60);
floodfill(x, y, GREEN);

delay(10);
cleardevice();
if(flag)
{
y = y + 10;
}
else
{
y = y - 10;
}
}

getch();
closegraph();
return 0;
}

OUTPUT

You might also like