Added respawn logic ... and with it also a complete rehaul of how managing scene instances work to make it work

This commit is contained in:
2026-03-01 15:40:56 +01:00
parent 51ee5029e9
commit 6d8e8e3734
14 changed files with 194 additions and 36 deletions

View File

@@ -0,0 +1,11 @@
extends CanvasLayer
@onready var color_rect: ColorRect = $ColorRect
func _ready() -> void:
color_rect.color.a = 0
func fade(target_alpha: float, duration: float):
var tween = create_tween()
tween.tween_property(color_rect, "color:a", target_alpha, duration)
return tween

View File

@@ -0,0 +1 @@
uid://bwf56ehqo32gr

View File

@@ -0,0 +1,14 @@
[gd_scene format=3 uid="uid://3eg3a8ceom4l"]
[ext_resource type="Script" uid="uid://bwf56ehqo32gr" path="res://molecular/fade.gd" id="1_rx8rx"]
[node name="Fade" type="CanvasLayer" unique_id=853660457]
script = ExtResource("1_rx8rx")
[node name="ColorRect" type="ColorRect" parent="." unique_id=1320853444]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0)

View File

@@ -103,14 +103,25 @@ func handle_damage(dmg: int, src: Node) -> void:
healthPoints -= dmg
hasiframes = true
invulnerable_cooldown_timer.start()
if healthPoints <= 0:
print("Player died. Respawn button not implemented.")
isAlive = false
if isAlive and healthPoints <= 0:
die()
func collect_resource(damnt: int) -> void:
resources += damnt
print("Resource collected! Total: ", resources)
func die() -> void:
print("Player died.")
isAlive = false
GameManager.switch_scene("respawn")
# TODO: Is this used or should it be removed? (currently unused)
func respawm() -> void:
healthPoints = maxHealth
isAlive = true
hasiframes = true
attack_cooldown_timer.start()

View File

@@ -100,7 +100,6 @@ limit_right = 1152
limit_bottom = 648
[node name="UI" type="Node2D" parent="." unique_id=1500495475]
visible = false
[node name="CanvasLayer" type="CanvasLayer" parent="UI" unique_id=633018012]