Skip to content

Commit 600bfd4

Browse files
committed
3d: add sample scenes for challenges (without full code)
1 parent d40d268 commit 600bfd4

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[gd_scene load_steps=4 format=3 uid="uid://dls18eeij47k4"]
2+
3+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cc56i"]
4+
bg_color = Color(0.152941, 0.168627, 0.188235, 1)
5+
border_width_left = 4
6+
border_width_top = 4
7+
border_width_right = 4
8+
border_width_bottom = 4
9+
border_color = Color(0.287008, 0.684375, 0.33128, 1)
10+
corner_radius_top_left = 24
11+
corner_radius_top_right = 24
12+
corner_radius_bottom_right = 24
13+
corner_radius_bottom_left = 24
14+
expand_margin_left = 4.0
15+
expand_margin_top = 4.0
16+
expand_margin_right = 4.0
17+
expand_margin_bottom = 4.0
18+
19+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dhpp2"]
20+
bg_color = Color(0.623529, 0.866667, 0.317647, 1)
21+
corner_radius_top_left = 20
22+
corner_radius_top_right = 20
23+
corner_radius_bottom_right = 20
24+
corner_radius_bottom_left = 20
25+
26+
[sub_resource type="LabelSettings" id="LabelSettings_dsttn"]
27+
font_size = 68
28+
29+
[node name="HealthBar" type="ProgressBar"]
30+
z_index = 100
31+
offset_left = 141.0
32+
offset_top = 39.0
33+
offset_right = 492.0
34+
offset_bottom = 100.0
35+
theme_override_styles/background = SubResource("StyleBoxFlat_cc56i")
36+
theme_override_styles/fill = SubResource("StyleBoxFlat_dhpp2")
37+
value = 100.0
38+
show_percentage = false
39+
40+
[node name="Label" type="Label" parent="."]
41+
layout_mode = 1
42+
anchors_preset = 4
43+
anchor_top = 0.5
44+
anchor_bottom = 0.5
45+
offset_left = -103.0
46+
offset_top = -47.5
47+
offset_right = -10.0
48+
offset_bottom = 45.5
49+
grow_vertical = 2
50+
text = "HP"
51+
label_settings = SubResource("LabelSettings_dsttn")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
extends Label
2+
3+
# You can use a signal like this to notify other nodes when the timer ended
4+
# and, for example, hide the player's reticle, despawn mobs, and more.
5+
signal timer_ended
6+
7+
@onready var timer = %Timer
8+
@onready var label = %Label
9+
@onready var color_rect = %ColorRect
10+
11+
12+
func _ready():
13+
label.hide()
14+
color_rect.hide()
15+
16+
17+
func _process(delta):
18+
text = "Time left: " + str(round(timer.time_left))
19+
20+
21+
func _on_timer_timeout():
22+
get_tree().paused = true
23+
label.show()
24+
color_rect.show()
25+
timer_ended.emit()
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[gd_scene load_steps=3 format=3 uid="uid://bp174uwgvqqr7"]
2+
3+
[ext_resource type="Script" path="res://lessons_reference/challenges/time_left.gd" id="1_31pkx"]
4+
5+
[sub_resource type="LabelSettings" id="LabelSettings_6iwf4"]
6+
font_size = 40
7+
8+
[node name="TimeLeftLabel" type="Label"]
9+
anchors_preset = 15
10+
anchor_right = 1.0
11+
anchor_bottom = 1.0
12+
offset_top = 19.0
13+
grow_horizontal = 2
14+
grow_vertical = 2
15+
theme_override_font_sizes/font_size = 60
16+
text = "Time: 60"
17+
horizontal_alignment = 1
18+
script = ExtResource("1_31pkx")
19+
20+
[node name="Timer" type="Timer" parent="."]
21+
unique_name_in_owner = true
22+
wait_time = 40.0
23+
one_shot = true
24+
autostart = true
25+
26+
[node name="ColorRect" type="ColorRect" parent="."]
27+
unique_name_in_owner = true
28+
top_level = true
29+
layout_mode = 1
30+
anchors_preset = 15
31+
anchor_right = 1.0
32+
anchor_bottom = 1.0
33+
grow_horizontal = 2
34+
grow_vertical = 2
35+
color = Color(0, 0, 0, 0.368627)
36+
37+
[node name="Label" type="Label" parent="."]
38+
unique_name_in_owner = true
39+
top_level = true
40+
layout_mode = 1
41+
anchors_preset = 8
42+
anchor_left = 0.5
43+
anchor_top = 0.5
44+
anchor_right = 0.5
45+
anchor_bottom = 0.5
46+
offset_left = -352.0
47+
offset_top = -156.5
48+
offset_right = 352.0
49+
offset_bottom = 156.5
50+
grow_horizontal = 2
51+
grow_vertical = 2
52+
text = "Congratulations, you won!"
53+
label_settings = SubResource("LabelSettings_6iwf4")
54+
horizontal_alignment = 1
55+
vertical_alignment = 1
56+
57+
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

0 commit comments

Comments
 (0)