Movement: Difference between revisions
No edit summary |
Marked this version for translation |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | <languages/> | ||
{{Stub}} | |||
<translate> | |||
<!--T:1--> | |||
Movement is one of the core aspects of Teeworlds and DDrace. | |||
== Basics == <!--T:2--> | |||
=== Gravity === <!--T:3--> | |||
<!--T:4--> | |||
Every tick the acceleration of 0.5 is added to the y velocity (downwards) due to gravity. | |||
=== Jumping === <!--T:5--> | |||
<!--T:6--> | |||
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. | |||
<!--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. | |||
</translate> | |||
{{Todo|Find the bps value or scaled coefficient for these values (same with the horizontal movement, these values are not in bps)}} | |||
<translate> | |||
=== 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> | ||
** Air: Every tick <syntaxhighlight lang="c++" inline>velocity.x = velocity.x * 0.95</syntaxhighlight> | ** 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 the 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 | ||
Line 13: | Line 42: | ||
* Horizontal speed up by pressing {{Kbd|a}} or {{Kbd|d}}: | * Horizontal speed up by pressing {{Kbd|a}} or {{Kbd|d}}: | ||
** Ground: Every tick the 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 the horizontal velocity increases by 1.5 until 5 is reached | ** Air: Every tick the horizontal velocity increases by 1.5 until 5 is reached\ | ||
<!--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. | |||
== Advanced == <!--T:12--> | |||
== Max | === 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 24: | 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. | ||
The speed is rounded down to a precision of 1/ | <!--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. | |||
</translate> | |||
{{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}} | |||
<translate> | |||
=== 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. | |||
<!--T:19--> | |||
Corner skimming: | |||
<!--T:20--> | |||
* 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) | |||
<!--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. | |||
</translate> | |||
{{Todo|add gif}} | |||
<translate> | |||
=== Elevated Jump === <!--T:22--> | |||
[[Category:Game-Mechanic]] | <!--T:23--> | ||
A ground jump can be performed even if the tee is a few subunits above the ground. | |||
</translate> | |||
[[Category:Game-Mechanic{{#translation:}}]] |
Latest revision as of 19:12, 11 February 2023
Movement is one of the core aspects of Teeworlds and DDrace.
Basics
Gravity
Every tick the acceleration of 0.5 is added to the y velocity (downwards) due to gravity.
Jumping
Ground jumping sets a tee's y velocity to -13.2, scaled by a value.
Air jumping (double-jump) sets a tee's y velocity to -12.0, scaled by a value.
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.
Horizontal Movement:
- Pressing nothing:
- Ground: Every tick
velocity.x = velocity.x * 0.5
- Air: Every tick
velocity.x = velocity.x * 0.95
- Ground: Every tick
- 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\
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 a/d
linear slowdown.
Advanced
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 every tick. This is causing the tee to stop moving horizontal when having too much speed.
Corner Skimming
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.
Corner skimming:
- allows a tee to refresh its double-jump (useful when skipping maps such as 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)
Corner skimming is not often intentionally used in map parts (except for maps such as Short and Precise 7), but can be used in short speedruns as small optimizations.
Elevated Jump
A ground jump can be performed even if the tee is a few subunits above the ground.