Fixed the bar so it works properly and dynamically

This commit is contained in:
theskywinds 2025-05-18 17:06:51 +02:00
parent bf3df69907
commit 44271b3c9d
2 changed files with 15 additions and 3 deletions

View File

@ -4,7 +4,7 @@
[ext_resource type="PackedScene" uid="uid://c1xy5bf2p6vmh" path="res://player/smallPlayer/player.tscn" id="2_r1egm"] [ext_resource type="PackedScene" uid="uid://c1xy5bf2p6vmh" path="res://player/smallPlayer/player.tscn" id="2_r1egm"]
[ext_resource type="PackedScene" uid="uid://darxbklsgh23m" path="res://collectables/crystal/collectableCrystal.tscn" id="3_56573"] [ext_resource type="PackedScene" uid="uid://darxbklsgh23m" path="res://collectables/crystal/collectableCrystal.tscn" id="3_56573"]
[ext_resource type="PackedScene" uid="uid://chpqjpcexhd3t" path="res://rock/Rock.tscn" id="4_1l7e8"] [ext_resource type="PackedScene" uid="uid://chpqjpcexhd3t" path="res://rock/Rock.tscn" id="4_1l7e8"]
[ext_resource type="Script" uid="uid://c3qi2ffmxsl8i" path="res://levelOne/exit_zone.gd" id="5_r1egm"] [ext_resource type="Script" path="res://levelOne/exit_zone.gd" id="5_r1egm"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_s5r4n"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_s5r4n"]
size = Vector2(67, 25) size = Vector2(67, 25)
@ -39,6 +39,15 @@ position = Vector2(87, -71)
[node name="crystal3" parent="Node2D" instance=ExtResource("3_56573")] [node name="crystal3" parent="Node2D" instance=ExtResource("3_56573")]
position = Vector2(97, -254) position = Vector2(97, -254)
[node name="crystal4" parent="Node2D" instance=ExtResource("3_56573")]
position = Vector2(214, -172)
[node name="crystal5" parent="Node2D" instance=ExtResource("3_56573")]
position = Vector2(146, 105)
[node name="crystal6" parent="Node2D" instance=ExtResource("3_56573")]
position = Vector2(-338, 156)
[node name="exitZone" type="Area2D" parent="."] [node name="exitZone" type="Area2D" parent="."]
position = Vector2(318, 1248) position = Vector2(318, 1248)
script = ExtResource("5_r1egm") script = ExtResource("5_r1egm")

View File

@ -5,7 +5,7 @@ var addAmount: float
func _ready() -> void: func _ready() -> void:
await get_tree().process_frame await get_tree().process_frame
var crystals = get_tree().get_nodes_in_group("crystals") var crystals = get_tree().get_nodes_in_group("crystals")
addAmount = crystals.size() / 100.0 addAmount = 100.0 / crystals.size()
print("Pulled " + str(crystals.size()) + " crystals from scene") print("Pulled " + str(crystals.size()) + " crystals from scene")
for crystal in crystals: for crystal in crystals:
@ -14,4 +14,7 @@ func _ready() -> void:
func collect(): func collect():
print("Collected crystal") print("Collected crystal")
value += 5.0 value += addAmount
if value > 99.0:
value = 100.0