Skip to content

Commit 17f4f9a

Browse files
Added new "Getting Started" tutorials covering the setup and implementation process for 3D and 2D games in Godot. Includes detailed steps, asset usage, and input configuration.
1 parent 4c5ecbc commit 17f4f9a

529 files changed

Lines changed: 8608 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import Tabs from "@theme/Tabs";
2+
import TabItem from "@theme/TabItem";
3+
4+
# Setting up the project
5+
6+
In this short first part, we'll set up and organize the project.
7+
8+
Launch Godot and create a new project.
9+
10+
![Image](img/new-project-button.webp)
11+
12+
When creating the new project, you only need to choose a valid *Project Path*. You can leave the other default settings alone.
13+
14+
<Tabs>
15+
16+
<TabItem value="gdscript" label="GDScript">
17+
18+
Download [dodge_the_creeps_2d_assets.zip](https://github.com/godotengine/godot-docs-project-starters/releases/download/latest-4.x/dodge_the_creeps_2d_assets.zip).
19+
The archive contains the images and sounds you'll be using
20+
to make the game. Extract the archive and move the ``art/``
21+
and ``fonts/`` directories to your project's directory.
22+
23+
</TabItem>
24+
25+
<TabItem value="c_" label="C#">
26+
27+
Download [dodge_the_creeps_2d_assets.zip](https://github.com/godotengine/godot-docs-project-starters/releases/download/latest-4.x/dodge_the_creeps_2d_assets.zip).
28+
The archive contains the images and sounds you'll be using
29+
to make the game. Extract the archive and move the ``art/``
30+
and ``fonts/`` directories to your project's directory.
31+
32+
Ensure that you have the required dependencies to use C# in Godot.
33+
You need the latest stable .NET SDK, and an editor such as VS Code.
34+
See [doc_c_sharp_setup](doc_c_sharp_setup).
35+
36+
</TabItem>
37+
38+
<TabItem value="c__" label="C++">
39+
40+
The C++ part of this tutorial wasn't rewritten for the new GDExtension system yet.
41+
42+
</TabItem>
43+
44+
</Tabs>
45+
46+
Your project folder should look like this.
47+
48+
![Image](img/folder-content.webp)
49+
50+
This game is designed for portrait mode, so we need to adjust the size of the
51+
game window. Click on *Project -&gt; Project Settings* to open the project settings
52+
window, in the left column open the *Display -&gt; Window* tab. There, set
53+
"Viewport Width" to ``480`` and "Viewport Height" to ``720``. You can see the
54+
"Project" menu on the upper left corner.
55+
56+
![Image](img/setting-project-width-and-height.webp)
57+
58+
Also, under the **Stretch** options, set **Mode** to ``canvas_items`` and **Aspect** to ``keep``.
59+
This ensures that the game scales consistently on different sized screens.
60+
61+
![Image](img/setting-stretch-mode.webp)
62+
63+
## Organizing the project
64+
65+
In this project, we will make 3 independent scenes: ``Player``, ``Mob``, and
66+
``HUD``, which we will combine into the game's ``Main`` scene.
67+
68+
In a larger project, it might be useful to create folders to hold the various
69+
scenes and their scripts, but for this relatively small game, you can save your
70+
scenes and scripts in the project's root folder, identified by ``res://``. You
71+
can see your project folders in the FileSystem dock in the lower left corner:
72+
73+
![Image](img/filesystem_dock.webp)
74+
75+
With the project in place, we're ready to design the player scene in the next lesson.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
# Creating the player scene
3+
4+
With the project settings in place, we can start working on the
5+
player-controlled character.
6+
7+
The first scene will define the ``Player`` object. One of the benefits of
8+
creating a separate Player scene is that we can test it separately, even before
9+
we've created other parts of the game.
10+
11+
## Node structure
12+
13+
To begin, we need to choose a root node for the player object. As a general
14+
rule, a scene's root node should reflect the object's desired functionality -
15+
what the object *is*. In the upper-left corner, in the "Scene" tab, click the
16+
"Other Node" button and add an [Area2D](/docs/Classes/Area2D) node to the scene.
17+
18+
![Image](img/add_node.webp)
19+
20+
When you add the ``Area2D`` node, Godot will display the following **warning icon**
21+
next to it in the scene tree:
22+
23+
![Image](img/no_shape_warning.webp)
24+
25+
This warning tells us that the ``Area2D`` node requires a shape to detect collisions or overlaps.
26+
We can **ignore the warning temporarily** because we will first set up the player's visuals
27+
(using an animated sprite). Once the visuals are ready, we will add a collision shape as a child
28+
node. This will allow us to accurately size and position the shape based on the sprite's appearance.
29+
30+
With ``Area2D`` we can detect objects that overlap or run into the player.
31+
Change the node's name to ``Player`` by double-clicking on it. Now that we've
32+
set the scene's root node, we can add additional nodes to give it more
33+
functionality.
34+
35+
Before we add any children to the ``Player`` node, we want to make sure we don't
36+
accidentally move or resize them by clicking on them. Select the node and click
37+
the icon to the right of the lock. Its tooltip says "Groups the selected node
38+
with its children. This causes the parent to be selected when any child
39+
node is clicked in 2D and 3D view."
40+
41+
![Image](img/lock_children.webp)
42+
43+
Save the scene as ``player.tscn``. Click **Scene &gt; Save**, or press `Ctrl + S`
44+
on Windows/Linux or `Cmd + S` on macOS.
45+
46+
:::note
47+
For this project, we will be following the Godot naming conventions.
48+
- **GDScript**: Classes (nodes) use PascalCase, variables and
49+
functions use snake_case, and constants use ALL_CAPS (See
50+
[doc_gdscript_styleguide](doc_gdscript_styleguide)).
51+
52+
- **C#**: Classes, export variables and methods use PascalCase,
53+
private fields use _camelCase, local variables and parameters use
54+
camelCase (See [doc_c_sharp_styleguide](doc_c_sharp_styleguide)). Be careful to type
55+
the method names precisely when connecting signals.
56+
57+
:::
58+
59+
## Sprite animation
60+
61+
Click on the ``Player`` node and add (`Ctrl + A` on Windows/Linux or
62+
`Cmd + A` on macOS) a child node :ref:`AnimatedSprite2D
63+
&lt;class_AnimatedSprite2D&gt;`. The ``AnimatedSprite2D`` will handle the
64+
appearance and animations for our player. Notice that there is a warning symbol
65+
next to the node. An ``AnimatedSprite2D`` requires a :ref:`SpriteFrames
66+
&lt;class_SpriteFrames&gt;` resource, which is a list of the animations it can
67+
display. Make sure ``AnimatedSprite2D`` is selected and then find the ``Sprite Frames`` property under
68+
the ``Animation`` section in the Inspector and click "[empty]" -&gt; "New SpriteFrames":
69+
70+
![Image](img/new_spriteframes.webp)
71+
72+
Click on the ``SpriteFrames`` you just created to open the "SpriteFrames" panel:
73+
74+
![Image](img/spriteframes_panel.webp)
75+
76+
On the left is a list of animations. Click the ``default`` one and rename it to
77+
``walk``. Then click the **Add Animation** button to create a second animation
78+
named ``up``.
79+
80+
Find the player images in the FileSystem dock - they're in the ``art`` folder
81+
you unzipped earlier. Drag the two images for each animation, into the
82+
**Animation Frames** side of the panel for the corresponding animation:
83+
84+
- ``playerGrey_walk1`` and ``playerGrey_walk2`` for the ``walk`` animation
85+
- ``playerGrey_up1`` and ``playerGrey_up2`` for the ``up`` animation
86+
87+
![Image](img/spriteframes_panel2.webp)
88+
89+
The player images are a bit too large for the game window, so we need to scale
90+
them down. Click on the ``AnimatedSprite2D`` node and set the ``Scale`` property
91+
to ``(0.5, 0.5)``. You can find it in the Inspector under the ``Node2D``
92+
heading.
93+
94+
![Image](img/player_scale.webp)
95+
96+
Finally, add a [CollisionShape2D](/docs/Classes/CollisionShape2D) as a child of
97+
``Player``. This will determine the player's "hitbox", or the bounds of its
98+
collision area. For this character, a ``CapsuleShape2D`` node gives the best
99+
fit, so next to "Shape" in the Inspector, click "[empty]" -&gt; "New
100+
CapsuleShape2D". Using the two size handles, resize the shape to cover the
101+
sprite:
102+
103+
![Image](img/player_coll_shape.webp)
104+
105+
When you're finished, your ``Player`` scene should look like this:
106+
107+
![Image](img/player_scene_nodes.webp)
108+
109+
Once this is done, the warning on the ``Area2D`` node will disappear, as it now has
110+
a shape assigned and can interact with other objects.
111+
112+
Make sure to save the scene again after these changes.
113+
114+
In the next part, we'll add a script to the player node to move and animate it.
115+
Then, we'll set up collision detection to know when the player got hit by
116+
something.

0 commit comments

Comments
 (0)