Movement: Difference between revisions

From DDraceNetwork
("Import pages by Zwelf from previous wiki")
 
m (the nowiki tag is ugly, try to fix the kbd template instead)
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:


* Pressing nothing:
* Pressing nothing:
** Air: Every tick <code>velocy.x = velocy.x * 0.95</code>
** Ground: Every tick <syntaxhighlight lang="c++" inline>velocity.x = velocity.x * 0.5</syntaxhighlight>
** Ground: Every tick <code>velocy.x = velocy.x * 0.5</code>
** Air: Every tick <syntaxhighlight lang="c++" inline>velocity.x = velocity.x * 0.95</syntaxhighlight>
* Pressing key in opposite direction:
* Pressing key in opposite direction:
** Ground: Every Tick horizontal velocity decreases by 2 until 10 in the opposite direction is reached
** Ground: Every tick the horizontal velocity decreases by 2 until 10 in the opposite direction is reached
** Air: Every Tick horizontal velocity decreases by 1.5 until -5 in the opposite direction is reached
** Air: Every tick the horizontal velocity decreases by 1.5 until 5 in the opposite direction is reached
* Horizontal speed up by pressing <code>a</code> or <code>d</code>:
* Horizontal speed up by pressing {{Kbd|a}} or {{Kbd|d}}:
** Ground: Every Tick horizontal velocity increases by 2 until 10 is reached
** Ground: Every tick the horizontal velocity increases by 2 until 10 is reached
** Air: Every Tick horizontal velocity increases by 1.5 until -5 is reached
** Air: Every tick the horizontal velocity increases by 1.5 until 5 is reached


== Max speed ==
== Max speed ==
Line 17: Line 17:
Max speed: 6000 Sub-tiles/Tick (+speedup in one tick, e.g. gravity, jetpack, explosion).
Max speed: 6000 Sub-tiles/Tick (+speedup in one tick, e.g. gravity, jetpack, explosion).


<code>src/game/gamecore.cpp</code> (before calculating new position from velocity):
<code>src/game/gamecore.cpp</code> (before calculating new position from velocity):<syntaxhighlight lang="c++">
 
if(length(m_Vel) > 6000)
<source lang="c">if(length(m_Vel) > 6000)
     m_Vel = normalize(m_Vel) * 6000;
     m_Vel = normalize(m_Vel) * 6000;</source>
</syntaxhighlight>This is the bottleneck in vertical movement. In horizontal movement a “ramp”-Value is multiplied to the horizontal speed. Causing the tee to slow down and stop when getting too fast. This is most commonly observed in speed ups.
This is the bottle neck in vertical movement. In horizontal movement a “ramp”-Value is multiplied to the horizontal speed. Causing the tee to slow down and stop when getting too fast. This is most commonly observed in speed ups.


The speed is rounded down to a precision of 1/256 every tick. This is causing the tee to stop moving horizontal when having too much speed.
The speed is rounded down to a precision of 1/256 every tick. This is causing the tee to stop moving horizontal when having too much speed.

Revision as of 14:33, 27 January 2021

Gravitation: Every tick the acceleration of 0.5 is added to the y velocity (downwards).

Input (horizontal movement):

  • Pressing nothing:
    • Ground: Every tick velocity.x = velocity.x * 0.5
    • Air: Every tick velocity.x = velocity.x * 0.95
  • Pressing key in opposite direction:
    • Ground: Every tick the horizontal velocity decreases by 2 until 10 in the opposite direction is reached
    • Air: Every tick the horizontal velocity decreases by 1.5 until 5 in the opposite direction is reached
  • Horizontal speed up by pressing a or d:
    • Ground: Every tick the horizontal velocity increases by 2 until 10 is reached
    • Air: Every tick the horizontal velocity increases by 1.5 until 5 is reached

Max speed

Max speed: 6000 Sub-tiles/Tick (+speedup in one tick, e.g. gravity, jetpack, explosion).

src/game/gamecore.cpp (before calculating new position from velocity):

if(length(m_Vel) > 6000)
    m_Vel = normalize(m_Vel) * 6000;

This is the bottleneck in vertical movement. In horizontal movement a “ramp”-Value is multiplied to the horizontal speed. Causing the tee to slow down and stop when getting too fast. This is most commonly observed in speed ups.

The speed is rounded down to a precision of 1/256 every tick. This is causing the tee to stop moving horizontal when having too much speed.

Todo: * convert sub-tiles/tick into tiles/sec * find max vel und real max vel (from where would a constant function fit) * find speed, where the tee stops moving * write about ramp speed, and add diagram