aboutsummaryrefslogtreecommitdiffstats
path: root/godot/scenes/Game.gd
diff options
context:
space:
mode:
authorLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-17 02:49:09 +0200
committerLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-17 02:49:09 +0200
commit4961e6a3f51990bb053cd8b18827e39aaf3e4e7c (patch)
tree41387099b13b6aca4ac69cdb3a1124a85825d600 /godot/scenes/Game.gd
parent88aeae3f02bfb19b83212599ac1eb950beb805b3 (diff)
parent8b932533e6d25a80f185bae299351426a4ca157e (diff)
download2022-4961e6a3f51990bb053cd8b18827e39aaf3e4e7c.tar.gz
2022-4961e6a3f51990bb053cd8b18827e39aaf3e4e7c.tar.bz2
2022-4961e6a3f51990bb053cd8b18827e39aaf3e4e7c.zip
Merge branch 'Scoreboard'
Diffstat (limited to '')
-rw-r--r--godot/scenes/Game.gd66
1 files changed, 61 insertions, 5 deletions
diff --git a/godot/scenes/Game.gd b/godot/scenes/Game.gd
index 31e543d..f24219e 100644
--- a/godot/scenes/Game.gd
+++ b/godot/scenes/Game.gd
@@ -1,14 +1,24 @@
extends Spatial
+const NUM_LEVELS = 9
+const PAR = [1,2,3,4,5,6,7,8,9]
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
+# level control
+var current_level_id = 0
+var levels = []
+var post_game = false
+# stroke control
+var current_strokes = 0
+var strokes_per_level = [0,0,0,0,0,0,0,0,0]
# Called when the node enters the scene tree for the first time.
func _ready():
- pass # Replace with function body.
+ for i in range(NUM_LEVELS):
+ levels.append(get_node("/root/Game/Level%d" % (i+1)))
+
+ current_strokes = 0
+ levels[0].show()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -20,7 +30,6 @@ func _process(delta):
-
func _on_QuitButton_pressed():
get_tree().quit()
@@ -29,3 +38,50 @@ func _on_ResumeButton_pressed():
$PausePopup.hide()
get_tree().paused = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+
+
+func end_level():
+ # save current strokes and reset
+ strokes_per_level[current_level_id] = current_strokes
+ current_strokes = 0
+
+ post_game = true
+
+ open_scoreboard()
+
+
+func add_stroke():
+ current_strokes += 1
+
+
+func revoke_stroke():
+ current_strokes -= 1
+
+
+func open_scoreboard():
+ $Scoreboard.update_values(strokes_per_level, PAR)
+ $Scoreboard.show()
+
+
+func close_scoreboard():
+ $Scoreboard.hide()
+
+
+func is_post_game():
+ return post_game
+
+
+func next_level():
+ post_game = false
+
+ levels[current_level_id].hide()
+ current_level_id = current_level_id + 1
+
+ if current_level_id >= NUM_LEVELS:
+ # TODO load main menu
+ return
+
+ # load next level
+ levels[current_level_id].show()
+
+ close_scoreboard()