added ability to reset high score

hitting delete key while at main menu or game over screen will reset the high score and save to file.
This commit is contained in:
Red3Tango 2023-12-09 15:08:00 -07:00
parent 0cb7f2d206
commit 131d4b83d4
4 changed files with 15 additions and 0 deletions

View File

@ -16,6 +16,9 @@ func _ready() -> void:
load_game()
Relay.game_over.connect(on_game_over)
Relay.game_restart.connect(on_game_reset)
Relay.reset_high_score.connect(func():
high_score = 0
save_high_score(0))
func _input(_event: InputEvent) -> void:

View File

@ -45,6 +45,11 @@ fire={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
clear_high_score={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194312,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[physics]

View File

@ -2,6 +2,7 @@ extends Node
signal current_score(score: int)
signal gain_point
signal reset_high_score
signal ship_hit

View File

@ -11,6 +11,12 @@ func _ready() -> void:
Relay.game_over.connect(on_game_over)
func _unhandled_input(event: InputEvent) -> void:
if not game_over.visible and not title_screen.visible: return
if event.is_action_pressed("clear_high_score"):
Relay.reset_high_score.emit()
func on_score_updated(new_score: int) -> void:
point_counter.text = str(new_score)