third level + km/h display

This commit is contained in:
Taevas 2025-02-23 14:27:35 +01:00
parent 203696e022
commit c19d1dffcb
27 changed files with 713 additions and 40 deletions

View file

@ -6,6 +6,7 @@ script/source = "extends Node
var seconds_spent: float = 0.0
var base = preload(\"res://levels/base/level.tscn\")
var forest = preload(\"res://levels/forest/level.tscn\")
var night = preload(\"res://levels/night/level.tscn\")
func start_level(level_scene: PackedScene) -> void:
if level_scene and level_scene.can_instantiate():
@ -17,6 +18,7 @@ func start_level(level_scene: PackedScene) -> void:
assert(false, \"NO LEVEL AAAA\")
func stop_level() -> void:
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, 1)
$Timer.paused = true
AudioServer.set_bus_volume_db(0, -5)
@ -28,15 +30,17 @@ func stop_level() -> void:
AudioServer.set_bus_volume_db(0, -50)
await get_tree().create_timer(0.5).timeout
var current_levels = $Levels.get_children(true)
var current_level = current_levels[0]
var next_level: PackedScene
if current_level.name == \"Base\":
next_level = forest
for level in current_levels:
level.queue_free()
var current_levels = $Levels.get_children(true)
if len(current_levels):
var current_level = current_levels[0]
if current_level.name == \"Base\":
next_level = forest
elif current_level.name == \"Forest\":
next_level = night
for level in current_levels:
level.queue_free()
start_level(next_level)
@ -59,11 +63,22 @@ func _on_animation_player_animation_finished(_anim_name: StringName) -> void:
func _on_timer_timeout() -> void:
seconds_spent = snapped(seconds_spent + 0.10, 0.01)
var minutes = floor(seconds_spent / 60)
$TimerDisplay.text = (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.1f\" % [4, seconds_spent - (minutes * 60)])
$Informations/MarginContainer/Timer.text = (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.1f\" % [4, seconds_spent - (minutes * 60)])
func _process(delta: float) -> void:
var current_levels = $Levels.get_children(true)
if len(current_levels):
var current_level = current_levels[0]
if is_instance_valid(current_level) and \"velocity\" in current_level:
$Informations/MarginContainer/VBoxContainer/Speed.text = str(floor(current_level.velocity)) + \" km/h\"
"
[sub_resource type="LabelSettings" id="LabelSettings_0s07t"]
font_size = 32
outline_size = 10
outline_color = Color(0, 0, 0, 1)
[sub_resource type="LabelSettings" id="LabelSettings_0jegv"]
font_size = 32
shadow_size = 2
@ -119,14 +134,55 @@ _data = {
"fadeout": SubResource("Animation_75r06")
}
[sub_resource type="LabelSettings" id="LabelSettings_0s07t"]
font_size = 64
outline_size = 10
outline_color = Color(0, 0, 0, 1)
[node name="Game" type="Node"]
script = SubResource("GDScript_8n212")
[node name="Informations" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="MarginContainer" type="MarginContainer" parent="Informations"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_right = 10
[node name="Timer" type="Label" parent="Informations/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 8
text = "00:00.0"
label_settings = SubResource("LabelSettings_0s07t")
vertical_alignment = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Informations/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = -5
alignment = 2
[node name="Rings" type="Label" parent="Informations/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "0/0"
label_settings = SubResource("LabelSettings_0s07t")
horizontal_alignment = 2
vertical_alignment = 2
[node name="Speed" type="Label" parent="Informations/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "0 km/h"
label_settings = SubResource("LabelSettings_0s07t")
horizontal_alignment = 2
vertical_alignment = 2
[node name="StartMenu" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
@ -255,18 +311,6 @@ libraries = {
[node name="Levels" type="Node" parent="."]
[node name="TimerDisplay" type="Label" parent="."]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -88.0
offset_right = 246.0
grow_vertical = 0
text = "00:00.0"
label_settings = SubResource("LabelSettings_0s07t")
horizontal_alignment = 1
vertical_alignment = 2
[node name="Timer" type="Timer" parent="."]
wait_time = 0.1