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

Commit

Permalink
fix: es
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Feb 9, 2024
1 parent 8db4d41 commit a3f9d1c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
11 changes: 7 additions & 4 deletions game/characters/wizard/wizard.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ signal game_over
## Slow down, kid!
@export var friction: int = 25

var is_game_over: bool = false

var score := 0:
set(value):
score = value
Expand All @@ -37,6 +39,11 @@ var mana := 20:
mana = value
self.mana_updated.emit(mana)

# GAME OVER!!
if self.mana <= 0 && not is_game_over:
game_over.emit()
is_game_over = true

var times := 1.0

## Get the gravity from the project settings to be synced with RigidBody nodes.
Expand All @@ -59,10 +66,6 @@ func _process(_delta: float) -> void:
# Add a mana
self.mana += 1

# GAME OVER!!
if self.mana <= 0:
game_over.emit()


func _physics_process(delta: float) -> void:
# Add gravity.
Expand Down
8 changes: 6 additions & 2 deletions game/levels/level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ const Ball := preload("res://game/spawnables/number/number.tscn")

func _on_wizard_did_fire(ball: int, direction: float, location: Vector2) -> void:
var spawned: NumberBall = Ball.instantiate()
add_child(spawned)
spawned.num = ball
spawned.rotation = direction
spawned.position = location + Vector2(12, -8)
spawned.velocity = spawned.velocity.rotated(direction)
spawned.z_index = 20
add_child.call_deferred(spawned)


func _on_anti_math_juice_poisoned(_amount: int) -> void:
self.wizard.position = self.spawn.global_position


func _on_wizard_game_over() -> void:
scene_changed.emit("menus/game_over")
scene_changed.emit("menus/game_over/game_over")


func _on_portal_scene_changed(next_scene_name: String) -> void:
scene_changed.emit(next_scene_name)
2 changes: 2 additions & 0 deletions game/levels/tutorial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,5 @@ position = Vector2(585, 100)
[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"]
[connection signal="scene_changed" from="MainPortal" to="." method="_on_portal_scene_changed"]
[connection signal="scene_changed" from="SecretPortal" to="." method="_on_portal_scene_changed"]
2 changes: 1 addition & 1 deletion game/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func _on_scene_changed(next_scene_name: String) -> void:
var Next: PackedScene = load("res://game/%s.tscn" % next_scene_name)
next_scene = Next.instantiate()
next_scene.z_index = -1000
add_child(next_scene)
add_child.call_deferred(next_scene)
animator.play("fade_in")
var _status := next_scene.connect("scene_changed", _on_scene_changed)

Expand Down
2 changes: 1 addition & 1 deletion game/menus/game_over/game_over.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ theme_override_font_sizes/font_size = 42
action_mode = 0
text = "RESTART"

[connection signal="pressed" from="StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="RestartButton" to="." method="_on_restart_button_pressed"]
11 changes: 3 additions & 8 deletions game/scenes/portal/portal.gd
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
class_name Portal
extends Area2D

signal scene_changed(next_scene_name: String)

@export var level: int = 1


func _on_body_entered(_body: Node2D) -> void:
self.get_tree().call_deferred(
"change_scene_to_file",
(
"res://game/levels/tutorial.tscn"
if self.level == 0
else "res://game/levels/%s.tscn" % self.level
)
)
scene_changed.emit("levels/tutorial" if self.level == 0 else "levels/%s" % self.level)

0 comments on commit a3f9d1c

Please sign in to comment.