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 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'godot/scenes/Die.gd') 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 -- cgit From 0e6b438cbb8d894c5d4d31a50a6e87a89d230b91 Mon Sep 17 00:00:00 2001 From: IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> Date: Sun, 17 Jul 2022 02:33:03 +0200 Subject: very scuffed detection which way the die faces the mapping of the buffs might be incorrect --- godot/scenes/Die.gd | 82 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 7 deletions(-) (limited to 'godot/scenes/Die.gd') diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd index 407f248..62d1d99 100644 --- a/godot/scenes/Die.gd +++ b/godot/scenes/Die.gd @@ -1,4 +1,4 @@ -extends Spatial +extends RigidBody const Game = preload("res://scenes/Game.gd") @@ -14,6 +14,10 @@ var dragging = false var mouse_origin = Vector2(0,0) var dice_launch_force = 0 +var mat +var target_bounce = 1 +var previous_bounciness = 0 + var _game: Game = null # Called when the node enters the scene tree for the first time. @@ -22,9 +26,13 @@ func _ready(): $CamRoot/Horizontal/Vertical/Camera.add_exception(self) $CamRoot.set_as_toplevel(true) _game = get_node("/root/Game") + mat = get_physics_material_override() + previous_bounciness = mat.get_bounce() + ball() + -func _input(event): +func _input(event): if event is InputEventKey: if event.scancode == KEY_TAB: if event.is_pressed(): @@ -51,11 +59,8 @@ func _input(event): elif dragging and not event.pressed: dragging = false Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - - - - - + + func _physics_process(delta): camrot_v = clamp(camrot_v, cam_v_min, cam_v_max) @@ -69,6 +74,9 @@ func _physics_process(delta): dice_is_moving = true else: dice_is_moving = false + + if angular_velocity.length() == 0: + get_upwards_side() last_frame_position = Vector3(translation.x, translation.y, translation.x) @@ -76,3 +84,63 @@ func _physics_process(delta): # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass + + +""" +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] + + +func extra_stroke(): + _game.revoke_stroke() + + +func bounciness(): + mat.set_bounce(target_bounce) + + +func bounciness_revert(): + mat.set_bounce(previous_bounciness) + + +func phase(): + set_collision_layer_bit(2, false) + + +func phase_revert(): + set_collision_layer_bit(2, true) + + +func ball(): + $BallShape.show() + $BallShape.set_process(true) + $BallShape.disabled = false + + +func ball_revert(): + $BallShape.hide() + $BallShape.set_process(false) + $BallShape.disabled = true -- cgit From 8b932533e6d25a80f185bae299351426a4ca157e Mon Sep 17 00:00:00 2001 From: IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com> Date: Sun, 17 Jul 2022 02:44:50 +0200 Subject: post game behaviour --- godot/scenes/Die.gd | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'godot/scenes/Die.gd') 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(): -- cgit