Sunteți pe pagina 1din 13

CSE 309 MINI PROJECT

SCREEN SAVER OF FISH POND IN C


SUBMITTED BY: W.SAGAR
ROLL NO. A-23
SECTION- K2003
REGISTRATION NO.11009482
19-Apr-13


SUBMITTED TO: MR. ARUN MALIK
PROBLEM STATEMENT: PROBLEM STATEMENT: PROBLEM STATEMENT: PROBLEM STATEMENT:
D DD DESIGN A SCREENSAVER OF FISH POND USING C ESIGN A SCREENSAVER OF FISH POND USING C ESIGN A SCREENSAVER OF FISH POND USING C ESIGN A SCREENSAVER OF FISH POND USING C

Design function: Design function: Design function: Design function:
The program has been created using various functions such as ellipse, fillellipse, arc,
circle, line and bar.
Floodfill has been used to fill the color in the fish.
The background color has been set using setbkcolor function.
The fish has been made using 4 arcs, two lines and a circle for eye.
The ground has been made using 3 fillellipse function and a bar.
For the plant I have used ellipse function.

Functions used: Functions used: Functions used: Functions used:
Ellipse:
ellipse draws an elliptical arc
fillellipse draws and fills an ellipse
sector draws and fills an elliptical pie slice
Declaration:
void far ellipse(int x, int y, int stangle, int endangle,
int xradius, int yradius);
void far fillellipse(int x, int y,
int xradius, int yradius);
void far sector(int x, int y, int stangle, int endangle,
int xradius, int yradius);


Arc:
arc draws a circular arc
circle draws a circle
pieslice draws and fills a circular pie slice
Declaration:
void far arc(int x, int y, int stangle, int endangle, int radius);
void far circle(int x, int y, int radius);
void far pieslice(int x, int y, int stangle, int endangle, int radius);
Line:
line draws a line between two specified points
linerel draws a line a relative distance from the current position (CP)
lineto draws a line from the current position (CP) to (x,y).
Declaration:
void far line(int x1, int y1, int x2, int y2);
void far linerel(int dx, int dy);
void far lineto(int x, int y);
Circle:
arc draws a circular arc
circle draws a circle
pieslice draws and fills a circular pie slice.
Declaration:
void far arc(int x, int y, int stangle, int endangle, int radius);
void far circle(int x, int y, int radius);
void far pieslice(int x, int y, int stangle, int endangle, int radius);





KBHIT:
Checks for currently available keystrokes
Declaration: int kbhit(void);
Remarks:
kbhit checks to see if a keystroke is currently available.
Any available keystrokes can be retrieved with getch or getche.

Return Value:
On success (if a keystroke is available),
returns a non-zero integer
If a keystroke is not available, returns 0.
Floodfill:
Flood-fills a bounded region
Declaration: void far floodfill(int x, int y, int border);
Remarks:
floodfill fills an enclosed area on bitmap devices.
The area bounded by the color border is flooded with the current fill pattern and
fill color.
(x,y) is a "seed point".
If the seed is within an enclosed area, the inside will be filled.
If the seed is outside the enclosed area, the exterior will be filled.






Source Code: Source Code: Source Code: Source Code:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>

void background();
void ground();
void fish1(int);
void fish2(int);
void fish3(int);
int i,j;
int main()
{
int gdriver = DETECT, gmode;
int i;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");


while(!kbhit())
{
background();
ground();
setviewport(0,0,635,320,1);
fish1((i*10)%640);
fish2((i*10)%640);
fish3((i*10)%640);
delay(300);
i++;
clearviewport();
}

getch();
closegraph();
return 0;
}
void background()
{
setbkcolor(9);
}
void ground()
{

setcolor(GREEN);
setfillstyle(SOLID_FILL,2);
fillellipse(100,430,120,20);
fillellipse(330,430,120,20);
fillellipse(530,430,120,20);
//
fillellipse(200,440,120,20);
fillellipse(450,440,120,20);
//
bar(0,440,700,500);

//

setcolor(2);
setlinestyle(SOLID_LINE,0,3);

ellipse(33,420,90,180,20,100);
ellipse(33,420,90,180,30,100);

ellipse(100,420,0,90,20,100);
ellipse(100,420,0,90,30,100);
ellipse(160,420,90,180,20,100);
ellipse(160,420,90,180,30,100);

ellipse(200,420,0,90,20,100);
ellipse(200,420,0,90,30,100);
ellipse(260,420,90,180,20,100);
ellipse(260,420,90,180,30,100);

ellipse(350,420,0,90,20,100);
ellipse(350,420,0,90,30,100);
ellipse(410,420,90,180,20,100);
ellipse(410,420,90,180,30,100);

ellipse(540,420,0,90,20,100);
ellipse(540,420,0,90,30,100);
ellipse(600,420,90,180,20,100);
ellipse(600,420,90,180,30,100);

ellipse(610,420,0,90,20,100);
ellipse(610,420,0,90,30,100);
}
void fish1(int t)
{
setcolor(4);
setlinestyle(SOLID_LINE,0,3);
setfillstyle(SOLID_FILL,6);

arc(100+t,350-30,35,150,60);
arc(100+t,290-30,210,328,60);
line(148+t,316-30,140+t,320-30);
line(140+t,320-30,149+t,322-30);
floodfill(100+t,330-30,4);
circle(130+t,321-30,2);

arc(18+t,325-30,10,120,30);
arc(28+t,285-30,208,278,30);
//
arc(20+t,305-30,230,340,30);
arc(22+t,347-30,70,133,30);

}
void fish2(int t)
{
setcolor(4);
setlinestyle(SOLID_LINE,0,3);
setfillstyle(SOLID_FILL,3);
arc(400+t,150,35,150,60);
arc(400+t,90,210,328,60);
line(448+t,116,440+t,120);
line(440+t,120,449+t,122);
floodfill(400+t,130,4);

circle(430+t,121,2);
setlinestyle(SOLID_LINE,0,3);
arc(318+t,125,10,120,30);
arc(328+t,85,208,278,30);
//
arc(320+t,105,228,340,30);
arc(322+t,147,70,135,30);
}

void fish3(int t)
{
setcolor(4);
setlinestyle(SOLID_LINE,0,3);
setfillstyle(SOLID_FILL,5);

arc(200+t,250-30,35,150,60);
arc(200+t,190-30,210,328,60);
line(248+t,216-30,240+t,220-30);
line(240+t,220-30,249+t,222-30);
floodfill(200+t,230-30,4);
circle(230+t,221-30,2);
//setlinestyle(SOLID_LINE,0,1);
arc(118+t,225-30,10,120,30);
arc(128+t,185-30,208,278,30);
//
arc(120+t,205-30,230,340,30);
arc(122+t,247-30,70,133,30);
}





Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot: Program and Output Screenshot:

S-ar putea să vă placă și