You are on page 1of 4

Fish Simulation

A project report submitted in partial


fulfillment of the requirements for the

Second Year of Computer Engineering

by

Gaurav Mishra(RollNo.9557)
Sumit Rai (Roll No. 9570)
Madhav Jha (Roll No. 9543)
Gaurav Joshi (Roll No. 9612)

Under the guidance of


Prof. Sushma F Nagdeote

DEPARTMENT OF COMPUTER ENGINEERING


Fr. Conceicao Rodrigues College of Engineering, Bandra (W),
Mumbai - 400050
University
of Mumbai
2022-23
Abstract:
Our Project is on a simple car animation that drives on the middle of screen(maxy/2)
.It Starts from the initial point on the x axis to the final point of the x axis that is the end of
screen .Our Project consists of functions such as floodfill method and setfillstyle method.
In this program, we will first draw a car and color it. In every iteration of for loop we keep on
increasing the x coordinates of every point of car to make it look like this car is moving from
left to right. We will use below mentioned graphics functions in this program.
Some of the other functions used in the project are
1.getmaxx - It returns the maximum X coordinate in current graphics mode and driver.
2.getmaxy - It returns the maximum X coordinate in current graphics mode and driver.
3. setcolor - It changes the current drawing colour. Default colour is white. Each color is
assigned a number, like BLACK is 0 and RED is 4. Here we are using colour constants
defined inside graphics.h header file.

Introduction:
- The animations used in this project are only using the graphics.h header file.
- The reason we chose this topic is because it covers most of the topics
covered in our syllabus and uses new functions which we got to learn and
implement.

Methodology:
The tools used for this project are MS turbo c complier.
The graphics.h library used in the BGI.
In this program, we first draw a fish on left side of the screen (x,y) and then
simulate it by moving it along X direction. We make the fish to simulate along the
screen and finally out of the screen. This will look like a fish moving from the right to
left direction. We will repeat above steps until fish reaches the right side of screen.

Results:
Source code:
#include <stdio.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>

int main() {
int gd = DETECT, gm;
int i, maxx, midy;

initgraph(&gd, &gm, "C:\\TC\\BGI");


maxx = getmaxx();

midy = getmaxy()/2;

for (i=0; i < maxx-150; i=i+5) {

cleardevice();

setcolor(WHITE);
line(0, midy + 37, maxx, midy + 37);

setcolor(YELLOW);
setfillstyle(SOLID_FILL, RED);

line(i, midy + 23, i, midy);


line(i, midy, 40 + i, midy - 20);
line(40 + i, midy - 20, 80 + i, midy - 20);
line(80 + i, midy - 20, 100 + i, midy);
line(100 + i, midy, 120 + i, midy);
line(120 + i, midy, 120 + i, midy + 23);
line(0 + i, midy + 23, 18 + i, midy + 23);
arc(30 + i, midy + 23, 0, 180, 12);
line(42 + i, midy + 23, 78 + i, midy + 23);
arc(90 + i, midy + 23, 0, 180, 12);
line(102 + i, midy + 23, 120 + i, midy + 23);
line(28 + i, midy, 43 + i, midy - 15);
line(43 + i, midy - 15, 57 + i, midy - 15);
line(57 + i, midy - 15, 57 + i, midy);
line(57 + i, midy, 28 + i, midy);
line(62 + i, midy - 15, 77 + i, midy - 15);
line(77 + i, midy - 15, 92 + i, midy);
line(92 + i, midy, 62 + i, midy);
line(62 + i, midy, 62 + i, midy - 15);
floodfill(5 + i, midy + 22, YELLOW);
setcolor(BLUE);
setfillstyle(SOLID_FILL, DARKGRAY);

circle(30 + i, midy + 25, 9);


circle(90 + i, midy + 25, 9);
floodfill(30 + i, midy + 25, BLUE);
floodfill(90 + i, midy + 25, BLUE);

delay(100);
}

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

Conclusion:
Thus by choosing this project we learned and got to implement new functions
Particularly setfillstyle() and arc().

References:
www.techcrashcourse.com
Javatpoint

You might also like