aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--godot/scenes/Die.gd34
-rw-r--r--godot/scenes/Die.tscn12
2 files changed, 33 insertions, 13 deletions
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd
index 9341bc1..558af14 100644
--- a/godot/scenes/Die.gd
+++ b/godot/scenes/Die.gd
@@ -15,6 +15,7 @@ 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.05
+var die_launch_force_magnitude_max = 500
var left_pressed = false
var mat
@@ -31,6 +32,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):
@@ -50,23 +53,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
+ 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)
- Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+ $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
@@ -80,15 +90,13 @@ 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
+ get_upwards_side()
+ elif dice_is_moving == false and angular_velocity.length() >= 0.01 and linear_velocity.length() >= 0.01:
+ dice_is_moving = true
- if angular_velocity.length() == 0:
- get_upwards_side()
-
- last_frame_position = Vector3(translation.x, translation.y, translation.x)
+
# 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 bbd73ed..89e6059 100644
--- a/godot/scenes/Die.tscn
+++ b/godot/scenes/Die.tscn
@@ -62,3 +62,15 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10.1285 )
far = 8192.0
margin = 0.57
process_mode = 1
+
+[node name="PowerUI" type="Control" parent="."]
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_right = 40.0
+margin_bottom = 40.0
+
+[node name="PowerBar" type="ProgressBar" parent="PowerUI"]
+margin_left = 102.0
+margin_top = 76.0
+margin_right = 768.0
+margin_bottom = 215.0