diff --git a/objects/ice/ice.gd b/objects/ice/ice.gd index c0552f6..33292e2 100644 --- a/objects/ice/ice.gd +++ b/objects/ice/ice.gd @@ -1,20 +1,18 @@ extends Node2D -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. +var _player: Player = null -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass +func _physics_process(delta: float) -> void: + _player.state_chart.send_event(&"touched_ice") -func _on_area_2d_body_entered(body: Node2D) -> void: +func _on_player_detector_body_entered(body: Node2D) -> void: if body is Player: - pass + _player = body -func _on_area_2d_body_exited(body: Node2D) -> void: - pass +func _on_player_detector_body_exited(body: Node2D) -> void: + if body == _player: + _player = null diff --git a/objects/ice/ice.tscn b/objects/ice/ice.tscn index b979059..4d473b7 100644 --- a/objects/ice/ice.tscn +++ b/objects/ice/ice.tscn @@ -12,23 +12,24 @@ size = Vector2(16, 16) [node name="Ice" type="Node2D"] script = ExtResource("1_hgdc3") -[node name="Sprite2D" type="Sprite2D" parent="."] -texture = ExtResource("1_0p7ug") - -[node name="Area2D" type="Area2D" parent="."] +[node name="PlayerDetector" type="Area2D" parent="."] collision_layer = 0 collision_mask = 16 +monitorable = false -[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetector"] position = Vector2(0, -0.5) shape = SubResource("RectangleShape2D_sv4q1") [node name="StaticBody2D" type="StaticBody2D" parent="."] collision_layer = 2 -collision_mask = 16 +collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("RectangleShape2D_xodyg") -[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] -[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"] +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_0p7ug") + +[connection signal="body_entered" from="PlayerDetector" to="." method="_on_player_detector_body_entered"] +[connection signal="body_exited" from="PlayerDetector" to="." method="_on_player_detector_body_exited"] diff --git a/objects/player/player.tscn b/objects/player/player.tscn index 165f02d..c101986 100644 --- a/objects/player/player.tscn +++ b/objects/player/player.tscn @@ -524,15 +524,15 @@ delay_in_seconds = "0.0" [connection signal="state_physics_processing" from="StateChart/Root/Grounded" to="." method="_check_for_bonk"] [connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"] [connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Stopping" to="Graphics/Sprite/Run" method="play"] -[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_scale_run_animation"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_slow_to_stop"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_scale_run_animation"] [connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"] -[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_scale_run_animation"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] [connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Skid" method="play"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"] -[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_bonk"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_corner"] [connection signal="state_entered" from="StateChart/Root/Airborne/Falling" to="Graphics/Sprite/Fall" method="play"] [connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Graphics/Sprite/Jump" method="play"]