aboutsummaryrefslogtreecommitdiffstats
path: root/godot
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--godot/scenes/Die.gd39
-rw-r--r--godot/scenes/Die.tscn104
2 files changed, 29 insertions, 114 deletions
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd
index 66eb02c..f7d51d5 100644
--- a/godot/scenes/Die.gd
+++ b/godot/scenes/Die.gd
@@ -14,7 +14,8 @@ var mouse_origin = Vector2(0,0)
var die_launch_force_magnitude = 0
var die_launch_force_direction = Vector3(0,0,0)
var die_launch_force = Vector3(0,0,0)
-var die_launch_force_multiplier = 0.001
+var die_launch_force_multiplier = 0.05
+var die_launch_force_magnitude_max = 500
var left_pressed = false
var mat
@@ -39,6 +40,8 @@ func _ready():
_game = get_node("/root/Game")
mat = get_physics_material_override()
previous_bounciness = mat.get_bounce()
+ $PowerUI/PowerBar.hide()
+ $PowerUI/PowerBar.max_value = die_launch_force_magnitude_max
func _input(event):
@@ -58,24 +61,30 @@ func _input(event):
if event is InputEventMouseButton and dice_is_moving == false:
if event.is_pressed() and left_pressed == false:
- Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
- mouse_origin = event.global_position
- camrot_v_locked_val = camrot_v
left_pressed = true
+ camrot_v_locked_val = camrot_v
+ #Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+ #mouse_origin = event.global_position
+ die_launch_force_magnitude = 0
+ $PowerUI/PowerBar.show()
+
else:
left_pressed = false
- die_launch_force_magnitude = -(mouse_origin.y - event.global_position.y)
+ #die_launch_force_magnitude = -(mouse_origin.y - event.global_position.y)
die_launch_force_direction = $CamRoot/Horizontal/Vertical/Camera.get_global_transform().basis
die_launch_force_direction = -die_launch_force_direction.z
- die_launch_force = die_launch_force_direction * die_launch_force_magnitude * die_launch_force_multiplier
- self.apply_impulse(global_transform.origin, die_launch_force)
- Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
- _game.add_stroke()
+ die_launch_force = die_launch_force_direction * clamp(die_launch_force_magnitude, 0, die_launch_force_magnitude_max) * die_launch_force_multiplier
+ self.apply_central_impulse(die_launch_force)
+ $PowerUI/PowerBar.hide()
+ #Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+ # add one to counter
if event is InputEventMouseMotion:
camrot_h += -event.relative.x * sensitivity
if left_pressed:
camrot_v = camrot_v_locked_val
+ die_launch_force_magnitude += event.relative.y * sensitivity
+ $PowerUI/PowerBar.value = die_launch_force_magnitude
else:
camrot_v += -event.relative.y * sensitivity
@@ -89,15 +98,11 @@ func _physics_process(delta):
$CamRoot.translation.y = translation.y + 5
$CamRoot.translation.z = translation.z
- if last_frame_position != Vector3(translation.x, translation.y, translation.x):
- dice_is_moving = true
- else:
+ if dice_is_moving == true and angular_velocity.length() < 0.01 and linear_velocity.length() < 0.01:
dice_is_moving = false
-
- if angular_velocity.length() == 0:
- get_buff_from_upwards_side()
-
- last_frame_position = Vector3(translation.x, translation.y, translation.x)
+ get_buff_from_upwards_side()
+ elif dice_is_moving == false and angular_velocity.length() >= 0.01 and linear_velocity.length() >= 0.01:
+ dice_is_moving = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
diff --git a/godot/scenes/Die.tscn b/godot/scenes/Die.tscn
index a4017cb..2887ddc 100644
--- a/godot/scenes/Die.tscn
+++ b/godot/scenes/Die.tscn
@@ -1,13 +1,8 @@
-[gd_scene load_steps=9 format=2]
+[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/Die.gd" type="Script" id=1]
[ext_resource path="res://assets/game_objects/W8baseColor_Mat.material" type="Material" id=2]
-[sub_resource type="PhysicsMaterial" id=3]
-
-[sub_resource type="ConvexPolygonShape" id=2]
-points = PoolVector3Array( -0.0850063, -0.879389, -0.0282584, 0.0288993, 0.929375, 0.0289349, 0.0288993, 0.929375, -0.0289349, 0.929367, -0.0289314, 0.0289314, -0.0289784, -0.0289338, 0.929338, -0.929369, 0.028929, 0.028929, 0.0288993, -0.0289349, -0.929375, 0.0288993, -0.929375, 0.0289349, -0.0850063, 0.0282584, -0.879389, 0.0282247, 0.084959, 0.87945, 0.857489, 0.056933, -0.0855785, -0.879454, -0.0849424, 0.0282549, 0.0570775, -0.885814, -0.0571088, 0.0570775, -0.0571088, 0.885814, -0.0571532, 0.885743, -0.0571043, -0.0571532, 0.885743, 0.0571043, 0.0570775, 0.0571088, -0.885814, -0.885806, -0.057097, -0.057097, 0.879446, 0.0849494, 0.0282572, 0.857335, -0.0571018, -0.0855632, -0.0571532, 0.0571043, 0.885743, -0.0571532, -0.885743, 0.0571043, -0.885806, 0.057097, -0.057097, -0.0571532, -0.0571043, -0.885743, 0.0570775, 0.0571088, 0.885814, -0.0571532, -0.885743, -0.0571043, -0.0571532, 0.0571043, -0.885743, 0.0570775, -0.885814, 0.0571088, 0.0570775, 0.885814, 0.0571088, -0.0571532, -0.0571043, 0.885743, -0.885806, 0.057097, 0.057097, 0.0570775, 0.885814, -0.0571088, 0.0570775, -0.0571088, -0.885814, 0.857335, -0.0571018, 0.0855632, -0.885806, -0.057097, 0.057097, 0.857489, 0.056933, 0.0855785, 0.929425, 0.0287513, -0.0289333, 0.929367, -0.0289314, -0.0289314, -0.0289784, 0.929338, -0.0289338, 0.0288993, 0.0289349, -0.929375, -0.929369, -0.028929, -0.028929, -0.0283039, -0.87942, -0.0849561, 0.084933, 0.0282608, 0.879461, -0.0289784, 0.929338, 0.0289338, -0.0289784, -0.0289338, -0.929338, -0.0289784, 0.0289338, 0.929338, 0.0288993, -0.0289349, 0.929375, 0.0288993, -0.929375, -0.0289349, -0.0289784, -0.929338, 0.0289338, -0.929369, 0.028929, -0.028929, -0.0283039, 0.0849561, -0.87942, -0.879454, -0.0282549, 0.0849424, 0.879512, 0.0280816, 0.0849558, 0.879446, -0.0849494, -0.0282572, -0.0282988, -0.822574, 0.141805, 0.17021, 0.0280745, -0.794261, -0.879454, 0.0849424, -0.0282549, -0.0283039, 0.87942, 0.0849561, 0.0282247, 0.87945, -0.084959, 0.0282247, -0.084959, -0.87945, -0.879454, -0.0282549, -0.0849424, -0.0850063, 0.0282584, 0.879389, -0.0850063, 0.879389, 0.0282584, 0.084933, -0.0282608, 0.879461 )
-
[sub_resource type="ArrayMesh" id=1]
resource_name = "W8_Cone"
surfaces/0 = {
@@ -23,38 +18,21 @@ surfaces/0 = {
"vertex_count": 68
}
-[sub_resource type="SphereShape" id=4]
-
-[sub_resource type="SphereMesh" id=5]
-
-[sub_resource type="SphereShape" id=6]
-radius = 0.1
+[sub_resource type="ConvexPolygonShape" id=2]
+points = PoolVector3Array( -0.0850063, -0.879389, -0.0282584, 0.0288993, 0.929375, 0.0289349, 0.0288993, 0.929375, -0.0289349, 0.929367, -0.0289314, 0.0289314, -0.0289784, -0.0289338, 0.929338, -0.929369, 0.028929, 0.028929, 0.0288993, -0.0289349, -0.929375, 0.0288993, -0.929375, 0.0289349, -0.0850063, 0.0282584, -0.879389, 0.0282247, 0.084959, 0.87945, 0.857489, 0.056933, -0.0855785, -0.879454, -0.0849424, 0.0282549, 0.0570775, -0.885814, -0.0571088, 0.0570775, -0.0571088, 0.885814, -0.0571532, 0.885743, -0.0571043, -0.0571532, 0.885743, 0.0571043, 0.0570775, 0.0571088, -0.885814, -0.885806, -0.057097, -0.057097, 0.879446, 0.0849494, 0.0282572, 0.857335, -0.0571018, -0.0855632, -0.0571532, 0.0571043, 0.885743, -0.0571532, -0.885743, 0.0571043, -0.885806, 0.057097, -0.057097, -0.0571532, -0.0571043, -0.885743, 0.0570775, 0.0571088, 0.885814, -0.0571532, -0.885743, -0.0571043, -0.0571532, 0.0571043, -0.885743, 0.0570775, -0.885814, 0.0571088, 0.0570775, 0.885814, 0.0571088, -0.0571532, -0.0571043, 0.885743, -0.885806, 0.057097, 0.057097, 0.0570775, 0.885814, -0.0571088, 0.0570775, -0.0571088, -0.885814, 0.857335, -0.0571018, 0.0855632, -0.885806, -0.057097, 0.057097, 0.857489, 0.056933, 0.0855785, 0.929425, 0.0287513, -0.0289333, 0.929367, -0.0289314, -0.0289314, -0.0289784, 0.929338, -0.0289338, 0.0288993, 0.0289349, -0.929375, -0.929369, -0.028929, -0.028929, -0.0283039, -0.87942, -0.0849561, 0.084933, 0.0282608, 0.879461, -0.0289784, 0.929338, 0.0289338, -0.0289784, -0.0289338, -0.929338, -0.0289784, 0.0289338, 0.929338, 0.0288993, -0.0289349, 0.929375, 0.0288993, -0.929375, -0.0289349, -0.0289784, -0.929338, 0.0289338, -0.929369, 0.028929, -0.028929, -0.0283039, 0.0849561, -0.87942, -0.879454, -0.0282549, 0.0849424, 0.879512, 0.0280816, 0.0849558, 0.879446, -0.0849494, -0.0282572, -0.0282988, -0.822574, 0.141805, 0.17021, 0.0280745, -0.794261, -0.879454, 0.0849424, -0.0282549, -0.0283039, 0.87942, 0.0849561, 0.0282247, 0.87945, -0.084959, 0.0282247, -0.084959, -0.87945, -0.879454, -0.0282549, -0.0849424, -0.0850063, 0.0282584, 0.879389, -0.0850063, 0.879389, 0.0282584, 0.084933, -0.0282608, 0.879461 )
[node name="Die" type="RigidBody"]
-collision_mask = 3
-physics_material_override = SubResource( 3 )
script = ExtResource( 1 )
-[node name="CollisionShape" type="CollisionShape" parent="."]
-shape = SubResource( 2 )
-
-[node name="Cone" type="MeshInstance" parent="CollisionShape"]
+[node name="MeshDie" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
-skeleton = NodePath("../../..")
-material/0 = null
-
-[node name="BallShape" type="CollisionShape" parent="."]
-visible = false
-shape = SubResource( 4 )
-disabled = true
-
-[node name="Ball" type="MeshInstance" parent="BallShape"]
-mesh = SubResource( 5 )
skeleton = NodePath("../..")
material/0 = null
+[node name="CollisionShapeDie" type="CollisionShape" parent="."]
+shape = SubResource( 2 )
+
[node name="CamRoot" type="Spatial" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 15.0578, 0 )
[node name="Horizontal" type="Spatial" parent="CamRoot"]
@@ -62,71 +40,3 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 15.0578, 0 )
[node name="Camera" type="ClippedCamera" parent="CamRoot/Horizontal/Vertical"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10.1285 )
-current = true
-far = 8192.0
-margin = 0.57
-process_mode = 1
-
-[node name="Plus1" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.326057, 0.384412, 0.301075 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Plus1"]
-shape = SubResource( 6 )
-
-[node name="Plus2" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.326, -0.384, -0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Plus2"]
-shape = SubResource( 6 )
-
-[node name="Ball1" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.326, -0.384, 0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Ball1"]
-shape = SubResource( 6 )
-
-[node name="Ball2" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.326, 0.384, -0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Ball2"]
-shape = SubResource( 6 )
-
-[node name="Bounce1" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.326, 0.384, -0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Bounce1"]
-shape = SubResource( 6 )
-
-[node name="Bounce2" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.326, -0.384, 0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Bounce2"]
-shape = SubResource( 6 )
-
-[node name="Phase1" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.326, -0.384, -0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Phase1"]
-shape = SubResource( 6 )
-
-[node name="Phase2" type="Area" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.326, 0.384, 0.301 )
-collision_layer = 4
-collision_mask = 4
-
-[node name="CollisionShape" type="CollisionShape" parent="Phase2"]
-shape = SubResource( 6 )