CG - Mini Project Report
CG - Mini Project Report
Guide name:
Mrs. Prajakta A. Puranik
Project name:
Man sailing in a boat in the rain
Technology/Platform/Language:
Dev-cpp, C++, OOP Concepts, Gaming, Animation.
Problem statement:
Write a C++ program to animate a man sailing in a boat in the rain.
Theory:
a) Animation:
Animation refers to the movement on the screen of the display device created by displaying a
sequence of still images. Animation is the technique of designing, drawing, making layouts and
preparation of photographic series which are integrated into the multimedia and gaming products.
Animation connects the exploitation and management of still images to generate the illusion of
movement. A person who creates animations is called animator. He/she use various computer
technologies to capture the pictures and then to animate these in the desired sequence. Animation
includes all the visual changes on the screen of display devices.
Algorithm:
Step 1: Initialize the graphics system.
Step 2: Using for loop make the line visible and invisible with changing x coordinate to show
that the line is moving forward, do this for the body of the man, the boat and the waves as well.
Step 3: Using DDA algorithm draw the rain in the background.
Step 4: After the man reaches the endpoint using for loop, stop the execution of the code.
Code:
#include<iostream>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
using namespace std;
class boatman
{
int rhx,rhy;
public:
void draw(int,int);
void draw(int);
void waves(int);
};
void boatman::draw(int i)
{
waves(i);
if(i%2)
{
setcolor(GREEN);
line(35+i,310,25+i,330);
line(35+i,310,50+i,330);
delay(20);
}
else
{
setcolor(GREEN);
line(35+i,310,40+i,330);
delay(20);
}
setcolor(GREEN);
line(35+i,340,35+i,310);
circle(35+i,300,10);
setcolor(RED);
line(-12+i,340,88+i,340);
arc(38+i,330,192,348,50);
}
void boatman::waves(int i)
{
setcolor(BLUE);
if(i%2)
{
for(int j=0;j<650;j+=20)
arc(j,370,192,348,10);
}
else
{
for(int j=0;j<650;j+=20)
arc(j+10,370,192,348,10);
}
}
void boatman::draw(int x,int y)
{
int j;
rhx=x;
rhy=y;
for
(j=0;j<100;j++)
{
setcolor(CYAN);
outtextxy(rand()%rhx,rand()%(rhy-50),"*");
setcolor(WHITE);
}
}
int main()
{
int gd=DETECT,gm;
int rhx,rhy,j,i;
boatman obj;
initgraph(&gd,&gm,"");
for(i=0;i<500;i+=5)
{
obj.draw(i);
delay(10);
rhx=getmaxx();
rhy=getmaxy();
obj.draw(rhx,rhy);
delay(100);
cleardevice();
}
getch();
}
Output Screenshot:
Video Links:
Google Drive: https://drive.google.com/file/d/1RNUmEKKwPzo0kybvwaIetHNux4Djw4-
9/view?usp=sharing
Youtube: https://youtu.be/Oggcevjnm5k