49 lines
992 B
GDScript
49 lines
992 B
GDScript
extends Button
|
|
|
|
|
|
const INFINITY_SIGIL := "▬↨"
|
|
|
|
|
|
onready var back_arrow: TextureRect = $"../BackArrow"
|
|
onready var next_arrow: TextureRect = $"../NextArrow"
|
|
|
|
|
|
func _ready() -> void:
|
|
_update_display()
|
|
|
|
|
|
func _update_display() -> void:
|
|
if Game.use_lives:
|
|
text = "%03d" % Game.marathon_lives
|
|
else:
|
|
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 _on_focus_entered() -> void:
|
|
back_arrow.visible = true
|
|
next_arrow.visible = true
|
|
|
|
|
|
func _on_focus_exited() -> void:
|
|
back_arrow.visible = false
|
|
next_arrow.visible = false
|