diff options
Diffstat (limited to 'godot/scenes/Game.gd')
-rw-r--r-- | godot/scenes/Game.gd | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/godot/scenes/Game.gd b/godot/scenes/Game.gd index 56acb04..f24219e 100644 --- a/godot/scenes/Game.gd +++ b/godot/scenes/Game.gd @@ -6,6 +6,7 @@ const PAR = [1,2,3,4,5,6,7,8,9] # level control var current_level_id = 0 var levels = [] +var post_game = false # stroke control var current_strokes = 0 @@ -39,25 +40,14 @@ func _on_ResumeButton_pressed(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) -func load_next_level(): - levels[current_level_id].hide() - current_level_id = current_level_id + 1 - +func end_level(): # save current strokes and reset strokes_per_level[current_level_id] = current_strokes current_strokes = 0 - if current_level_id >= NUM_LEVELS: - # TODO load main menu - return - - # load next level - levels[current_level_id].show() + post_game = true - $Scoreboard.update_values(strokes_per_level, PAR) - $Scoreboard.show() - - # TODO teleport player back + open_scoreboard() func add_stroke(): @@ -75,3 +65,23 @@ func open_scoreboard(): 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() |