extends Object static var start = null static func calc_swipe(end): if start == null: return null var delta = end - start var biggest = max(abs(delta.x), abs(delta.y)) if biggest < 50: return null if abs(delta.x) > abs(delta.y): if delta.x < 0: return Global.DIRS.LEFT else: return Global.DIRS.RIGHT else: if delta.y < 0: return Global.DIRS.UP else: return Global.DIRS.DOWN static func _input(event: InputEvent): var d = null if event.is_action_pressed('left_mouse_button'): start = event.get_position() if event.is_action_released('left_mouse_button'): d = calc_swipe(event.get_position()) if event.is_action_released('key_up'): d = Global.DIRS.UP if event.is_action_released('key_down'): d = Global.DIRS.DOWN if event.is_action_released('key_left'): d = Global.DIRS.LEFT if event.is_action_released('key_right'): d = Global.DIRS.RIGHT return d