Professional Documents
Culture Documents
In this program, we will draw a red color ball move it vertically up and
down like a bouncing ball. We will use below mentioned functions in this
program.
Function Description
initgraph It initializes the graphics system by loading the passed graphics driver
then changing the system into graphics mode.
getmaxx It returns the maximum X coordinate in current graphics mode and driver.
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.
floodfill It is used to fill a closed area with current fill pattern and fill color. It takes
any point inside closed area and color of the boundary as input.
cleardevice It clears the screen, and sets current position to (0, 0).
closegraph It unloads the graphics drivers and sets the screen back to text mode.
Coding for Bouncing-Ball program:-
#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, "C:\\TC\\BGI");
while (!kbhit()) {
if(y >= getmaxy()-30 || y <= 30)
flag = !flag;
/* draws the gray board */
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
circle(x, y, 30);
floodfill(x, y, RED);
/* clears screen */
cleardevice();
if(flag){
y = y + 5;
} else {
y = y - 5;
}
}
getch();
closegraph();
return 0;
}
Program Output
Here is the screenshot of bouncing ball.
JSPM’s
JAYAWANTRAO SAWANT
POLYTECHNIC, Handewadi Road,
Hadapsar, Pune-28 Department of
Computer Engineering Academic Year
2021-22
MICROPROJECT
COMPUTER GRAPHICS
TITLE OF THE PROJECT
Certificate
This is to certify that: Mr./Ms.: Shreyas Vilas Bagate, Aditya
Suresh Chorghade, Kartik Bharat Choudhari, Gaurav Mangesh
Kamthe of ‘3rd semester of diploma in computer engineering
of institute Jaywantrao Sawant Polytechnic (Code 0711) has
completed the micro project satisfactorily in subject –
CGR(22318) for the academic year 2021-2022 as prescribed
in the curriculum.
Place: Hadapsar, Pune
Enrollment No: 2007110635 2007110548
2007110 623 2007110246
Exam Seat No:
Date: 31/12/21
MICRO PROJECT
MICRO PROJECT GROUP DETAILS
Sr Roll
Name Enrollment No. Seat No.
No. No.
Sr No. Content
1 Certificate
2 Group Details
3 Index
4 Introduction
5 function
7 Output
BOUNCING BALL PROJECT