summaryrefslogtreecommitdiff
path: root/stage/dice_throw/dice.gd
diff options
context:
space:
mode:
Diffstat (limited to 'stage/dice_throw/dice.gd')
-rw-r--r--stage/dice_throw/dice.gd18
1 files changed, 15 insertions, 3 deletions
diff --git a/stage/dice_throw/dice.gd b/stage/dice_throw/dice.gd
index 291710c..88fdbb8 100644
--- a/stage/dice_throw/dice.gd
+++ b/stage/dice_throw/dice.gd
@@ -1,3 +1,4 @@
+class_name Dice
extends RigidBody3D
@@ -5,6 +6,17 @@ var previous_position: Vector3
var previous_rotation: Vector3
var is_moving := false
+@export var configuration: DiceConfiguration
+
+
+func _ready() -> void:
+ %DiceFaceFront.configuration = configuration.front_face
+ %DiceFaceBack.configuration = configuration.back_face
+ %DiceFaceTop.configuration = configuration.top_face
+ %DiceFaceBottom.configuration = configuration.bottom_face
+ %DiceFaceLeft.configuration = configuration.left_face
+ %DiceFaceRight.configuration = configuration.right_face
+
func roll(direction := Vector3(1.0, 1.0, 1.0), strength: float = 20) -> void:
var position_impulse := Vector3(
@@ -24,10 +36,10 @@ func roll(direction := Vector3(1.0, 1.0, 1.0), strength: float = 20) -> void:
apply_torque_impulse(rotation_impulse)
-func get_top() -> Node3D:
+func get_top() -> DiceFace:
var top := -pow(2, 8)
- var face: Node3D
- for node: Node3D in $Faces.get_children():
+ var face: DiceFace
+ for node: DiceFace in $Faces.get_children():
if top < node.global_transform.origin.y:
top = node.global_transform.origin.y
face = node