Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions tutorials/2d/2d_movement.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ In this scenario, you want the user to press the four directional keys (up/left/
or W/A/S/D) and move in the selected direction. The name "8-way movement" comes from the
fact that the player can move diagonally by pressing two keys at the same time.

.. image:: img/movement_8way.gif
.. video:: video/movement_8way.webm
:alt: 8-way movement
:autoplay:
:loop:
:muted:
:align: default
:width: 100%
:nocontrols:

Add a script to the character body and add the following code:

Expand Down Expand Up @@ -98,7 +105,14 @@ This type of movement is sometimes called "Asteroids-style" because it resembles
how that classic arcade game worked. Pressing left/right rotates the character,
while up/down moves it forward or backward in whatever direction it's facing.

.. image:: img/movement_rotate1.gif
.. video:: video/movement_rotate_keyboard.webm
:alt: Rotation + movement
:autoplay:
:loop:
:muted:
:align: default
:width: 100%
:nocontrols:

.. tabs::
.. code-tab:: gdscript GDScript
Expand Down Expand Up @@ -160,7 +174,14 @@ This style of movement is a variation of the previous one. This time, the direct
is set by the mouse position instead of the keyboard. The character will always
"look at" the mouse pointer. The forward/back inputs remain the same, however.

.. image:: img/movement_rotate2.gif
.. video:: video/movement_rotate_mouse.webm
:alt: Rotation + movement (mouse)
:autoplay:
:loop:
:muted:
:align: default
:width: 100%
:nocontrols:

.. tabs::
.. code-tab:: gdscript GDScript
Expand Down Expand Up @@ -219,7 +240,14 @@ Click-and-move
This last example uses only the mouse to control the character. Clicking
on the screen will cause the player to move to the target location.

.. image:: img/movement_click.gif
.. video:: video/movement_click.webm
:alt: Click-and-move
:autoplay:
:loop:
:muted:
:align: default
:width: 100%
:nocontrols:

.. tabs::
.. code-tab:: gdscript GDScript
Expand Down
Binary file removed tutorials/2d/img/movement_8way.gif
Binary file not shown.
Binary file removed tutorials/2d/img/movement_click.gif
Binary file not shown.
Binary file removed tutorials/2d/img/movement_rotate1.gif
Binary file not shown.
Binary file removed tutorials/2d/img/movement_rotate2.gif
Binary file not shown.
Binary file added tutorials/2d/video/movement_8way.webm
Binary file not shown.
Binary file added tutorials/2d/video/movement_click.webm
Binary file not shown.
Binary file added tutorials/2d/video/movement_rotate_keyboard.webm
Binary file not shown.
Binary file added tutorials/2d/video/movement_rotate_mouse.webm
Binary file not shown.