extends Sprite2D var empty: bool = true var value: int var move_timer: int = 0 var map_position: Vector2 var facing_direction: int # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func setup(pos, dir): map_position = pos facing_direction = dir self.rotate(-PI / 2 * facing_direction) func collect(input_value: int): if empty: $value_text.text = str(input_value) $value_text.show() empty = false value = input_value func move(): #print("Moving item") move_timer += 1 $value_text.position[1] = -14 + (move_timer * 2) if move_timer > 15: move_timer = 0 empty = true $value_text.hide() var next_pos = map_position if facing_direction == 0: next_pos[1] += 1 elif facing_direction == 1: next_pos[0] += 1 elif facing_direction == 2: next_pos[1] -= 1 elif facing_direction == 3: next_pos[0] -= 1 return [next_pos, value] return