diff --git a/Scenes/player.tscn b/Scenes/player.tscn index b583e4b..72dd7c1 100644 --- a/Scenes/player.tscn +++ b/Scenes/player.tscn @@ -45,4 +45,5 @@ offset_right = 5000.0 offset_bottom = 5000.0 [connection signal="input_event" from="." to="BackgroundParticles" method="_on_player_input_event"] +[connection signal="player_respawned" from="." to="BackgroundParticles" method="_on_player_player_respawned"] [connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/Scripts/Levels/level_3.gd b/Scripts/Levels/level_3.gd index b0462da..7ad5a59 100644 --- a/Scripts/Levels/level_3.gd +++ b/Scripts/Levels/level_3.gd @@ -3,4 +3,4 @@ extends Node2D var startPosX : int = 24 var startPosY : int = 184 -var next_level : String = "res://Scenes/main.tscn" +var next_level : String = "res://Scenes/Levels/level_4.tscn" diff --git a/Scripts/background_particles.gd b/Scripts/background_particles.gd index 8de5a59..57e7112 100644 --- a/Scripts/background_particles.gd +++ b/Scripts/background_particles.gd @@ -63,3 +63,7 @@ func reloadParticles() -> void: #Set the material of the particle child object to the created material. particle_child.process_material = material + + +func _on_player_player_respawned() -> void: + reloadParticles() diff --git a/Scripts/player.gd b/Scripts/player.gd index d2cce8c..76cbca1 100644 --- a/Scripts/player.gd +++ b/Scripts/player.gd @@ -15,7 +15,7 @@ var move_input : float var dead : bool var tile_map_custom_data = [] -signal player_died +signal player_respawned func _ready() -> void: @@ -94,7 +94,6 @@ func death(fallen: bool) -> void: #Prevents movement. dead = true - player_died.emit() #Checks if the player has not fallen out of bounds. #If not, halt all current velocity, and shrink them down to 0 scale as a death animation. @@ -122,6 +121,8 @@ func respawn() -> void: #Sets the Y gravity back to default (downwards) if al_globals.y_gravity < 0: al_globals.y_gravity *= -1 + + player_respawned.emit() #Change their position to the start position of the current level. position.x = current_level.startPosX