summaryrefslogtreecommitdiff
path: root/Scripts/Mask
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts/Mask')
-rw-r--r--Scripts/Mask/GrappleMask.gd78
-rw-r--r--Scripts/Mask/GrappleMask.gd.uid1
-rw-r--r--Scripts/Mask/SpeedMask.gd36
-rw-r--r--Scripts/Mask/SpeedMask.gd.uid1
4 files changed, 116 insertions, 0 deletions
diff --git a/Scripts/Mask/GrappleMask.gd b/Scripts/Mask/GrappleMask.gd
new file mode 100644
index 0000000..35df89a
--- /dev/null
+++ b/Scripts/Mask/GrappleMask.gd
@@ -0,0 +1,78 @@
+extends Node2D
+
+@export var area : Area2D
+@export var area_detect : Area2D
+@export var line : Line2D
+@export var grapple_speed : float
+
+var thing : Node2D = null
+
+var player_movement : PlayerMovement
+
+var just_released : bool = false
+
+func _ready() -> void:
+ player_movement = get_node("../../PlayerMovement")
+
+func _input(event: InputEvent) -> void:
+ if event is InputEventMouseMotion:
+ var delta_pos = event.position - get_global_transform_with_canvas().origin
+ area_detect.rotation = atan2(delta_pos.y, delta_pos.x)
+ if Input.is_action_just_pressed("action_secondary") && event is InputEventMouseButton:
+ var delta_pos = event.position - get_global_transform_with_canvas().origin
+ area.rotation = atan2(delta_pos.y, delta_pos.x)
+ area.monitoring = true
+ if Input.is_action_just_released("action_secondary"):
+ print("hi")
+ area.monitoring = false
+ thing = null
+
+var init_delta : Vector2
+var x_vel
+
+func _process(_delta: float) -> void:
+ if !thing:
+ if just_released:
+ player_movement.grapple_x_vel_aft = player_movement.speed
+ player_movement.grapple_velocity = Vector2.ZERO
+ line.points[1] = Vector2.ZERO
+ x_vel = null
+ just_released = false
+ return
+
+ area.monitoring = false
+
+ var delta_pos = thing.global_position - global_position
+ print(delta_pos.length(), " ", delta_pos.y, " ", delta_pos.x)
+
+ line.points[1] = delta_pos
+
+ var normalised = delta_pos.normalized()
+
+ if !x_vel: x_vel = normalised.x
+
+ if x_vel > 0.3:
+ x_vel = .9
+ elif x_vel < -0.3:
+ x_vel = -.9
+
+ if delta_pos.length() < 100 || ((x_vel > 0 && delta_pos.x < 0) || (x_vel < 0 && delta_pos.x > 0)):
+ just_released = true
+ thing = null
+
+ player_movement.grapple_velocity = Vector2(x_vel, normalised.y * 1.1) * grapple_speed
+
+func _on_area_2d_body_entered(body: Node2D) -> void:
+ print("grapple", body)
+ thing = body
+ area.monitoring = false
+ init_delta = thing.global_position - global_position
+
+func _on_detect_area_2d_body_exited(body:Node2D) -> void:
+ if body is Grappleable:
+ body.dehighlight()
+
+func _on_detect_area_2d_body_entered(body:Node2D) -> void:
+ if body is Grappleable:
+ body.highlight()
+
diff --git a/Scripts/Mask/GrappleMask.gd.uid b/Scripts/Mask/GrappleMask.gd.uid
new file mode 100644
index 0000000..908aafb
--- /dev/null
+++ b/Scripts/Mask/GrappleMask.gd.uid
@@ -0,0 +1 @@
+uid://cxy2ovjxwgtco
diff --git a/Scripts/Mask/SpeedMask.gd b/Scripts/Mask/SpeedMask.gd
new file mode 100644
index 0000000..682785a
--- /dev/null
+++ b/Scripts/Mask/SpeedMask.gd
@@ -0,0 +1,36 @@
+extends Node2D
+
+var player_movement : PlayerMovement
+
+var timer : Timer
+
+var just_clicked : bool = false
+
+var can_dash : bool = true
+
+func _ready() -> void:
+ player_movement = get_node("../../PlayerMovement")
+ timer = Timer.new()
+ timer.wait_time = .5
+ timer.one_shot = true
+ timer.timeout.connect(_timeout)
+ add_child(timer)
+
+func _input(_event: InputEvent) -> void:
+# if Input.is_action_just_pressed("left") || Input.is_action_just_pressed("right"):
+# if !just_clicked:
+# just_clicked = true
+# timer.start()
+# else:
+# just_clicked = false
+ if Input.is_action_just_pressed("dash"):
+ if can_dash:
+ player_movement.dash(Input.get_axis("left", "right"))
+ can_dash = false
+ $"Cooldown".start()
+
+func _timeout() -> void:
+ just_clicked = false
+
+func _on_cooldown_timeout() -> void:
+ can_dash = true
diff --git a/Scripts/Mask/SpeedMask.gd.uid b/Scripts/Mask/SpeedMask.gd.uid
new file mode 100644
index 0000000..4e64967
--- /dev/null
+++ b/Scripts/Mask/SpeedMask.gd.uid
@@ -0,0 +1 @@
+uid://dpjuboxc5u855