Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
refactor: use signals for respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Feb 6, 2024
1 parent 4a478c5 commit b704ec2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion game/characters/wizard/wizard.gd
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,3 @@ func _on_rock_hit(points: int) -> void:

func _on_anti_math_juice_poisoned(amount: int) -> void:
mana -= amount
position = get_parent().get_node("Spawn").global_position
2 changes: 2 additions & 0 deletions game/levels/1.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ question = "1+1"
[connection signal="hit" from="Rock3" to="Wizard" method="_on_rock_hit"]
[connection signal="hit" from="Rock4" to="Wizard" method="_on_rock_hit"]
[connection signal="hit" from="Rock5" to="Wizard" method="_on_rock_hit"]
[connection signal="poisoned" from="AntiMathJuice" to="." method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="AntiMathJuice" to="Wizard" method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="AntiMathJuicePool" to="." method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="AntiMathJuicePool" to="Wizard" method="_on_anti_math_juice_poisoned"]
[connection signal="hit" from="Rock2" to="Wizard" method="_on_rock_hit"]
4 changes: 4 additions & 0 deletions game/levels/level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ func _on_wizard_did_fire(ball: int, direction: float, location: Vector2) -> void
spawned.position = location + Vector2(12, -8)
spawned.velocity = spawned.velocity.rotated(direction)
spawned.z_index = 20


func _on_anti_math_juice_poisoned(_amount: int) -> void:
%Wizard.position = %Spawn.global_position
10 changes: 4 additions & 6 deletions game/levels/tutorial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ layer_2/tile_data = PackedInt32Array(2228261, 65536, 2, 1966120, 65536, 2, 22282
[node name="Wizard" parent="." instance=ExtResource("2_gvfjw")]
unique_name_in_owner = true
position = Vector2(566, 538)
speed = 200
jump_velocity = -350.0
floaty = 150.0
feather = 20
friction = 25

[node name="Camera" type="Camera2D" parent="Wizard"]
zoom = Vector2(2, 2)
Expand Down Expand Up @@ -171,7 +166,8 @@ scale = Vector2(2.5, 1)
position = Vector2(3200, 430)
scale = Vector2(5, 1)

[node name="Spawn" type="Area2D" parent="."]
[node name="Spawn" type="Marker2D" parent="."]
unique_name_in_owner = true
position = Vector2(566, 541)

[node name="Checkpoint" parent="." instance=ExtResource("6_newtr")]
Expand All @@ -191,5 +187,7 @@ position = Vector2(585, 100)
[connection signal="score_updated" from="Wizard" to="HUD" method="_on_wizard_score_updated"]
[connection signal="hit" from="Rock" to="Wizard" method="_on_rock_hit"]
[connection signal="hit" from="Rock2" to="Wizard" method="_on_rock_hit"]
[connection signal="poisoned" from="AntiMathJuice" to="." method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="AntiMathJuice" to="Wizard" method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="LargeAntiMathJuice" to="." method="_on_anti_math_juice_poisoned"]
[connection signal="poisoned" from="LargeAntiMathJuice" to="Wizard" method="_on_anti_math_juice_poisoned"]
2 changes: 1 addition & 1 deletion game/scenes/checkpoint/checkpoint.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ extends Area2D


func _on_body_entered(_body: Node2D) -> void:
get_parent().get_node("Spawn").position = position
%Spawn.position = position

0 comments on commit b704ec2

Please sign in to comment.