physic simulation bouncing ball

if I want to make the ball fall on flat surface and then bounce, do I have to create the flat surface?

Hello, I want to make the ball falling at flat surface and then bounce until it stop just like in the real life. I’m using opengl glut in codeblock. I’m still the beginner. What I understand, I need create the class for ball and flat surface. Then I need to implement the physics formula into the coding. my problem is, I don’t know how to code the formula. how to set the maxHeight of ball, the speed and then when the ball at the surface, it will bounce until finally stop due to friction and energy loss.

Yes - you will need to create a flat surface. And - you will need to create the ball. Both of these things can be done with 1 line of code using GLUT routines. My recommendation is to first write a simple GLUT/OPENGL program that displays these 2 objects in the center of the window. Don’t worry about motion until you can this. When this is done, if you still need help, post the code to the forum. You’ll get more help when you’ve shown the forum that you’ve put some effort into the problem.

If you’re talking about doing this in 3D, maybe if you’re not sure how to do this, try 2D first?

One thing with the Physics that I can tell you from the top of my head, is that the Acceleration will be constant (gravity). So speed will increase (acceleration) at a constant rate. Usually this is added every frame.

You may have inspired me to try this in 2D today. Thanks and good job. Best of luck in all your OpenGL Endeavors, also, I have a YouTube channel for OpenGL Tutorials, check out the link below: