diff options
author | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 01:08:48 +0200 |
---|---|---|
committer | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 01:08:48 +0200 |
commit | 612e037bc85b815865c6019eb9be87d731e14d30 (patch) | |
tree | 05ca92c1be2cca98e1e0b493a990556f96e003b6 /godot/scenes | |
parent | 98a089669678984edaf6ef37d5a0c463962b007b (diff) | |
download | 2022-612e037bc85b815865c6019eb9be87d731e14d30.tar.gz 2022-612e037bc85b815865c6019eb9be87d731e14d30.tar.bz2 2022-612e037bc85b815865c6019eb9be87d731e14d30.zip |
scoreboard can be accessed when pressing tab
Diffstat (limited to '')
-rw-r--r-- | godot/scenes/Die.gd | 12 | ||||
-rw-r--r-- | godot/scenes/Game.gd | 9 |
2 files changed, 21 insertions, 0 deletions
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() |