Skip to content

Commit 0156277

Browse files
committed
feat: add ready screen and timer
Added a one-second ready screen before the timer starts.
1 parent 7729442 commit 0156277

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

scenes/play.tscn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@ margin_left = 20.0
6060
margin_top = 20.0
6161
margin_right = 1840.0
6262
margin_bottom = 914.0
63+
64+
[node name="Timer" type="Timer" parent="."]
65+
one_shot = true
66+
autostart = true
67+
[connection signal="timeout" from="Timer" to="PlayingScreen" method="_on_Timer_timeout"]

scripts/play.gd

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
extends VBoxContainer
22

3+
var start_time = -1
4+
35
func _ready():
6+
var label = Label.new()
7+
label.text = "ready..."
8+
label.align = Label.ALIGN_CENTER
9+
label.set_anchors_preset(Control.PRESET_HCENTER_WIDE)
10+
$DisplayBorder/Display.add_child(label)
411
$HUDBorder/HUD/Level.text = scene.get_param("level")
12+
match scene.get_param("level"):
13+
"BUBBLE SORT":
14+
pass
15+
16+
func _process(delta):
17+
var elapsed_time = stepify((OS.get_ticks_msec() - start_time) / 1000.0, 0.001)
18+
$HUDBorder/HUD/Score.text = "0.000" if start_time == -1 else "%.3f" % elapsed_time
519

6-
# Called every frame. 'delta' is the elapsed time since the previous frame.
7-
#func _process(delta):
8-
# pass
20+
func _on_Timer_timeout():
21+
$DisplayBorder/Display.get_child(0).queue_free()
22+
start_time = OS.get_ticks_msec()

0 commit comments

Comments
 (0)