Python | Making an object jump in PyGame
Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. Now, it’s up to the imagination or necessity of developer, what type of game he/she wants to develop using this toolkit.
So, in this article, we will learn how to make an object jump using PyGame library in Python.
There is basic formula from classical mechanics to make an object jump.
F = 1/2 * m * v^2
Where F is the force up/down, m is the mass of the object and v is the velocity. The velocity goes down over time because when the object jumps the velocity will not increase more in this simulation. When object reaches the ground, the jump ends. If
isjump variable is True or False it indicates object is jumping or not. If
isjump is True, object position will be updated according to the above formula.