From efc5826935353466ab6ec1bd20a1bf333ec977e7 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Sun, 31 Dec 2023 00:34:15 -0500 Subject: [PATCH] HOLDING --- menus/marathon_select_lives.gd | 74 +++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/menus/marathon_select_lives.gd b/menus/marathon_select_lives.gd index 83d08e0..35ae383 100644 --- a/menus/marathon_select_lives.gd +++ b/menus/marathon_select_lives.gd @@ -4,6 +4,10 @@ extends Button const INFINITY_SIGIL := "▬↨" +var delay := 1.0 +var cooldown := 0.0 + + onready var back_arrow: TextureRect = $"../BackArrow" onready var next_arrow: TextureRect = $"../NextArrow" @@ -12,6 +16,40 @@ func _ready() -> void: _update_display() +func _process(delta: float) -> void: + if Input.is_action_pressed("ui_left"): + if cooldown <= 0.0: + cooldown = delay + delay *= 0.5 + if Game.use_lives: + Game.marathon_lives -= 1 + if Game.marathon_lives < 0: + Game.use_lives = false + cooldown = INF + else: + Game.use_lives = true + Game.marathon_lives = 999 + cooldown -= delta + _update_display() + elif Input.is_action_pressed("ui_right"): + if cooldown <= 0.0: + cooldown = delay + delay *= 0.5 + if Game.use_lives: + Game.marathon_lives += 1 + if Game.marathon_lives > 999: + Game.use_lives = false + cooldown = INF + else: + Game.use_lives = true + Game.marathon_lives = 0 + cooldown -= delta + _update_display() + else: + cooldown = 0.0 + delay = 1.0 + + func _update_display() -> void: if Game.use_lives: text = "%03d" % Game.marathon_lives @@ -19,24 +57,24 @@ func _update_display() -> void: text = INFINITY_SIGIL -func _gui_input(event: InputEvent) -> void: - if event.is_action_pressed("ui_left"): - if Game.use_lives: - Game.marathon_lives -= 1 - if Game.marathon_lives < 0: - Game.use_lives = false - else: - Game.use_lives = true - Game.marathon_lives = 999 - if event.is_action_pressed("ui_right"): - if Game.use_lives: - Game.marathon_lives += 1 - if Game.marathon_lives > 999: - Game.use_lives = false - else: - Game.use_lives = true - Game.marathon_lives = 0 - _update_display() +#func _gui_input(event: InputEvent) -> void: +# if event.is_action_pressed("ui_left"): +# if Game.use_lives: +# Game.marathon_lives -= 1 +# if Game.marathon_lives < 0: +# Game.use_lives = false +# else: +# Game.use_lives = true +# Game.marathon_lives = 999 +# if event.is_action_pressed("ui_right"): +# if Game.use_lives: +# Game.marathon_lives += 1 +# if Game.marathon_lives > 999: +# Game.use_lives = false +# else: +# Game.use_lives = true +# Game.marathon_lives = 0 +# _update_display() func _on_focus_entered() -> void: