Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Ball Bounce Simulation under gravity using C++ and SDL
New
18 students

Ball Bounce Simulation under gravity using C++ and SDL

Hands on coding Ball Bounce Simulation using C++ and SDL graphics library
Last updated 6/2026
English

What you'll learn

  • C++ program to simulate a ball falling under gravity
  • Use of C++ and SDL graphics library to animate or visualize the balls movement
  • Physics equations to calculate velocity and displacement of ball under gravity
  • Physical measurement units to Computer screen pixel conversion

Course content

3 sections9 lectures1h 15m total length
  • Introduction2:24
  • Derivation of formula for Ball velocity and displacement6:03
  • Time sampling and graphics theory for simulation5:12

Requirements

  • Basic knowledge of C++ programming

Description

Solving interesting problems and implementing them in C++ is a good way to learn the C++ language.

In this course, we understand the Physics and theory behind the motion of the Ball falling under gravity. We understand the equations for velocity and displacement of the ball at different intervals of time. Then we programmatically sample the time and render the position of the ball, calculated using above equations.

We use SDL graphics library to visualize the simulation.


Structure of the course:

1. Theory and Physics behind Ball fall and bounce under gravity

2. Program to calculate velocity and displacement of the ball

3. SDL graphics programming in C++

4. Final simulation program in C++


Different C++ & programming concepts used during software development:

classes, public & private variables, functions, constructors, compilation and running with g++, SDL graphics library (-lSDL2)

SDL graphics functions used: SDL_CreateWindow, SDL_CreateRenderer, SDL_SetRenderDrawColor, SDL_RenderClear, SDL_RenderPresent, etc. draw circle using 'midpoint circle algorithm'.

Future enhancements Possible: Multiple balls falling under gravity using multiple threads in C++, option to change the gravity to simulate different planets, Ball falling at an angle.

Applications of simulation: educational tool to learn physics or mathematics concepts visually, Product design or engineering R&D in aerodynamic, fluid dynamics, etc.

Who this course is for:

  • Entry level C++ Software Engineers
  • Mid level C++ Software Engineers