feat: Add time limit with level restart

This commit is contained in:
Dendy 2026-03-05 12:59:12 +01:00
parent 1566354cc6
commit 5d2fd16e87
2 changed files with 26 additions and 2 deletions

View File

@ -16,10 +16,15 @@ var stamina: float = max_stamina
func _ready() -> void:
$Upgrades.update()
$TimeLimit.start()
func _process(delta: float) -> void:
$StaminaLabel.text = str(int(stamina))
var time_left = int($TimeLimit.time_left)
@warning_ignore("integer_division")
$TimeLimitLabel.text = "%02d:%02d" % [time_left/60, time_left]
var dir = Input.get_vector("player_move_left", "player_move_right", "player_move_up", "player_move_down")
var speed: float = BASE_SPEED
@ -51,3 +56,8 @@ func _on_area_area_exited(area: Area3D) -> void:
if area.name == "PedestrianArea":
pedestrian_area_count -= 1
print(pedestrian_area_count)
func _on_time_limit_timeout():
station_reached.emit()
$TimeLimit.start()

View File

@ -42,9 +42,22 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
shape = SubResource("CylinderShape3D_i3pqv")
debug_color = Color(0.41852123, 0.4635067, 0.996484, 0.41960785)
[node name="TimeLimitLabel" type="Label" parent="." unique_id=1179212384]
offset_left = 10.0
offset_top = 10.0
offset_right = 110.0
offset_bottom = 33.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
[node name="TimeLimit" type="Timer" parent="." unique_id=1568603467]
wait_time = 10.0
one_shot = true
[node name="StaminaLabel" type="Label" parent="." unique_id=762689230]
offset_right = 99.0
offset_bottom = 46.0
offset_left = 10.0
offset_top = 41.0
offset_right = 110.0
offset_bottom = 64.0
theme_override_colors/font_color = Color(0.83137256, 0, 0.18039216, 1)
[node name="Hurtbox" type="Area3D" parent="." unique_id=2004081669]
@ -65,5 +78,6 @@ debug_color = Color(0.5381443, 0.5430501, 0.4771669, 0.41960785)
shape = SubResource("CylinderShape3D_hqtel")
debug_color = Color(0.6328197, 0.113640614, 0, 0.41960785)
[connection signal="timeout" from="TimeLimit" to="." method="_on_time_limit_timeout"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_area_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_area_area_exited"]