You are on page 1of 8

BOUNCING – BALL PROJECT

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.

setfillstyle It sets the current fill pattern and fill color.

circle It draws a circle with radius r and centre at (x, y).

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).

kbhit It is used to determine whether a key is pressed or not. It returns a non-


zero value if a key is pressed otherwise zero.

delay It is used to suspend execution of a program for a M milliseconds.

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");

/* get mid positions in x and y-axis */


x = getmaxx()/2;
y = 30;

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);

/* delay for 50 milli seconds */


delay(50);

/* 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

BOUNCING BALL PROJECT

PROGRAM: CO PROGRAM CODE:CO21


Course: CGR Course Code: 22318
Class: SYCO3

Project Guide: Mr.Shende S.S.


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

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

Subject Teacher Head of Department Principal

MICRO PROJECT
MICRO PROJECT GROUP DETAILS

Sr Roll
Name Enrollment No. Seat No.
No. No.

1 33 Shreyas Vilas Bagate 2007110548

2 54 Aditya Suresh Chorghade 2007110635

3 07 Kartik Bharat Choudhari 2007110246

4 48 Gaurav Mangesh Kamthe 2007110623


INDEX

Sr No. Content

1 Certificate

2 Group Details

3 Index

4 Introduction

5 function

6 Program On bouncing ball

7 Output
BOUNCING BALL PROJECT

Brief Introduction Computer graphics are pictures and films


created using computers. Usually, the term refers to
computer-generated image data created with the help of
specialized graphical hardware and software. It is a vast and
recently developed area of computer science. The phrase
was coined in 1960, by computer graphics researchers Verne
Hudson and William Fetter of Boeing. It is often abbreviated
as CG, though sometimes erroneously referred to as
computer-generated imagery (CGI). Some topics in computer
graphics include user interface design, sprite graphics, vector
graphics, 3D modelling, shaders, GPU design, implicit surface
visualization with ray tracing, and computer vision, among
others. Computer graphics is responsible for displaying art
and image data effectively and meaningfully to the
consumer. It is also used for processing image data received
from the physical world. Computer graphics development has
had a significant impact on many types of media and has
revolutionized animation, movies, advertising, video games,
and graphic design in general.

You might also like