summaryrefslogtreecommitdiff
path: root/stage/dice_throw
diff options
context:
space:
mode:
Diffstat (limited to 'stage/dice_throw')
-rw-r--r--stage/dice_throw/dice.gd19
-rw-r--r--stage/dice_throw/dice.tscn74
-rw-r--r--stage/dice_throw/dice_throw.tscn66
-rw-r--r--stage/dice_throw/dice_throw_3d.gd11
-rw-r--r--stage/dice_throw/dice_throw_3d.tscn34
5 files changed, 204 insertions, 0 deletions
diff --git a/stage/dice_throw/dice.gd b/stage/dice_throw/dice.gd
new file mode 100644
index 0000000..127d968
--- /dev/null
+++ b/stage/dice_throw/dice.gd
@@ -0,0 +1,19 @@
+extends RigidBody3D
+
+
+func roll(direction := Vector3(1.0, 1.0, 1.0), strength: float = 20) -> void:
+ var position_impulse := Vector3(
+ [-1, 1].pick_random(),
+ randf_range(0.5, 1.0),
+ [-1, 1].pick_random()
+ )
+
+ apply_central_impulse(position_impulse.normalized() * direction * strength)
+
+ var rotation_impulse := Vector3(
+ [-1, 1].pick_random(),
+ [-1, 1].pick_random(),
+ [-1, 1].pick_random()
+ )
+
+ apply_torque_impulse(rotation_impulse.normalized())
diff --git a/stage/dice_throw/dice.tscn b/stage/dice_throw/dice.tscn
new file mode 100644
index 0000000..14f28b7
--- /dev/null
+++ b/stage/dice_throw/dice.tscn
@@ -0,0 +1,74 @@
+[gd_scene load_steps=12 format=3 uid="uid://dnq7fpof6w0mj"]
+
+[ext_resource type="Script" path="res://stage/dice_throw/dice.gd" id="1_gwnix"]
+[ext_resource type="Texture2D" uid="uid://blanietpri1be" path="res://icon.svg" id="2_6tbdd"]
+[ext_resource type="Texture2D" uid="uid://dtltt171temec" path="res://stage/assets/tinyBlocks.png" id="3_t0umq"]
+
+[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_m7tx2"]
+bounce = 0.5
+
+[sub_resource type="BoxMesh" id="BoxMesh_gof22"]
+
+[sub_resource type="BoxShape3D" id="BoxShape3D_tqijt"]
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_0hsac"]
+atlas = ExtResource("3_t0umq")
+region = Rect2(0, 18, 18, 18)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_2rcxj"]
+atlas = ExtResource("3_t0umq")
+region = Rect2(90, 36, 18, 18)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_l100r"]
+atlas = ExtResource("3_t0umq")
+region = Rect2(54, 72, 18, 18)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_l8don"]
+atlas = ExtResource("3_t0umq")
+region = Rect2(90, 90, 18, 18)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_ug301"]
+atlas = ExtResource("3_t0umq")
+region = Rect2(72, 144, 18, 18)
+
+[node name="Dice" type="RigidBody3D"]
+physics_material_override = SubResource("PhysicsMaterial_m7tx2")
+gravity_scale = 2.0
+script = ExtResource("1_gwnix")
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
+mesh = SubResource("BoxMesh_gof22")
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
+shape = SubResource("BoxShape3D_tqijt")
+
+[node name="Faces" type="Node3D" parent="."]
+
+[node name="Sprite3D" type="Sprite3D" parent="Faces"]
+transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0, 0, 0.51)
+texture = ExtResource("2_6tbdd")
+
+[node name="Sprite3D2" type="Sprite3D" parent="Faces"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.51)
+pixel_size = 0.05
+texture = SubResource("AtlasTexture_0hsac")
+
+[node name="Sprite3D3" type="Sprite3D" parent="Faces"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.51, 0, 0)
+pixel_size = 0.05
+texture = SubResource("AtlasTexture_2rcxj")
+
+[node name="Sprite3D4" type="Sprite3D" parent="Faces"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.51, 0, 0)
+pixel_size = 0.05
+texture = SubResource("AtlasTexture_l100r")
+
+[node name="Sprite3D5" type="Sprite3D" parent="Faces"]
+transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.51, 0)
+pixel_size = 0.05
+texture = SubResource("AtlasTexture_l8don")
+
+[node name="Sprite3D6" type="Sprite3D" parent="Faces"]
+transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.51, 0)
+pixel_size = 0.05
+texture = SubResource("AtlasTexture_ug301")
diff --git a/stage/dice_throw/dice_throw.tscn b/stage/dice_throw/dice_throw.tscn
new file mode 100644
index 0000000..1311285
--- /dev/null
+++ b/stage/dice_throw/dice_throw.tscn
@@ -0,0 +1,66 @@
+[gd_scene load_steps=5 format=3 uid="uid://dsy8atabknch"]
+
+[ext_resource type="PackedScene" uid="uid://dlkds7l1kw468" path="res://stage/dice_throw/dice_throw_3d.tscn" id="1_mg5cv"]
+
+[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_cqep4"]
+sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
+ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
+
+[sub_resource type="Sky" id="Sky_ij08j"]
+sky_material = SubResource("ProceduralSkyMaterial_cqep4")
+
+[sub_resource type="Environment" id="Environment_sn6lt"]
+background_mode = 2
+sky = SubResource("Sky_ij08j")
+tonemap_mode = 2
+
+[node name="DiceThrow" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="HBoxContainer" type="HBoxContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer"]
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/PanelContainer"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="HBoxContainer/PanelContainer/VBoxContainer"]
+layout_mode = 2
+text = "Movement Points"
+
+[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+stretch = true
+
+[node name="SubViewport" type="SubViewport" parent="HBoxContainer/SubViewportContainer"]
+transparent_bg = true
+handle_input_locally = false
+size = Vector2i(340, 320)
+render_target_update_mode = 4
+
+[node name="DiceThrow3D" parent="HBoxContainer/SubViewportContainer/SubViewport" instance=ExtResource("1_mg5cv")]
+
+[node name="Camera3D" type="Camera3D" parent="HBoxContainer/SubViewportContainer/SubViewport"]
+transform = Transform3D(1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 9, 10)
+projection = 1
+size = 10.0
+
+[node name="WorldEnvironment" type="WorldEnvironment" parent="HBoxContainer/SubViewportContainer/SubViewport"]
+environment = SubResource("Environment_sn6lt")
+
+[node name="DirectionalLight3D" type="DirectionalLight3D" parent="HBoxContainer/SubViewportContainer/SubViewport"]
+transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0, 25, 0)
+shadow_enabled = true
diff --git a/stage/dice_throw/dice_throw_3d.gd b/stage/dice_throw/dice_throw_3d.gd
new file mode 100644
index 0000000..c5734a0
--- /dev/null
+++ b/stage/dice_throw/dice_throw_3d.gd
@@ -0,0 +1,11 @@
+extends Node3D
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready() -> void:
+ $Dice.roll()
+
+
+func _process(_delta: float) -> void:
+ if Input.is_action_just_pressed("ui_accept"):
+ $Dice.roll(Vector3(1,1,0))
diff --git a/stage/dice_throw/dice_throw_3d.tscn b/stage/dice_throw/dice_throw_3d.tscn
new file mode 100644
index 0000000..15be9f5
--- /dev/null
+++ b/stage/dice_throw/dice_throw_3d.tscn
@@ -0,0 +1,34 @@
+[gd_scene load_steps=4 format=3 uid="uid://dlkds7l1kw468"]
+
+[ext_resource type="PackedScene" uid="uid://dnq7fpof6w0mj" path="res://stage/dice_throw/dice.tscn" id="1_ovyq0"]
+[ext_resource type="Script" path="res://stage/dice_throw/dice_throw_3d.gd" id="1_w4qjs"]
+
+[sub_resource type="BoxShape3D" id="BoxShape3D_pbdn1"]
+size = Vector3(10, 0.1, 10)
+
+[node name="DiceThrow3D" type="Node3D"]
+script = ExtResource("1_w4qjs")
+
+[node name="StaticBody3D" type="StaticBody3D" parent="."]
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
+shape = SubResource("BoxShape3D_pbdn1")
+
+[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D"]
+transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 5, 5, 0)
+shape = SubResource("BoxShape3D_pbdn1")
+
+[node name="CollisionShape3D5" type="CollisionShape3D" parent="StaticBody3D"]
+transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, -5, 5, 0)
+shape = SubResource("BoxShape3D_pbdn1")
+
+[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D"]
+transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 5, 5)
+shape = SubResource("BoxShape3D_pbdn1")
+
+[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D"]
+transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 5, -5)
+shape = SubResource("BoxShape3D_pbdn1")
+
+[node name="Dice" parent="." instance=ExtResource("1_ovyq0")]
+transform = Transform3D(1, 0, 0, 0, 0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 2.83258, -2)