HOLDING
This commit is contained in:
parent
282c3186ef
commit
efc5826935
1 changed files with 56 additions and 18 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue