diff options
author | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 02:44:50 +0200 |
---|---|---|
committer | IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> | 2022-07-17 02:44:50 +0200 |
commit | 8b932533e6d25a80f185bae299351426a4ca157e (patch) | |
tree | 34013fa3060b7dfec53b2dabe2959454e18504de /godot/scenes | |
parent | 0e6b438cbb8d894c5d4d31a50a6e87a89d230b91 (diff) | |
download | 2022-8b932533e6d25a80f185bae299351426a4ca157e.tar.gz 2022-8b932533e6d25a80f185bae299351426a4ca157e.tar.bz2 2022-8b932533e6d25a80f185bae299351426a4ca157e.zip |
post game behaviour
Diffstat (limited to 'godot/scenes')
-rw-r--r-- | godot/scenes/Die.gd | 28 | ||||
-rw-r--r-- | godot/scenes/Game.gd | 38 |
2 files changed, 29 insertions, 37 deletions
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd index 62d1d99..93d3bfa 100644 --- a/godot/scenes/Die.gd +++ b/godot/scenes/Die.gd @@ -28,11 +28,13 @@ func _ready(): _game = get_node("/root/Game") mat = get_physics_material_override() previous_bounciness = mat.get_bounce() - - ball() func _input(event): + if _game.is_post_game(): + _game.next_level() + return + if event is InputEventKey: if event.scancode == KEY_TAB: if event.is_pressed(): @@ -91,27 +93,7 @@ BUFFS """ func get_upwards_side(): - var forward = -global_transform.basis.z - - var up = forward.angle_to(Vector3.UP) - var down = forward.angle_to(Vector3.DOWN) - var left = forward.angle_to(Vector3.LEFT) - var right = forward.angle_to(Vector3.RIGHT) - var forw = forward.angle_to(Vector3.FORWARD) - var back = forward.angle_to(Vector3.BACK) - - # 0 = ball, 1 = phase, 2 = bounce - var dictionary = { - up: 0, - down: 1, - left: 2, - right: 0, - forw: 1, - back: 2 - } - - var smallest = dictionary.keys().min() - return dictionary[smallest] + return 0 func extra_stroke(): 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() |