Skip to content

Dnafivuq/movement-demo

Repository files navigation

Smooth Movement with Accelerated Motion and Air Resistance

Implementation of physics model of smooth movement using acceleration, with an upper bound caused by air resistance.

Equation

$$F_o = F - (F_f + F_{ar})$$
  • $F_o$ is the output force,
  • $F$ is the applied force,
  • $F_f$ is the friction force,
  • $F_{ar}$ is the additional resistance force.

The equation for acceleration output is:

$$m a_o = m a - \mu m g - k v^2$$

which can be rewritten as:

$$a_o = a - \mu g - \frac{k v^2}{m}$$

Since $k$ is an air resistance constant for the object, we can absorb $m$ into $k$ and simplify:

$$a_o = a - \mu g - k v^2$$

Thus giving the final form of equation.

where:

  • $a_o$ is the output acceleration,
  • $a$ is the applied force acceleration,
  • $\mu$ is a coefficient friction,
  • $g$ is gravitational acceleration,
  • $k$ is the modified air resistance constant,
  • $v$ is velocity.

Repository content

  • Graphs showing the relationship between acceleration, velocity, and distance traveled,
  • Pygame demo of movable object.

Demo keybinds

Use wsad for movement, hold b for faster movement (sprint).

How to run

Prefered python version Python 3.12.3 or newer.

Install required dependencies and libraries

pip install -r requirements.txt 

To run the demo use

python3 main.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published