From 612e037bc85b815865c6019eb9be87d731e14d30 Mon Sep 17 00:00:00 2001 From: IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> Date: Sun, 17 Jul 2022 01:08:48 +0200 Subject: scoreboard can be accessed when pressing tab --- godot/scenes/Die.gd | 12 ++++++++++++ godot/scenes/Game.gd | 9 +++++++++ 2 files changed, 21 insertions(+) (limited to 'godot') diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd index 5e238f1..407f248 100644 --- a/godot/scenes/Die.gd +++ b/godot/scenes/Die.gd @@ -1,5 +1,7 @@ extends Spatial +const Game = preload("res://scenes/Game.gd") + var camrot_h = 0 var camrot_v = 0 var camrot_v_locked_val = 0 @@ -12,14 +14,24 @@ var dragging = false var mouse_origin = Vector2(0,0) var dice_launch_force = 0 +var _game: Game = null + # Called when the node enters the scene tree for the first time. func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) $CamRoot/Horizontal/Vertical/Camera.add_exception(self) $CamRoot.set_as_toplevel(true) + _game = get_node("/root/Game") func _input(event): + if event is InputEventKey: + if event.scancode == KEY_TAB: + if event.is_pressed(): + _game.open_scoreboard() + else: + _game.close_scoreboard() + if event is InputEventMouseMotion: camrot_h += -event.relative.x * sensitivity camrot_v += -event.relative.y * sensitivity diff --git a/godot/scenes/Game.gd b/godot/scenes/Game.gd index 29a5537..56acb04 100644 --- a/godot/scenes/Game.gd +++ b/godot/scenes/Game.gd @@ -66,3 +66,12 @@ func add_stroke(): func revoke_stroke(): current_strokes -= 1 + + +func open_scoreboard(): + $Scoreboard.update_values(strokes_per_level, PAR) + $Scoreboard.show() + + +func close_scoreboard(): + $Scoreboard.hide() -- cgit