Compare commits

..

3 Commits

View File

@@ -19,6 +19,7 @@ var time_since_first_location: float = -1
@export var max_x: int = 1000
@export var min_x: int = 0
@export var ease_out_time: float = 0.5
@export var bounce: bool = false
func _ready() -> void:
draggable = true
@@ -26,12 +27,10 @@ func _ready() -> void:
func _process(delta: float) -> void:
global_position.x += velocity
var offset: Vector2
if draggable:
if (Input.is_action_just_pressed("click")):
mouse_first_location = get_global_mouse_position()
offset = get_local_mouse_position() - global_position
time_since_first_location = 0
if Input.is_action_pressed("click"):
mouse_first_location = get_global_mouse_position()
@@ -64,18 +63,20 @@ func _process(delta: float) -> void:
draggable = true
if global_position.x > max_x:
push_warning("too far to the pos_x")
velocity = -velocity
global_position.x = 999
if global_position.x >= max_x && velocity > 0:
if bounce:
velocity = -(velocity)/2
print("velocity negated, bouncing")
global_position.x = max_x - 1
time_since_first_location = -1
draggable = true
return
elif global_position.x < min_x:
push_warning("too far to the neg_y")
velocity = -velocity
global_position.x = 1
elif global_position.x < min_x && velocity < 0:
if bounce:
velocity = -(velocity)/2
print("velocity negated, bouncing")
global_position.x = min_x + 1
time_since_first_location = -1
draggable = true
return