Update first_2d_game C# variables capitalization (#4723)

This commit is contained in:
Pierre Ellul
2021-03-19 13:02:45 +01:00
committed by GitHub
parent 4a987385df
commit f26bdbbcd4
3 changed files with 15 additions and 15 deletions

View File

@@ -37,13 +37,13 @@ Start by declaring the member variables this object will need:
using Godot;
using System;
public class Player : Area2D
{
[Export]
public int speed = 400; // How fast the player will move (pixels/sec).
public int Speed = 400; // How fast the player will move (pixels/sec).
public Vector2 screenSize; // Size of the game window.
public Vector2 ScreenSize; // Size of the game window.
}
@@ -75,7 +75,7 @@ a good time to find the size of the game window:
public override void _Ready()
{
screenSize = GetViewportRect().Size;
ScreenSize = GetViewportRect().Size;
}
Now we can use the ``_process()`` function to define what the player will do.
@@ -147,7 +147,7 @@ which returns ``true`` if it's pressed or ``false`` if it isn't.
if (velocity.Length() > 0)
{
velocity = velocity.Normalized() * speed;
velocity = velocity.Normalized() * Speed;
animatedSprite.Play();
}
else
@@ -199,8 +199,8 @@ the ``_process`` function (make sure it's not indented under the `else`):
Position += velocity * delta;
Position = new Vector2(
x: Mathf.Clamp(Position.x, 0, screenSize.x),
y: Mathf.Clamp(Position.y, 0, screenSize.y)
x: Mathf.Clamp(Position.x, 0, ScreenSize.x),
y: Mathf.Clamp(Position.y, 0, ScreenSize.y)
);