You are on page 1of 21

UNITED INSTITUTE OF MANAGEMENT

Program on :Animation like home & Raining


MCA 1st Year || Section A || Group No. 8

Presented By : Submitted To:


Deepak Verma Mr. Ashutosh Pandey
Deepak Pandey Assistant Professor
Devi Prasanna Pati UIM, Prayagraj
Diksha Singh
Chirag Pandey
Table of Content
• INTRODUCTION
• PROGRAM : ANIMATION LIKE HOME & RAINING
• ALGORITHM
• SIMPLE FLOWCHART
• HEADER FILE
• FUNCTION
• CODING
• OUTPUT
Introduction
Creating an animation like a house and raining in C requires
the use of a graphics library like Turbo C or Borland C++
Builder. These libraries provide the necessary functions for
drawing shapes, lines, and managing the animation loop.
Here's a simplified example using Turbo C.
Program : Animation like home &
Raining
Algorithm
1. Initialize graphics using the initgraph function.
2. Loop 700 times (for animation purposes):
a. Draw the home body using the line function.
b. Draw the land line at the bottom of the screen.
c. Draw the gate using the line function.
d. Draw window using the line function.
e. Draw the moon using the circle function.
f. Draw clouds using the circle function.
Cont……
Algorithm
g. Generate random raindrops using the outtextxy
function.
h. Delay for a short period and then clear the
screen for the next frame.
3. Close the graphics using the closegraph function.
Simple flowchart
Start
V
Draw Land Line
Initialize
Graphics
Draw Gate

Loop 700
times Draw Window

Draw Home Body Draw Moon


Cont……
Simple flowchart
Draw Clouds

Generate
Raindrops

Delay and Clear

End
Header file
• Stdio.h
The header file stdio. h allows us to conduct input and output operations
in C. Printf() and scanf() are functions that are used to display output
and receive user input, respectively.

• Conio. h
Conio. h full form stands for “Console Input & Output”. conio. h in C
programming is a header file that provides the function of console input
and output.
Cont……
Header file
• Graphics. h
The graphics. h header file provides access to a simple graphics
library that makes it possible to draw lines, rectangles, ovals, arcs,
polygons, images, and strings on a graphical window.

• Stdlib. h
Stdlib. h stands for Standard Library. It has information related to
input/output functions. It has information related to memory
allocation/free functions.
Function
• lnitgraph()
Initializes the graphics system by loading a graphics driver
from disk and putting the system into graphics mode.

• Line()
Line is a library function of graphics. h in c programming
language which is used to draw a line from two coordinates.
Function
• Circle()
The header file graphics. h contains circle() function which
draws a circle with center at (x, y) and given radius.

• Getmaxx()
Getmaxx returns the maximum (screen-relative) x value for the
current graphics driver and mode.
Function
• Outtextxy()
Outtextxy displays a text string in the viewport at the given position (x,
y), using the current justification settings and the current font, direction,
and size.

• Random()
The random() function is a library function that generates the random
number in the range
Function
• Delay()
Delay function is used to suspend execution of a program for a
particular time.

• Cleardevice()
Cleardevice erases the entire graphics screen and moves the CP (current
position).

• Closegraph()
Closegraph function which closes the graphics mode.
Coding
#include<stdio.h>
#include<conio.h> Library
#include<graphics.h>
#include<stdlib.h>
void main()
{
int gd=DETECT,gm,x,y,j,i;
initgraph(&gd,&gm,"BGI");

for(i=0; i<700; i++) //Rain Movement


{
Cont……
Coding
//Home Body
line(100,100,200,200);//1 Home Body
line(200,200,400,200);//2
line(400,200,300,100);//3 4
line(100,100,300,100);//4 5 3
line(100,100,3,200);//5 1
line(200,200,200,300);//6
2
line(400,200,400,300);//7 8
6 7
line(3,200,2,300);//8

Cont……
Coding
//Land
Land
line(0,300,1400,300);//9
//Gate
line(70,220,70,300);//10
line(130,220,130,300);//11 Gate
line(70,220,130,220);//12 12 15

//window 10 11 14 13
16
line(350,270,350,230);//13
9
line(250,270,250,230);//14
Window
line(250,230,350,230);//15
line(250,270,350,270);//26
Cont……
Coding
//moon Moon
circle(500,100,40);/17
//cloud Cloud
circle(100,1,30);//18
circle(40,1,50); 18
circle(160,5,20);
circle(220,1,40); 17

circle(280,0,20);
circle(350,10,40);
circle(410,1,20);
circle(600,1,50);
circle(530,1,20); Cont……
Coding
//rain 19 Rain
x= getmaxx(); //Maximum x Coordinate
y= getmaxy(); //Maximum y Coordinate
for(j=0;j<100; j++)
{
outtextxy(random(x),random(y),"|");
}
19
delay(5);
cleardevice();
}
getch();
closegraph();

}
Output
Thank You

You might also like