Skip to content

Commit 8916cbd

Browse files
committed
Unify C# naming notes and comments
1 parent 5884378 commit 8916cbd

File tree

9 files changed

+37
-5
lines changed

9 files changed

+37
-5
lines changed

getting_started/first_2d_game/03.coding_the_player.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ Next, add this code to the function:
407407

408408
.. code-tab:: csharp
409409

410+
// We also specified this function name in PascalCase in the editor's connection window.
410411
private void OnBodyEntered(Node2D body)
411412
{
412413
Hide(); // Player disappears after being hit.

getting_started/first_2d_game/04.creating_the_enemy.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ to the ``Mob`` and add this code:
117117

118118
.. code-tab:: csharp
119119

120+
// We also specified this function name in PascalCase in the editor's connection window.
120121
private void OnVisibleOnScreenNotifier2DScreenExited()
121122
{
122123
QueueFree();

getting_started/first_2d_game/05.the_main_game_scene.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ the other two timers. ``ScoreTimer`` will increment the score by 1.
168168

169169
.. code-tab:: csharp
170170

171+
// We also specified this function name in PascalCase in the editor's connection window.
171172
private void OnScoreTimerTimeout()
172173
{
173174
_score++;
174175
}
175176

177+
// We also specified this function name in PascalCase in the editor's connection window.
176178
private void OnStartTimerTimeout()
177179
{
178180
GetNode<Timer>("MobTimer").Start();
@@ -219,6 +221,7 @@ Note that a new instance must be added to the scene using ``add_child()``.
219221

220222
.. code-tab:: csharp
221223

224+
// We also specified this function name in PascalCase in the editor's connection window.
222225
private void OnMobTimerTimeout()
223226
{
224227
// Note: Normally it is best to use explicit types rather than the `var`

getting_started/first_2d_game/06.heads_up_display.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,14 @@ signal of ``MessageTimer``, and add the following code to the new functions:
199199

200200
.. code-tab:: csharp
201201

202+
// We also specified this function name in PascalCase in the editor's connection window.
202203
private void OnStartButtonPressed()
203204
{
204205
GetNode<Button>("StartButton").Hide();
205206
EmitSignal(SignalName.StartGame);
206207
}
207208

209+
// We also specified this function name in PascalCase in the editor's connection window.
208210
private void OnMessageTimerTimeout()
209211
{
210212
GetNode<Label>("Message").Hide();

getting_started/first_3d_game/03.player_movement_code.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Moving the player with code
66
It's time to code! We're going to use the input actions we created in the last
77
part to move the character.
88

9+
.. note:: For this project, we will be following the Godot naming conventions.
10+
11+
- **GDScript**: Classes (nodes) use PascalCase, variables and
12+
functions use snake_case, and constants use ALL_CAPS (See
13+
:ref:`doc_gdscript_styleguide`).
14+
15+
- **C#**: Classes, export variables and methods use PascalCase,
16+
private fields use _camelCase, local variables and parameters use
17+
camelCase (See :ref:`doc_c_sharp_styleguide`). Be careful to type
18+
the method names precisely when connecting signals.
19+
920
Right-click the ``Player`` node and select *Attach Script* to add a new script to
1021
it. In the popup, set the *Template* to *Empty* before pressing the *Create*
1122
button. We set it to *Empty* because we want to write our own code for

getting_started/first_3d_game/04.mob_scene.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ method. This function destroys the instance it's called on.
239239

240240
.. code-tab:: csharp
241241

242-
// We also specified this function name in PascalCase in the editor's connection window
242+
// We also specified this function name in PascalCase in the editor's connection window.
243243
private void OnVisibilityNotifierScreenExited()
244244
{
245245
QueueFree();
@@ -321,7 +321,7 @@ Here is the complete ``Mob.gd`` script for reference.
321321
Velocity = Velocity.Rotated(Vector3.Up, Rotation.Y);
322322
}
323323

324-
// We also specified this function name in PascalCase in the editor's connection window
324+
// We also specified this function name in PascalCase in the editor's connection window.
325325
private void OnVisibilityNotifierScreenExited()
326326
{
327327
QueueFree();

getting_started/first_3d_game/05.spawning_mobs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Let's code the mob spawning logic. We're going to:
244244

245245
.. code-tab:: csharp
246246

247-
// We also specified this function name in PascalCase in the editor's connection window
247+
// We also specified this function name in PascalCase in the editor's connection window.
248248
private void OnMobTimerTimeout()
249249
{
250250
// Create a new instance of the Mob scene.

getting_started/first_3d_game/07.killing_player.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ a ``die()`` function that helps us put a descriptive label on the code.
9494
QueueFree();
9595
}
9696

97-
// We also specified this function name in PascalCase in the editor's connection window
97+
// We also specified this function name in PascalCase in the editor's connection window.
9898
private void OnMobDetectorBodyEntered(Node3D body)
9999
{
100100
Die();
@@ -122,7 +122,7 @@ Get the timer, and stop it, in the ``_on_player_hit()`` function.
122122

123123
.. code-tab:: csharp
124124

125-
// We also specified this function name in PascalCase in the editor's connection window
125+
// We also specified this function name in PascalCase in the editor's connection window.
126126
private void OnPlayerHit()
127127
{
128128
GetNode<Timer>("MobTimer").Stop();

getting_started/step_by_step/signals.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ the bar to reflect the change. To do so, in Godot, you would use signals.
3232
We will now use a signal to make our Godot icon from the previous lesson
3333
(:ref:`doc_scripting_player_input`) move and stop by pressing a button.
3434

35+
.. note:: For this project, we will be following the Godot naming conventions.
36+
37+
- **GDScript**: Classes (nodes) use PascalCase, variables and
38+
functions use snake_case, and constants use ALL_CAPS (See
39+
:ref:`doc_gdscript_styleguide`).
40+
41+
- **C#**: Classes, export variables and methods use PascalCase,
42+
private fields use _camelCase, local variables and parameters use
43+
camelCase (See :ref:`doc_c_sharp_styleguide`). Be careful to type
44+
the method names precisely when connecting signals.
45+
3546
.. Example
3647
3748
Scene setup
@@ -156,6 +167,7 @@ the ``not`` keyword to invert the value.
156167

157168
.. code-tab:: csharp C#
158169

170+
// We also specified this function name in PascalCase in the editor's connection window.
159171
private void OnButtonPressed()
160172
{
161173
SetProcess(!IsProcessing());
@@ -221,6 +233,7 @@ Your complete ``sprite_2d.gd`` code should look like the following.
221233
Position += velocity * (float)delta;
222234
}
223235

236+
// We also specified this function name in PascalCase in the editor's connection window.
224237
private void OnButtonPressed()
225238
{
226239
SetProcess(!IsProcessing());
@@ -393,6 +406,7 @@ Here is the complete ``sprite_2d.gd`` file for reference.
393406
Position += velocity * (float)delta;
394407
}
395408

409+
// We also specified this function name in PascalCase in the editor's connection window.
396410
private void OnButtonPressed()
397411
{
398412
SetProcess(!IsProcessing());

0 commit comments

Comments
 (0)