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