diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-02-12 20:05:59 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-02-12 20:05:59 +0100 |
commit | 218748f67a6a6b35efc4a732ad11426d0f528709 (patch) | |
tree | e58504dd758ce6525844872007221cda2a8b6926 /stage/dice_throw/dice.gd | |
parent | f6c81b065cf4d7f1302a50f2f72cfab32204a1ec (diff) |
Diffstat (limited to 'stage/dice_throw/dice.gd')
-rw-r--r-- | stage/dice_throw/dice.gd | 18 |
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 |