fix: Solution for getting stuck under frog

This commit is contained in:
Jakob Feldmann 2023-07-30 17:47:32 +02:00
parent b55902f0ba
commit 100c9b547a
7 changed files with 89 additions and 55 deletions

View File

@ -76,6 +76,54 @@ func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
$LeashAnchor.visible = true
func execute_movement(delta: float) -> void:
# Navigation2DServer.map_get_path()
current_delta = delta
# TODO what when the game runs really long and the float runs out of space?
# Achievment maybe lul
detect_timer += delta
velocity.y += _gravity * delta
if(is_bound):
var next_position = global_position + velocity * current_delta
var current_distance = global_position.distance_to(anchor.global_position)
var new_distance = next_position.distance_to(anchor.global_position)
# TODO Fix this in respects to x and y distances and movement dampening
# Maybe use mathemathematics or something idfc
if(current_distance >= movement_radius && new_distance > current_distance):
velocity.x = velocity.x * 0.8
velocity.y = velocity.y * 0.8
was_restricted = true
velocity = move_and_slide(velocity, FLOOR_NORMAL, false, 4, 0.785398, false)
if($"%GroundDetector".get_overlapping_bodies().size() > 0):
velocity.y -= 10 * (delta/0.0083)
var min_x_slide_velocity = 50 * (delta/0.0083)
velocity.x = sign(velocity.x) * max(min_x_slide_velocity, velocity.x * 0.99)
return
elif(is_on_floor()):
velocity = Vector2(0,0)
# Reverse direction when hitting limit
func die() -> void:
levelState.kills += 1
queue_free()
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()
func _on_EnemySkin_body_entered(body: Node) -> void:
if body.is_in_group("frogfood"):
loose_target()
body.die()
func _on_StompDetector_body_entered(body: Node) -> void:
if body.is_in_group("player"):
attached_player = body
@ -102,47 +150,6 @@ func _on_StompDetector_body_exited(body: Node) -> void:
$FeelerRayCast.collision_mask += 1
attached_player = null
func execute_movement(delta: float) -> void:
# Navigation2DServer.map_get_path()
current_delta = delta
detect_timer += delta
velocity.y += _gravity * delta
if(is_bound):
var next_position = global_position + velocity * current_delta
var current_distance = global_position.distance_to(anchor.global_position)
var new_distance = next_position.distance_to(anchor.global_position)
# TODO Fix this in respects to x and y distances and movement dampening
# Maybe use mathemathematics or something idfc
if(current_distance >= movement_radius && new_distance > current_distance):
velocity.x = velocity.x * 0.8
velocity.y = velocity.y * 0.8
was_restricted = true
velocity = move_and_slide(velocity, FLOOR_NORMAL, false, 4, 0.785398, false)
if(is_on_floor()):
velocity = Vector2(0,0)
# Reverse direction when hitting limit
func die() -> void:
levelState.kills += 1
queue_free()
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()
func _on_EnemySkin_body_entered(body: Node) -> void:
if body.is_in_group("frogfood"):
loose_target()
body.die()
func searching() -> Vector2:
if(detect_timer > 0.333):

View File

@ -427,7 +427,7 @@ graph_offset = Vector2( -379, -204 )
extents = Vector2( 12, 9 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 11, 1.875 )
extents = Vector2( 12, 0.5 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 18.2143, 13.5955 )
@ -559,6 +559,18 @@ monitorable = false
position = Vector2( 0, -0.875 )
shape = SubResource( 2 )
[node name="GroundDetector" type="Area2D" parent="."]
unique_name_in_owner = true
modulate = Color( 0, 0.0392157, 1, 1 )
position = Vector2( 0, 9 )
collision_layer = 0
input_pickable = false
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="GroundDetector"]
position = Vector2( 0, 2 )
shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="."]
process_priority = -1
scale = Vector2( 0.7, 0.7 )

View File

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

View File

@ -59,9 +59,14 @@ wait_time = 20.0
[node name="BlobbyCam" parent="." instance=ExtResource( 7 )]
unique_name_in_owner = true
drag_margin_top = 0.1
drag_margin_bottom = 0.1
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 10
frame = 1
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 0
[node name="Blobby" parent="." instance=ExtResource( 8 )]
unique_name_in_owner = true
@ -84,7 +89,7 @@ collision_layer = 8
collision_mask = 8
bake_navigation = true
format = 1
tile_data = PoolIntArray( -1245078, 5, 6, -1179542, 5, 6, -1114006, 5, 6, -1048470, 5, 6, -982934, 5, 6, -917398, 5, 6, -851862, 5, 6, -720912, 5, 524293, -786326, 5, 6, -655376, 5, 524293, -720790, 5, 6, -589840, 5, 524293, -589835, 1610612741, 196609, -589834, 5, 196613, -589833, -1073741819, 196609, -589829, 1610612741, 6, -655254, 5, 6, -524304, 5, 524293, -524299, -1073741819, 196616, -524298, 5, 393221, -524297, -1073741819, 196610, -524293, 1610612741, 6, -589718, 5, 6, -458768, 5, 524293, -458763, -1610612731, 196609, -458762, 5, 196610, -458761, 5, 196609, -458758, -1073741819, 262150, -458757, 1610612741, 6, -524182, 5, 6, -393232, 5, 524293, -393230, 1610612741, 65539, -393229, 1610612741, 3, -393228, 1610612741, 3, -393227, 1610612741, 3, -393226, 1610612741, 3, -393225, 1610612741, 3, -393224, 1610612741, 3, -393223, 1073741829, 2, -393222, 5, 65541, -393221, 1610612741, 6, -458646, 5, 6, -327696, 5, 524293, -327694, 5, 7, -327686, 5, 6, -327685, 5, 8, -393110, 5, 6, -262160, 5, 524293, -262158, 5, 7, -262150, 5, 6, -262149, 5, 8, -327574, 5, 6, -196624, 5, 524293, -196622, 5, 7, -196614, 5, 6, -196613, 5, 8, -262133, 5, 1, -262132, 5, 2, -262131, 5, 2, -262130, 5, 2, -262129, 5, 2, -262128, 5, 2, -262127, 5, 2, -262126, 5, 2, -262125, 5, 2, -262124, 5, 2, -262123, 5, 5, -262082, 5, 1, -262081, 5, 2, -262080, 5, 2, -262079, 5, 2, -262078, 5, 2, -262077, 5, 2, -262076, 5, 2, -262075, 5, 2, -262074, 5, 2, -262073, 5, 2, -262072, 5, 2, -262071, 5, 2, -262070, 5, 2, -262069, 5, 2, -262068, 5, 2, -262067, 5, 2, -262066, 5, 2, -262065, 5, 2, -262064, 5, 2, -262063, 5, 2, -262062, 5, 2, -262061, 5, 2, -262060, 5, 2, -262059, 5, 2, -262058, 5, 2, -262057, 5, 2, -262056, 5, 2, -262055, 5, 2, -262054, 5, 2, -262053, 5, 2, -262052, 5, 2, -262051, 5, 2, -262050, 5, 2, -262049, 5, 2, -262048, 5, 2, -262047, 5, 2, -262046, 5, 2, -262045, 5, 2, -262044, 5, 2, -262043, 5, 2, -262042, 5, 2, -262041, 5, 2, -262040, 5, 2, -262039, 5, 2, -262038, 5, 65539, -131088, 5, 524293, -131086, 5, 7, -131078, 5, 6, -131077, 5, 65538, -131076, 5, 2, -131075, 5, 2, -131074, 5, 5, -196606, 5, 1, -196605, 5, 2, -196604, 5, 5, -196597, 5, 9, -196596, 5, 10, -196595, 5, 10, -196594, 5, 10, -196593, 5, 65541, -196587, 5, 7, -196546, 5, 6, -65552, 5, 524293, -65550, 5, 7, -65542, 5, 6, -65538, 5, 7, -131070, 5, 6, -131068, 5, 7, -131057, 5, 6, -131051, 5, 7, -131010, 5, 6, -16, 5, 524293, -14, 5, 7, -6, 5, 6, -2, 5, 7, -65534, 5, 6, -65532, 5, 7, -65521, 5, 6, -65515, 5, 7, -65486, 5, 65542, -65485, 5, 65543, -65484, 5, 65543, -65483, 5, 65543, -65482, 5, 65543, -65481, 5, 65543, -65480, 5, 65544, -65474, 5, 6, 65520, 5, 524293, 65522, 5, 7, 65530, 5, 6, 65534, 5, 7, 2, 5, 6, 4, 5, 65538, 5, 5, 2, 6, 5, 2, 7, 5, 5, 15, 5, 6, 21, 5, 7, 29, 5, 1, 30, 5, 2, 31, 5, 2, 32, 5, 2, 33, 5, 2, 34, 5, 2, 35, 5, 2, 36, 5, 2, 37, 5, 2, 38, 5, 2, 39, 5, 2, 40, 5, 2, 41, 5, 2, 42, 5, 2, 43, 5, 5, 62, 5, 6, 131056, 5, 524293, 131058, 5, 7, 131066, 5, 6, 131071, 5, 2, 65536, 5, 2, 65537, 5, 2, 65538, 5, 65540, 65539, 5, 10, 65540, 5, 10, 65541, 5, 10, 65542, 5, 10, 65543, 5, 65536, 65551, 5, 6, 65557, 5, 7, 65565, 5, 6, 65579, 5, 7, 65598, 5, 6, 196592, 5, 524293, 196594, 5, 7, 196602, 5, 9, 196603, 5, 10, 196604, 5, 10, 196605, 5, 10, 196606, 5, 10, 196607, 5, 10, 131072, 5, 10, 131073, 5, 10, 131074, 5, 65536, 131087, 5, 6, 131093, 5, 7, 131101, 5, 6, 131115, 5, 7, 131134, 5, 6, 262128, 5, 524293, 262130, 5, 7, 196619, 5, 1, 196620, 5, 2, 196621, 5, 2, 196622, 5, 2, 196623, 5, 65539, 196629, 5, 7, 196637, 5, 6, 196651, 5, 7, 196670, 5, 6, 327664, 5, 524293, 327666, 5, 7, 262155, 5, 6, 262165, 5, 7, 262173, 5, 6, 262187, 5, 7, 262206, 5, 6, 393200, 5, 524293, 393202, 5, 7, 327691, 5, 6, 327701, 5, 7, 327709, 5, 6, 327723, 5, 7, 327742, 5, 6, 458736, 5, 524293, 458738, 5, 7, 393227, 5, 6, 393237, 5, 7, 393245, 5, 6, 393259, 5, 7, 524272, 5, 524293, 524274, 5, 65538, 524275, 5, 2, 524276, 5, 2, 524277, 5, 2, 524278, 5, 2, 524279, 536870917, 2, 524280, 536870917, 2, 524281, 536870917, 2, 524282, 536870917, 2, 524283, 536870917, 2, 524284, 536870917, 2, 524285, 5, 2, 524286, 5, 2, 524287, 5, 2, 458752, 5, 2, 458753, 5, 2, 458754, 5, 2, 458755, 5, 2, 458756, 5, 2, 458757, 5, 2, 458758, 5, 2, 458759, 5, 2, 458760, 5, 2, 458761, 5, 2, 458762, 5, 2, 458763, 5, 65539, 458795, 5, 7, 589808, 5, 524293, 655344, 5, 524293, 655345, 5, 524293, 655346, 5, 524293, 655347, 5, 524293, 655348, 5, 524293, 655349, 5, 524293, 655350, 5, 524293, 655351, 5, 524293, 655352, 5, 524293, 655353, 5, 524293, 655354, 5, 524293, 655355, 5, 524293, 655356, 5, 524293 )
tile_data = PoolIntArray( -1245078, 5, 6, -1179542, 5, 6, -1114006, 5, 6, -1048470, 5, 6, -982934, 5, 6, -917398, 5, 6, -851862, 5, 6, -720912, 5, 524293, -786326, 5, 6, -655376, 5, 524293, -720790, 5, 6, -589840, 5, 524293, -589835, 1610612741, 196609, -589834, 5, 196613, -589833, -1073741819, 196609, -589829, 1610612741, 6, -655254, 5, 6, -524304, 5, 524293, -524299, -1073741819, 196616, -524298, 5, 393221, -524297, -1073741819, 196610, -524293, 1610612741, 6, -589718, 5, 6, -458768, 5, 524293, -458763, -1610612731, 196609, -458762, 5, 196610, -458761, 5, 196609, -458758, -1073741819, 262150, -458757, 1610612741, 6, -524182, 5, 6, -393232, 5, 524293, -393230, 1610612741, 65539, -393229, 1610612741, 3, -393228, 1610612741, 3, -393227, 1610612741, 3, -393226, 1610612741, 3, -393225, 1610612741, 3, -393224, 1610612741, 3, -393223, 1073741829, 2, -393222, 5, 65541, -393221, 1610612741, 6, -458646, 5, 6, -327696, 5, 524293, -327694, 5, 7, -327686, 5, 6, -327685, 5, 8, -393110, 5, 6, -262160, 5, 524293, -262158, 5, 7, -262150, 5, 6, -262149, 5, 8, -327574, 5, 6, -196624, 5, 524293, -196622, 5, 7, -196614, 5, 6, -196613, 5, 8, -262133, 5, 1, -262132, 5, 2, -262131, 5, 2, -262130, 5, 2, -262129, 5, 2, -262128, 5, 2, -262127, 5, 2, -262126, 5, 2, -262125, 5, 2, -262124, 5, 2, -262123, 5, 5, -262082, 5, 1, -262081, 5, 2, -262080, 5, 2, -262079, 5, 2, -262078, 5, 2, -262077, 5, 2, -262076, 5, 2, -262075, 5, 2, -262074, 5, 2, -262073, 5, 2, -262072, 5, 2, -262071, 5, 2, -262070, 5, 2, -262069, 5, 2, -262068, 5, 2, -262067, 5, 2, -262066, 5, 2, -262065, 5, 2, -262064, 5, 2, -262063, 5, 2, -262062, 5, 2, -262061, 5, 2, -262060, 5, 2, -262059, 5, 2, -262058, 5, 2, -262057, 5, 2, -262056, 5, 2, -262055, 5, 2, -262054, 5, 2, -262053, 5, 2, -262052, 5, 2, -262051, 5, 2, -262050, 5, 2, -262049, 5, 2, -262048, 5, 2, -262047, 5, 2, -262046, 5, 2, -262045, 5, 2, -262044, 5, 2, -262043, 5, 2, -262042, 5, 2, -262041, 5, 2, -262040, 5, 2, -262039, 5, 2, -262038, 5, 65539, -131088, 5, 524293, -131086, 5, 7, -131078, 5, 6, -131077, 5, 65538, -131076, 5, 2, -131075, 5, 2, -131074, 5, 5, -196606, 5, 1, -196605, 5, 2, -196604, 5, 5, -196597, 5, 9, -196596, 5, 10, -196595, 5, 10, -196594, 5, 10, -196593, 5, 65541, -196587, 5, 7, -196546, 5, 6, -65552, 5, 524293, -65550, 5, 7, -65542, 5, 6, -65538, 5, 7, -131070, 5, 6, -131068, 5, 7, -131057, 5, 6, -131051, 5, 7, -131010, 5, 6, -16, 5, 524293, -14, 5, 7, -6, 5, 6, -2, 5, 7, -65534, 5, 6, -65532, 5, 7, -65521, 5, 6, -65515, 5, 7, -65486, 5, 65542, -65485, 5, 65543, -65484, 5, 65543, -65483, 5, 65543, -65482, 5, 65543, -65481, 5, 65543, -65480, 5, 65544, -65474, 5, 6, 65520, 5, 524293, 65522, 5, 7, 65530, 5, 6, 65534, 5, 7, 2, 5, 6, 4, 5, 65538, 5, 5, 2, 6, 5, 2, 7, 5, 5, 15, 5, 6, 21, 5, 7, 29, 5, 1, 30, 5, 2, 31, 5, 2, 32, 5, 2, 33, 5, 2, 34, 5, 2, 35, 5, 2, 36, 5, 2, 37, 5, 2, 38, 5, 2, 39, 5, 2, 40, 5, 2, 41, 5, 2, 42, 5, 2, 43, 5, 5, 62, 5, 6, 131056, 5, 524293, 131058, 5, 7, 131066, 5, 6, 131071, 5, 2, 65536, 5, 2, 65537, 5, 2, 65538, 5, 65540, 65539, 5, 10, 65540, 5, 10, 65541, 5, 10, 65542, 5, 10, 65543, 5, 65536, 65551, 5, 6, 65557, 5, 7, 65565, 5, 6, 65579, 5, 7, 65598, 5, 6, 196592, 5, 524293, 196594, 5, 7, 196602, 5, 9, 196603, 5, 10, 196604, 5, 10, 196605, 5, 10, 196606, 5, 10, 196607, 5, 10, 131072, 5, 10, 131073, 5, 10, 131074, 5, 65536, 131087, 5, 6, 131093, 5, 7, 131101, 5, 6, 131115, 5, 7, 131134, 5, 6, 262128, 5, 524293, 262130, 5, 7, 196619, 5, 1, 196620, 5, 2, 196621, 5, 2, 196622, 5, 2, 196623, 5, 65539, 196629, 5, 7, 196637, 5, 6, 196651, 5, 7, 196670, 5, 6, 327664, 5, 524293, 327666, 5, 7, 262155, 5, 9, 262156, 5, 10, 262157, 5, 10, 262158, 5, 10, 262159, 5, 10, 262160, 5, 10, 262161, 5, 10, 262162, 5, 10, 262163, 5, 10, 262164, 5, 10, 262165, 5, 65536, 262173, 5, 6, 262187, 5, 7, 262206, 5, 6, 393200, 5, 524293, 393202, 5, 7, 327709, 5, 6, 327723, 5, 7, 327742, 5, 6, 458736, 5, 524293, 458738, 5, 7, 393245, 5, 6, 393259, 5, 7, 393278, 5, 6, 524272, 5, 524293, 524274, 5, 65538, 524275, 5, 2, 524276, 5, 2, 524277, 5, 2, 524278, 5, 2, 524279, 536870917, 2, 524280, 536870917, 2, 524281, 536870917, 2, 524282, 536870917, 2, 524283, 536870917, 2, 524284, 536870917, 2, 524285, 5, 2, 524286, 5, 2, 524287, 5, 2, 458752, 5, 2, 458753, 5, 2, 458754, 5, 2, 458755, 5, 2, 458756, 5, 2, 458757, 5, 2, 458758, 5, 2, 458759, 5, 2, 458760, 5, 2, 458761, 5, 2, 458762, 5, 2, 458763, 5, 3, 458764, 5, 3, 458765, 5, 3, 458766, 5, 3, 458767, 5, 3, 458768, 5, 3, 458769, 5, 3, 458770, 5, 3, 458771, 5, 3, 458772, 5, 3, 458773, 5, 3, 458774, 5, 3, 458775, 5, 3, 458776, 5, 3, 458777, 5, 3, 458778, 5, 3, 458779, 5, 3, 458780, 5, 3, 458781, 5, 65539, 458795, 5, 7, 458814, 5, 6, 589808, 5, 524293, 655344, 5, 524293, 655345, 5, 524293, 655346, 5, 524293, 655347, 5, 524293, 655348, 5, 524293, 655349, 5, 524293, 655350, 5, 524293, 655351, 5, 524293, 655352, 5, 524293, 655353, 5, 524293, 655354, 5, 524293, 655355, 5, 524293, 655356, 5, 524293 )
[node name="DropThroughPlatforms" type="TileMap" parent="."]
tile_set = ExtResource( 4 )
@ -97,7 +102,7 @@ cell_size = Vector2( 16, 16 )
format = 1
[node name="ElevatorButton" parent="." instance=ExtResource( 12 )]
position = Vector2( 874, 441 )
position = Vector2( 1440, -64 )
[node name="Portal" parent="ElevatorButton" instance=ExtResource( 6 )]
position = Vector2( 112, -8 )
@ -106,7 +111,7 @@ next_scene = "res://src/Levels/Actual Level 1.tscn"
[node name="Obstacles" type="Node2D" parent="."]
visible = false
position = Vector2( 192, -60 )
position = Vector2( -742, 148 )
[node name="Spikes" parent="Obstacles" instance=ExtResource( 11 )]
position = Vector2( 524, 100 )

File diff suppressed because one or more lines are too long

View File

@ -2,11 +2,13 @@ extends Control
# Smart ist es die notwendigen Resourcen vor dem Skriptstart zu laden
onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var levelState := get_tree().root.get_child(3).get_node("%LevelState")
onready var current_scene := get_tree().get_current_scene()
onready var pause_overlay: ColorRect = get_node("PauseOverlay")
onready var pause_title: Label = get_node("PauseOverlay/Title")
var paused := false setget set_paused
var block_ui_cancel = false
func _ready():
#signalManager.connect("player_died", self, "_on_GlobalState_player_died")
@ -20,12 +22,17 @@ func _on_GlobalState_player_died() -> void:
pause_title.text = "You lost"
func _unhandled_input(event: InputEvent) -> void:
# TODO don't match for specific text... why did i even consider that... did I pull that from the tutorial???
if event.is_action_released("pause") && pause_title.text != "You lost" && !$ControlsMenu.visible:
func _input(event: InputEvent) -> void:
if !event.is_action("pause"):
return
if block_ui_cancel || $"%ControlsMenu".visible:
block_ui_cancel = false
get_tree().set_input_as_handled()
return
#not oder ! schaltet einen boolean um
#Ist self hier notwendig?
self.paused = not paused
self.paused = not paused
block_ui_cancel = true
func set_paused(value: bool) -> void:
@ -38,5 +45,6 @@ func set_paused(value: bool) -> void:
func _on_Controls_button_up() -> void:
$ControlsMenu.visible = true
block_ui_cancel = true
$PauseOverlay.visible = false
$"%ProfilesMenu".grab_focus()

View File

@ -19,9 +19,11 @@ func _input(event: InputEvent) -> void:
return
if block_ui_cancel:
block_ui_cancel = false
get_tree().set_input_as_handled()
return
$"%Back"._on_button_up()
func rebuild(input_profile):
_action_list.clear()
var first = true