-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from nezvers/player_spawn_and_rooms
persistent score
- Loading branch information
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
class_name ScoreResource | ||
extends Resource | ||
extends SaveableResource | ||
|
||
signal points_updated | ||
|
||
@export var point_count:int = 0 | ||
|
||
func reset_resource()->void: | ||
point_count = 0 | ||
|
||
func add_point()->void: | ||
point_count += 1 | ||
points_updated.emit() |
12 changes: 12 additions & 0 deletions
12
addons/top_down/scripts/ui/game_over_screen/score_component.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extends Node | ||
|
||
@export var score_resource:ScoreResource | ||
@export var score_label:Label | ||
@export var try_again_button:Button | ||
|
||
func _ready()->void: | ||
try_again_button.pressed.connect(on_try_again_pressed) | ||
score_label.text = "Score: " + str(score_resource.point_count) | ||
|
||
func on_try_again_pressed()->void: | ||
score_resource.reset_resource() |