Skip to content

Instantly share code, notes, and snippets.

@sergiosvieira
Last active August 24, 2024 15:08
Show Gist options
  • Save sergiosvieira/7b5d63066a83072b72cdf339023f1bf6 to your computer and use it in GitHub Desktop.
Save sergiosvieira/7b5d63066a83072b72cdf339023f1bf6 to your computer and use it in GitHub Desktop.

Revisions

  1. sergiosvieira revised this gist Aug 24, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions aula.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,12 @@ func _ready() -> void:
    # Chamado a cada quadro. 'delta' é o tempo decorrido desde o quadro anterior.
    # Normalizando
    # import numpy as np
    # velocity = np.array([4, 3])
    # norm_velocity = (velocity / np.linalg.norm(velocity))
    # np.hypot(norm_velocity[0], norm_velocity[1])
    # = np.float64(1.0)
    func _process(delta):
    var velocity = Vector2.ZERO # The player's movement vector.
    if Input.is_action_pressed("move_right"):
  2. sergiosvieira revised this gist Aug 24, 2024. 1 changed file with 16 additions and 2 deletions.
    18 changes: 16 additions & 2 deletions aula.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,20 @@ func _ready() -> void:
    # Chamado a cada quadro. 'delta' é o tempo decorrido desde o quadro anterior.
    func _process(delta: float) -> void:
    pass
    func _process(delta):
    var velocity = Vector2.ZERO # The player's movement vector.
    if Input.is_action_pressed("move_right"):
    velocity.x += 1
    if Input.is_action_pressed("move_left"):
    velocity.x -= 1
    if Input.is_action_pressed("move_down"):
    velocity.y += 1
    if Input.is_action_pressed("move_up"):
    velocity.y -= 1
    if velocity.length() > 0:
    velocity = velocity.normalized() * speed
    $AnimatedSprite2D.play()
    else:
    $AnimatedSprite2D.stop()
    ```
  3. sergiosvieira revised this gist Aug 24, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion aula.md
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,9 @@ extends Area2D
    var screen_size # Tamanho da janela do jogo.
    # Chamado quando o nó entra na árvore de cenas pela primeira vez.
    # A função _ready() é chamada quando um nó entra na árvore de cenas, o que é um bom momento para descobrir o tamanho da janela do jogo:
    func _ready() -> void:
    pass # Substitua pelo corpo da função.
    screen_size = get_viewport_rect().size
    # Chamado a cada quadro. 'delta' é o tempo decorrido desde o quadro anterior.
  4. sergiosvieira revised this gist Aug 24, 2024. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions aula.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,13 @@ extends Area2D
    @export var speed = 400 # Quão rápido o jogador se moverá (pixels/segundo).
    var screen_size # Tamanho da janela do jogo.
    # Chamado quando o nó entra na árvore de cenas pela primeira vez.
    func _ready() -> void:
    pass # Substitua pelo corpo da função.
    # Chamado a cada quadro. 'delta' é o tempo decorrido desde o quadro anterior.
    func _process(delta: float) -> void:
    pass
    ```
  5. sergiosvieira created this gist Aug 24, 2024.
    8 changes: 8 additions & 0 deletions aula.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Slide 33

    ```
    extends Area2D
    @export var speed = 400 # Quão rápido o jogador se moverá (pixels/segundo).
    var screen_size # Tamanho da janela do jogo.
    ```