Movement: Difference between revisions

No edit summary
Marked this version for translation
 
Line 3: Line 3:
<translate>
<translate>


<!--T:1-->
Movement is one of the core aspects of Teeworlds and DDrace.
Movement is one of the core aspects of Teeworlds and DDrace.




== Basics ==
== Basics == <!--T:2-->




=== Gravity ===
=== Gravity === <!--T:3-->


<!--T:4-->
Every tick the acceleration of 0.5 is added to the y velocity (downwards) due to gravity.
Every tick the acceleration of 0.5 is added to the y velocity (downwards) due to gravity.




=== Jumping ===
=== Jumping === <!--T:5-->


<!--T:6-->
Ground jumping sets a tee's y velocity to -13.2, scaled by a value.
Ground jumping sets a tee's y velocity to -13.2, scaled by a value.


<!--T:7-->
Air jumping (double-jump) sets a tee's y velocity to -12.0, scaled by a value.
Air jumping (double-jump) sets a tee's y velocity to -12.0, scaled by a value.


<!--T:8-->
Jumping will ''set'' the y velocity, cancelling out any previous upwards or downwards velocity. This is very useful in scenarios where you need to halt large vertical impulses.
Jumping will ''set'' the y velocity, cancelling out any previous upwards or downwards velocity. This is very useful in scenarios where you need to halt large vertical impulses.
</translate>
</translate>
Line 26: Line 31:




=== Horizontal Movement: ===
=== Horizontal Movement: === <!--T:9-->


<!--T:10-->
* Pressing nothing:
* Pressing nothing:
** Ground: Every tick <syntaxhighlight lang="c++" inline="">velocity.x = velocity.x * 0.5</syntaxhighlight>
** Ground: Every tick <syntaxhighlight lang="c++" inline="">velocity.x = velocity.x * 0.5</syntaxhighlight>
Line 39: Line 45:




<!--T:11-->
Friction is ignored when holding down a key. So, at high velocities, pressing nothing will slow a tee down faster than moving in the opposite direction, as the friction will have an exponential slowdown compared to the <code>a/d</code> linear slowdown.
Friction is ignored when holding down a key. So, at high velocities, pressing nothing will slow a tee down faster than moving in the opposite direction, as the friction will have an exponential slowdown compared to the <code>a/d</code> linear slowdown.




== Advanced ==
== Advanced == <!--T:12-->




=== Max Speed ===
=== Max Speed === <!--T:13-->


<!--T:14-->
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).


<!--T:15-->
<code>src/game/gamecore.cpp</code> (before calculating new position from velocity):<syntaxhighlight lang="c++">
<code>src/game/gamecore.cpp</code> (before calculating new position from velocity):<syntaxhighlight lang="c++">
if(length(m_Vel) > 6000)
if(length(m_Vel) > 6000)
Line 54: Line 63:
</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.
</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.


<!--T:16-->
The speed is rounded down to a precision of <math>\frac{1}{256}</math> 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 <math>\frac{1}{256}</math> every tick. This is causing the tee to stop moving horizontal when having too much speed.


Line 61: Line 71:




=== Corner Skimming ===
=== Corner Skimming === <!--T:17-->


<!--T:18-->
A tee is considered on the ground only due to its position and distance to the ground - it does not require the tee to have downwards velocity. So, it is possible for a tee to be "grounded" while traveling upwards, as long as the tee skims the corner of a tile.  
A tee is considered on the ground only due to its position and distance to the ground - it does not require the tee to have downwards velocity. So, it is possible for a tee to be "grounded" while traveling upwards, as long as the tee skims the corner of a tile.  


<!--T:19-->
Corner skimming:
Corner skimming:


<!--T:20-->
* allows a tee to refresh its double-jump (useful when skipping maps such as [https://ddnet.org/maps/Impetuous Impetuous]).
* allows a tee to refresh its double-jump (useful when skipping maps such as [https://ddnet.org/maps/Impetuous Impetuous]).
* can apply ground acceleration and max speed to a tee for a short amount of time (assuming the tee's horizontal midair speed is less than the maximum ground speed prior to corner skimming)
* can apply ground acceleration and max speed to a tee for a short amount of time (assuming the tee's horizontal midair speed is less than the maximum ground speed prior to corner skimming)




<!--T:21-->
Corner skimming is not often intentionally used in map parts (except for maps such as [https://ddnet.org/maps/Short-32-And-32-Precise-32-7/ Short and Precise 7]), but can be used in short speedruns as small optimizations.
Corner skimming is not often intentionally used in map parts (except for maps such as [https://ddnet.org/maps/Short-32-And-32-Precise-32-7/ Short and Precise 7]), but can be used in short speedruns as small optimizations.
</translate>
</translate>
Line 76: Line 90:
<translate>
<translate>


=== Elevated Jump ===
=== Elevated Jump === <!--T:22-->


<!--T:23-->
A ground jump can be performed even if the tee is a few subunits above the ground.  
A ground jump can be performed even if the tee is a few subunits above the ground.  
</translate>
</translate>
[[Category:Game-Mechanic{{#translation:}}]]
[[Category:Game-Mechanic{{#translation:}}]]