summaryrefslogtreecommitdiff
path: root/Scripts/Mask/SpeedMask.gd
blob: 682785ae57ee03eb1f875599a3175cd659541697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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