Skip to content

Commit

Permalink
refactor: Use node reference syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
addianto committed Feb 28, 2024
1 parent 342c22b commit ca576bc
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions scenes/Player.gd
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
extends KinematicBody2D

export(int) var speed = 400
export(int) var GRAVITY = 1200
export(int) var jump_speed = -400
export var speed: int = 400
export var GRAVITY: int = 1200
export var jump_speed: int = -400

const UP = Vector2(0, -1)

var velocity = Vector2()

onready var animator = self.get_node("Animator")
onready var sprite = self.get_node("Sprite")
const UP: Vector2 = Vector2(0, -1)

var velocity: Vector2 = Vector2()

func get_input():
velocity.x = 0
Expand All @@ -30,12 +26,12 @@ func _physics_process(delta):

func _process(delta):
if velocity.y != 0:
animator.play("Jump")
$Animator.play("Jump")
elif velocity.x != 0:
animator.play("Walk")
$Animator.play("Walk")
if velocity.x > 0:
sprite.flip_h = false
$Sprite.flip_h = false
else:
sprite.flip_h = true
$Sprite.flip_h = true
else:
animator.play("Idle")
$Animator.play("Idle")

0 comments on commit ca576bc

Please sign in to comment.