fix: configurable min frog jump height checks

This commit is contained in:
Jakob Feldmann 2023-07-30 19:52:44 +02:00
parent 100c9b547a
commit 79e0fe4a2e
8 changed files with 120 additions and 117 deletions

View File

@ -336,7 +336,11 @@ func correct_jump_direction(v: Vector2) -> Vector2:
# Cast a ray to the highest point of the jump
# Check the highest point for collision
# Calculate safe jump height and then a safe jump velocity
func consider_jump_headspace(v: Vector2) -> Vector2:
# Returns 0,0 if theres no headspace
func consider_jump_headspace(v: Vector2, recursive_check_count = 0, max_checks = 2) -> Vector2:
if recursive_check_count >= max_checks:
print("Frog has no safe headspace")
return Vector2(0,0)
var height = calculate_jump_height(v)
var distance = calculate_jump_distance(v)
var angle = (v * get_facing_direction()).angle()
@ -348,14 +352,13 @@ func consider_jump_headspace(v: Vector2) -> Vector2:
var target_height = collision_point.y - (feeler_raycast.global_position.y - 23)
# print(feeler_raycast.global_position)
var new_angle = angle * (0.75 if target_height > -26 else 0.95)
var new_distance = default_jump_distance * (0.66 if target_height < -26 else 0.75)
var new_distance = abs(distance) * (0.66 if target_height < -26 else 0.75)
v = velocity_for_jump_distance(new_distance, abs(new_angle))
v = correct_jump_direction(v)
height = calculate_jump_height(v) * -1
distance = calculate_jump_distance(v) * get_facing_direction()
if(height < target_height && can_reverse_facing_direction()):
print("no safe height for frog jump")
return Vector2(0,0)
v = consider_jump_headspace(v, recursive_check_count + 1)
return v

View File

@ -63,10 +63,10 @@ drag_margin_top = 0.1
drag_margin_bottom = 0.1
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 1
frame = 7
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 0
frame = 6
[node name="Blobby" parent="." instance=ExtResource( 8 )]
unique_name_in_owner = true

View File

@ -80,10 +80,10 @@ wait_time = 20.0
unique_name_in_owner = true
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 8
frame = 1
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 7
frame = 0
[node name="Blobby" parent="." instance=ExtResource( 10 )]
unique_name_in_owner = true