[Tech Demo] Character physics

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

[Tech Demo] Character physics

Post by Roland_Yonaba »

Hi folks,

Here is a technical demo on which I spent a few hours.
It was originally inspired by Kikito's thread: Interesting article about gravity in games.

Image

The purpose of this demo, at last when I started it, was to:
  • show various ways to mimic real physics for entitites motion in games without using a dedicated physics third-party library. The motion would include linear motion, and jump as well.
  • Study/compare and benchmarks various time - integration methods (in the case of constant acceleration), and how they perform compared to real integration they all try to approximate, with regards to the framerate.
So here you go.
In this demo, you can move those 6 different entities with directional arrows.
You aso make them jump with space key. You can also cap down/cap up the framerate (between preset bounds, 300 and 3 fps) and see the incidence on the entities jump curve. And compare them aswell as opposed to the real integration curve.

Important note: You can hide/unhide an entity and its time-integration method results by clicking on the corresponding rectangle on the legend (upper right).

I have included six different time-integration methods, which are Implicit Euler, Explicit Euler, Improved Euler, Heun, 4th-order Runge Kutta and Verlet (aka Leapfrog).

The simple physical model I set has some constraints: velocity is clamped to a maximum absolute value (per-component). It also takes into account the mass, but actually, all agents have a unit-mass.
Ground friction is included too, but there is no air friction, so that the jump curve remains parabolic.

Some statistics are evaluated and displayed such as the actual acceleration and velocity for each entity, the jump height, range, and the accuracy of the approximation with respect to the real integration method. You can compare them and conclude on which method have the best results according to the framerate.

Source code is Mit-Licensed, and hosted at github.
Love file attached.

Feel free to try, and give your opinion, suggestions.
Thanks in advance.
Attachments
character-physics-demo_r3.love
Character_Physics_Demo (r3)
(18.51 KiB) Downloaded 348 times
Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests