new ring counter, move some logic away from main scene

This commit is contained in:
Taevas 2025-04-23 15:37:03 +02:00
parent b81eb08e05
commit 9890e0a625
Signed by: Taevas
SSH key fingerprint: SHA256:Y5Hv18xwPvUKSlgkx1sPnRO3L2mc03ehC7BzrnZVEyY
5 changed files with 187 additions and 143 deletions

33
gui/rings.tscn Normal file
View file

@ -0,0 +1,33 @@
[gd_scene load_steps=4 format=3 uid="uid://cn55m5dqo3m6u"]
[ext_resource type="FontFile" uid="uid://c3fsj6knyiuhl" path="res://fonts/Knewave/Knewave-Regular.ttf" id="1_nja12"]
[sub_resource type="LabelSettings" id="LabelSettings_cnn6y"]
font = ExtResource("1_nja12")
font_size = 32
outline_size = 8
outline_color = Color(0, 0, 0, 1)
shadow_size = 8
shadow_color = Color(0, 0, 0, 1)
[sub_resource type="GDScript" id="GDScript_nja12"]
script/source = "extends Label
var remaining_rings := 0:
get: return remaining_rings
set(value):
remaining_rings = value
if value >= 1:
var rings_word := \"rings\" if value != 1 else \"ring\"
self.text = str(value) + \" \" + rings_word + \" to go!\"
else:
self.text = \"You did it!!\"
"
[node name="Rings" type="Label"]
offset_right = 109.0
offset_bottom = 23.0
text = "69 rings to go!"
label_settings = SubResource("LabelSettings_cnn6y")
horizontal_alignment = 2
script = SubResource("GDScript_nja12")

View file

@ -17,8 +17,8 @@ var ball_velocity := 0.0:
get: return ball_velocity
set(value):
ball_velocity = value
var rounded := int(floor(value))
self.text = str(rounded) + \" km/h\"
var rounded: float = floor(value)
self.text = str(int(rounded)) + \" km/h\"
const min_px = 32.0
const max_px = 56.0