54 lines
1.3 KiB
GDScript
54 lines
1.3 KiB
GDScript
extends RayCast2D
|
|
|
|
@onready var player : Player = get_parent()
|
|
|
|
@onready var fire_range : float = player.ROPE_MAX_DISTANCE
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
|
|
var aim_dir : Vector2 = player.global_position
|
|
if player.MK:
|
|
aim_dir = get_global_mouse_position()
|
|
else:
|
|
# get the aim_dir based off of joystick
|
|
pass
|
|
#print("shooting_dir ", aim_dir.normalized())
|
|
look_at(aim_dir)
|
|
|
|
#if Input. # fire rope
|
|
if Input.is_action_just_pressed("fire"):
|
|
#print("hi")
|
|
if (not player.on_rope):
|
|
%PlayerAudio.play_sound("shoot")
|
|
|
|
#fire rope
|
|
#vec2 aim_pos = get_global_mouse_position()
|
|
if is_colliding(): # process the swing
|
|
#print("shooting")
|
|
var col_point : Vector2 = get_collision_point()
|
|
var dist : float = player.global_position.distance_to(col_point)
|
|
#print(col_point," ", dist," ", fire_range, " ", player.global_position)
|
|
if dist < fire_range:
|
|
player.connection_point = col_point
|
|
player.rope_length = dist
|
|
player.on_rope = true
|
|
player.rope.add_rope_seg(col_point)
|
|
|
|
|
|
|
|
# set the velocity accordingly since you can just float up otherwise
|
|
pass
|
|
|
|
|
|
|
|
|
|
elif player.on_rope:
|
|
#print("was_on_rope")
|
|
player.on_rope = false
|
|
player.connection_point = Vector2.ZERO
|
|
player.rope.clear_rope()
|
|
# release rope
|
|
|
|
pass
|