aboutsummaryrefslogtreecommitdiffstats
path: root/godot/scenes/Die.gd
diff options
context:
space:
mode:
authorLibravatar cel <cel@blos.sm>2022-07-17 07:11:45 +0100
committerLibravatar cel <cel@blos.sm>2022-07-17 07:11:45 +0100
commit88fdf66db3dfc1c761860f1b18254a239e0e64e6 (patch)
tree7e4852117cd26b367fd78943a3f324f58d0a4d21 /godot/scenes/Die.gd
parent6cdf5b1fc587bfa7f3ed8b3388c232269946a5da (diff)
download2022-88fdf66db3dfc1c761860f1b18254a239e0e64e6.tar.gz
2022-88fdf66db3dfc1c761860f1b18254a239e0e64e6.tar.bz2
2022-88fdf66db3dfc1c761860f1b18254a239e0e64e6.zip
fix ball bug
Diffstat (limited to 'godot/scenes/Die.gd')
-rw-r--r--godot/scenes/Die.gd48
1 files changed, 34 insertions, 14 deletions
diff --git a/godot/scenes/Die.gd b/godot/scenes/Die.gd
index 76c1474..1f82417 100644
--- a/godot/scenes/Die.gd
+++ b/godot/scenes/Die.gd
@@ -15,12 +15,12 @@ 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 die_launch_force_magnitude_max = 1000
var left_pressed = false
-
var mat
-var target_bounce = 1
-var previous_bounciness = 0
+var target_bounce = 10
+var default_gravity = 2
+var default_bounciness = 0
var curr_buff = buff.none
@@ -31,6 +31,7 @@ enum buff {
stroke,
bounce,
phase,
+ gravity,
ball
}
@@ -41,7 +42,8 @@ func _ready():
$CamRoot.set_as_toplevel(true)
_game = get_node("/root/Game")
mat = get_physics_material_override()
- previous_bounciness = mat.get_bounce()
+ mat.friction = 1
+ gravity_scale = default_gravity
$PowerUI/PowerBar.hide()
$PowerUI/PowerBar.max_value = die_launch_force_magnitude_max
@@ -77,6 +79,8 @@ func _input(event):
die_launch_force_direction = -die_launch_force_direction.z
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)
+ if curr_buff != buff.ball:
+ self.apply_torque_impulse(die_launch_force)
$PowerUI/PowerBar.hide()
_game.add_stroke()
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
@@ -101,13 +105,14 @@ func _physics_process(delta):
$CamRoot.translation.y = translation.y + 5
$CamRoot.translation.z = translation.z
- if dice_is_moving == true and angular_velocity.length() < 0.01 and linear_velocity.length() < 0.01:
- dice_is_moving = false
+ if dice_is_moving == true and angular_velocity.length() < 0.1 and linear_velocity.length() < 0.1:
+ if curr_buff != buff.ball:
+ dice_is_moving = false
revert_current_buff()
curr_buff = get_buff_from_upwards_side()
apply_buff()
- elif dice_is_moving == false and angular_velocity.length() >= 0.01 and linear_velocity.length() >= 0.01:
+ elif dice_is_moving == false and angular_velocity.length() >= 0.1 and linear_velocity.length() >= 0.1:
dice_is_moving = true
@@ -120,29 +125,37 @@ func _physics_process(delta):
BUFFS
"""
+func is_on_side():
+ if $Plus1.get_overlapping_areas().size() > 0 || $Plus2.get_overlapping_areas().size() > 0 || $Ball1.get_overlapping_areas().size() > 0 || $Ball2.get_overlapping_areas().size() > 0 || $Bounce1.get_overlapping_areas().size() > 0 || $Bounce2.get_overlapping_areas().size() > 0 || $Phase1.get_overlapping_areas().size() > 0 || $Phase2.get_overlapping_areas().size() > 0:
+ return true
+ else:
+ return false
+
func get_buff_from_upwards_side():
if $Plus1.get_overlapping_areas().size() > 0 || $Plus2.get_overlapping_areas().size() > 0:
return buff.stroke
if $Ball1.get_overlapping_areas().size() > 0 || $Ball2.get_overlapping_areas().size() > 0:
return buff.ball
if $Bounce1.get_overlapping_areas().size() > 0 || $Bounce2.get_overlapping_areas().size() > 0:
- return buff.bounce
+ return buff.gravity
if $Phase1.get_overlapping_areas().size() > 0 || $Phase2.get_overlapping_areas().size() > 0:
return buff.phase
return buff.none
+func low_gravity():
+ gravity_scale = 0.2
+
func extra_stroke():
_game.revoke_stroke()
-
func bounciness():
- mat.set_bounce(target_bounce)
+ mat.bounce = target_bounce
func bounciness_revert():
- mat.set_bounce(previous_bounciness)
+ mat.bounce = default_bounciness
func phase():
@@ -157,6 +170,8 @@ func ball():
$BallShape.show()
$BallShape.set_process(true)
$BallShape.disabled = false
+ angular_velocity = Vector3(0,0,0)
+ linear_velocity = Vector3(0,0,0)
func ball_revert():
@@ -165,6 +180,7 @@ func ball_revert():
$BallShape.disabled = true
+
func revert_current_buff():
match curr_buff:
buff.ball:
@@ -173,15 +189,19 @@ func revert_current_buff():
bounciness_revert()
buff.phase:
phase_revert()
-
+ buff.gravity:
+ gravity_scale = default_gravity
func apply_buff():
match curr_buff:
buff.ball:
+ gravity_scale = default_gravity
ball()
buff.bounce:
+ gravity_scale = default_gravity
bounciness()
buff.phase:
phase()
+ gravity_scale = default_gravity
buff.stroke:
- extra_stroke()
+ low_gravity()