aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--godot/assets/sounds/Uuhhh.mp33
-rw-r--r--godot/scenes/Die.gd54
2 files changed, 24 insertions, 33 deletions
diff --git a/godot/assets/sounds/Uuhhh.mp3 b/godot/assets/sounds/Uuhhh.mp3
deleted file mode 100644
index 9586316..0000000
--- a/godot/assets/sounds/Uuhhh.mp3
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:c87fa2ec3fd654e1004e0bdb38740ff889e26db453220f00cada2a6fe4bda412
-size 2212
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd
index 93d3bfa..6ccd16e 100644
--- a/godot/scenes/Die.gd
+++ b/godot/scenes/Die.gd
@@ -10,9 +10,12 @@ var cam_v_max = 90
var sensitivity = 0.5
var dice_is_moving = false
var last_frame_position = Vector3(1.0,1.0,1.0)
-var dragging = false
var mouse_origin = Vector2(0,0)
-var dice_launch_force = 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.05
+var left_pressed = false
var mat
var target_bounce = 1
@@ -29,39 +32,30 @@ func _ready():
mat = get_physics_material_override()
previous_bounciness = mat.get_bounce()
+func _input(event):
-func _input(event):
- if _game.is_post_game():
- _game.next_level()
- return
-
- if event is InputEventKey:
- if event.scancode == KEY_TAB:
- if event.is_pressed():
- _game.open_scoreboard()
- else:
- _game.close_scoreboard()
+ 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
+ else:
+ left_pressed = false
+ 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_central_impulse(die_launch_force)
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if event is InputEventMouseMotion:
camrot_h += -event.relative.x * sensitivity
- camrot_v += -event.relative.y * sensitivity
-
- if dice_is_moving == false:
- if event is InputEventMouseMotion and dragging:
- # While dragging, move the sprite with the mouse.
- dice_launch_force = mouse_origin.distance_to(event.global_position)
+ if left_pressed:
camrot_v = camrot_v_locked_val
- elif event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
- Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
- mouse_origin = event.global_position
- camrot_v_locked_val = camrot_v
- if not dragging and event.pressed:
- dragging = true
- # Stop dragging if the button is released.
- elif dragging and not event.pressed:
- dragging = false
- Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
-
+ else:
+ camrot_v += -event.relative.y * sensitivity
+
func _physics_process(delta):
camrot_v = clamp(camrot_v, cam_v_min, cam_v_max)