Last active
August 24, 2024 15:08
-
-
Save sergiosvieira/7b5d63066a83072b72cdf339023f1bf6 to your computer and use it in GitHub Desktop.
Revisions
-
sergiosvieira revised this gist
Aug 24, 2024 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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"): -
sergiosvieira revised this gist
Aug 24, 2024 . 1 changed file with 16 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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): 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() ``` -
sergiosvieira revised this gist
Aug 24, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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: screen_size = get_viewport_rect().size # Chamado a cada quadro. 'delta' é o tempo decorrido desde o quadro anterior. -
sergiosvieira revised this gist
Aug 24, 2024 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 ``` -
sergiosvieira created this gist
Aug 24, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. ```