CGR Microproject
CGR Microproject
Certificate
This is to certify that Mr. Dnyaneshwar Dilip Garad with Roll No-35 has successfully
completed Micro-project in course Data Structure Using C (312301)for the academic year
2024-25 Microproject is completing Third Semester of Diploma Programme in Information
Technology from institute, PK Technical Campus Pune
1
Computer Graphics
In this case, we'll be using C programming along with the graphics.h library to create
this simulation. Though graphics.h is an older library primarily used in Turbo C/C++ IDE
for DOS and Windows environments, it is still useful for understanding fundamental
concepts of graphical rendering and motion in programming.
Let's break down the key concepts and details involved in creating a bouncing ball
simulation
1. A bouncing ball simulation demonstrates how an object moves and interacts with
the environment in a 2D space. The ball in this case moves across the screen, and
its movement is altered when it comes in contact with any boundary. The most
straightforward version of this simulation involves the ball moving at constant
speed, bouncing back whenever it hits one of the four walls of the window.
2
Computer Graphics
Features:
3
Computer Graphics
6. Exit Condition:
o When a key is pressed (kbhit() returns true), the loop ends and the program exits
the graphics mode using closegraph().
REQUIREMENTS:-
1. Turbo C++ IDE (or Turbo C++ Compiler) with access to the graphics.h library, which is
used for drawing shapes and animations.
2. The BGI files (Borland Graphics Interface) should be set up correctly in Turbo C++.
PROGRAM :-
#include <graphics.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#define LEFT 0
#define TOP 0
// Ball properties
int ballRadius = 20; int x = 320, y = 240; // Initial position of the ball
directions
4
Computer Graphics
floodfill(x, y, WHITE);
void moveBall() {
positions
x += xSpeed;
y += ySpeed;
direction
direction
int main() {
5
Computer Graphics
while (!kbhit()) {
movement
closegraph();
return 0;
6
Computer Graphics
Result :