Dev C++ Bouncy Ball

Source Code For Bouncing Ball In 3d Using Opengl Codes and Scripts Downloads Free. Accounting source code for Delphi. Metis is an open source project management module developed in PHP using MySQL for a database backend.

Write a program in C for bouncing ball animation using graphics.h header file

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.

FunctionDescription
initgraphIt initializes the graphics system by loading the passed graphics driver then changing the system into graphics mode.
getmaxxIt returns the maximum X coordinate in current graphics mode and driver.
setcolorIt 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.
setfillstyleIt sets the current fill pattern and fill color.
circleIt draws a circle with radius r and centre at (x, y).
floodfillIt 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.
cleardeviceIt clears the screen, and sets current position to (0, 0).
kbhitIt is used to determine whether a key is pressed or not. It returns a non-zero value if a key is pressed otherwise zero.
delayIt is used to suspend execution of a program for a M milliseconds.
closegraphIt unloads the graphics drivers and sets the screen back to text mode.

C program for bouncing ball graphics animation

In this program, we first draw a red color ball on screen having center at (x, y) and then erases it using cleardevice function. We again draw this ball at center (x, y + 5), or (x, y - 5) depending upon whether ball is moving down or up. This will look like a bouncing ball. We will repeat above steps until user press any key on keyboard.

Program Output

Dev C++ Bouncy Ball Video

Here is the screenshot of bouncing ball. Dev c++ bouncy balls
Related Topics
C graphics program for moving car animation
C program to draw pie chart using graphics
C program to draw sine wave graph on screen
C program to draw 3D bar graph on screen
C graphics program to draw digital clock
C Program to draw concentric circles screen
C Program to draw a hut using graphics
List of all C Graphics Programs

hi guys,

i am working on a new java program, the program consists of a ball, bouncing around the applet, i have created button to control the ball, one to stop the ball bouncing, another to resume the ball boucing and another to reverse the direction of the ball bouncing,

but i am trying to re-design the buttons so that i can steer the direction of ball / drag the ball with the mouse around the applet.
the code so far is below...

any advice and help, would be appreciated a lot.....

thx for your time,
tc..

Edited by happygeek: fixed formatting
  • 4 Contributors
  • forum 8 Replies
  • 896 Views
  • 2 Years Discussion Span
  • commentLatest Postby jadhav vijayLatest Post

Dev C++ Bouncy Ball 2

D boss