Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Yoo! the ball bounce is epic. Do you have the source code for this? I really want to see the physics..

(1 edit)

Source code is here: https://github.com/ALaevens/Cannon-Game-SDL2
The relevant code is the collideGround function in src/scenes/CannonScene.cpp and the Kinematics component in include/Components/CKinematics.hpp.

In short, the kinematics component keeps track of a vector velocity and acceleration and uses it to update the position every frame. On collision with the ground, the ball is slowed down a bit horizontally and I flip the vertical velocity (also reduced by a little bit) to give the bounce effect. I had plans of implementing collision between the balls but never got around to it.

Thanks so much!