DreamBall/index.tscn

499 lines
16 KiB
Text
Raw Normal View History

2025-02-23 17:21:13 +01:00
[gd_scene load_steps=11 format=3 uid="uid://ccgnnif026wb4"]
[ext_resource type="PackedScene" uid="uid://n40mg5tc3bnv" path="res://levels/demo_level.tscn" id="1_08svf"]
2025-02-23 00:46:23 +01:00
[sub_resource type="GDScript" id="GDScript_8n212"]
script/source = "extends Node
var seconds_spent: float = 0.0
2025-02-23 16:18:14 +01:00
var changing_level: bool = false
2025-02-23 00:46:23 +01:00
var base = preload(\"res://levels/base/level.tscn\")
var forest = preload(\"res://levels/forest/level.tscn\")
2025-02-23 14:27:35 +01:00
var night = preload(\"res://levels/night/level.tscn\")
2025-02-23 00:46:23 +01:00
2025-02-23 16:18:14 +01:00
func _ready() -> void:
2025-02-23 17:46:50 +01:00
var os_name = OS.get_name()
if os_name == \"Web\": ## we can't quit the game on web
$PauseMenu/VBoxContainer/Btn_Quit.hide()
2025-02-23 17:21:13 +01:00
$VictoryScreen.hide()
$Informations.hide()
2025-02-23 16:18:14 +01:00
$PauseMenu.hide()
## Add the version of the game and the name of the OS to the footer of the start menu
2025-02-23 17:46:50 +01:00
$StartMenu/VBoxContainer/MarginContainer2/Notice.text += \" - build \" + ProjectSettings.get_setting(\"application/config/version\") + \" (\" + os_name + \")\"
2025-02-23 16:18:14 +01:00
2025-02-23 00:46:23 +01:00
func start_level(level_scene: PackedScene) -> void:
2025-02-23 17:21:13 +01:00
$VictoryScreen.hide()
2025-02-23 00:46:23 +01:00
if level_scene and level_scene.can_instantiate():
var level = level_scene.instantiate()
$Levels.add_child(level)
$Timer.paused = false
2025-02-23 17:21:13 +01:00
AudioServer.set_bus_volume_db(0, 0)
PhysicsServer3D.area_set_param(
get_viewport().find_world_3d().space,
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,
Vector3.DOWN
)
2025-02-23 16:18:14 +01:00
changing_level = false
2025-02-23 00:46:23 +01:00
else:
2025-02-23 17:21:13 +01:00
$VictoryScreen.show()
await get_tree().create_timer(2).timeout
$StartMenu/AnimationPlayer.play_backwards(\"fadeout\")
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
await get_tree().create_timer(1).timeout
$StartMenu.modulate = Color(1,1,1,1)
2025-02-23 00:46:23 +01:00
func stop_level() -> void:
2025-02-23 14:27:35 +01:00
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, 1)
2025-02-23 00:46:23 +01:00
$Timer.paused = true
2025-02-23 16:18:14 +01:00
changing_level = true
2025-02-23 00:46:23 +01:00
AudioServer.set_bus_volume_db(0, -5)
await get_tree().create_timer(0.5).timeout
AudioServer.set_bus_volume_db(0, -10)
await get_tree().create_timer(0.5).timeout
AudioServer.set_bus_volume_db(0, -30)
await get_tree().create_timer(0.5).timeout
AudioServer.set_bus_volume_db(0, -50)
await get_tree().create_timer(0.5).timeout
var next_level: PackedScene
2025-02-23 14:27:35 +01:00
var current_levels = $Levels.get_children(true)
if len(current_levels):
var current_level = current_levels[0]
2025-02-23 16:18:14 +01:00
if current_level.get_meta(\"name\") == \"Base\":
2025-02-23 14:27:35 +01:00
next_level = forest
2025-02-23 16:18:14 +01:00
elif current_level.get_meta(\"name\") == \"Forest\":
2025-02-23 14:27:35 +01:00
next_level = night
for level in current_levels:
level.queue_free()
2025-02-23 00:46:23 +01:00
start_level(next_level)
2025-02-23 16:18:14 +01:00
func restart_level() -> void:
if changing_level == false:
var current_levels = $Levels.get_children(true)
if len(current_levels):
pause_game()
changing_level = true
var current_level = current_levels[0]
var next_level: PackedScene = base
if current_level.get_meta(\"name\") == \"Forest\":
next_level = forest
elif current_level.get_meta(\"name\") == \"Night\":
next_level = night
for level in current_levels:
level.queue_free()
start_level(next_level)
func pause_game() -> void:
if $Levels.process_mode == PROCESS_MODE_INHERIT:
$Levels.process_mode = Node.PROCESS_MODE_DISABLED
$Timer.paused = true
$PauseMenu.show()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
$Levels.process_mode = Node.PROCESS_MODE_INHERIT
$Timer.paused = false
$PauseMenu.hide()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
func fullscreen_game() -> void:
2025-02-23 00:46:23 +01:00
var fs = DisplayServer.window_get_mode()
if fs != DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_WINDOWED)
2025-02-23 16:18:14 +01:00
func _on_btn_fullscreen_pressed() -> void:
fullscreen_game()
2025-02-23 00:46:23 +01:00
func _on_btn_start_pressed() -> void:
2025-02-23 17:21:13 +01:00
seconds_spent = 0.0
var current_levels = $Levels.get_children(true)
for level in current_levels:
level.queue_free()
$Informations.show()
2025-02-23 00:46:23 +01:00
$StartMenu/AnimationPlayer.play(\"fadeout\")
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
start_level(base)
2025-02-23 17:21:13 +01:00
$Timer.start(0)
2025-02-23 00:46:23 +01:00
func _on_animation_player_animation_finished(_anim_name: StringName) -> void:
2025-02-23 17:21:13 +01:00
if $StartMenu.modulate == Color(1,1,1,1):
$StartMenu.show()
else:
$StartMenu.hide()
2025-02-23 00:46:23 +01:00
func _on_timer_timeout() -> void:
seconds_spent = snapped(seconds_spent + 0.10, 0.01)
var minutes = floor(seconds_spent / 60)
2025-02-23 14:27:35 +01:00
$Informations/MarginContainer/Timer.text = (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.1f\" % [4, seconds_spent - (minutes * 60)])
2025-02-23 16:18:14 +01:00
func _process(_delta: float) -> void:
2025-02-23 14:27:35 +01:00
var current_levels = $Levels.get_children(true)
if len(current_levels):
var current_level = current_levels[0]
2025-02-23 16:18:14 +01:00
if is_instance_valid(current_level):
if \"velocity\" in current_level:
2025-03-23 14:48:54 +01:00
$Informations/MarginContainer/VBoxContainer/Speed.text = str(int(floor(current_level.velocity))) + \" km/h\"
2025-02-23 16:18:14 +01:00
if \"rings_count\" in current_level and \"finished_rings_count\" in current_level:
$Informations/MarginContainer/VBoxContainer/Rings.text = str(current_level.finished_rings_count) + \"/\" + str(current_level.rings_count)
func _unhandled_key_input(event: InputEvent) -> void:
if event.is_pressed() and event is InputEventKey:
if $StartMenu.visible == false and changing_level == false:
if event.keycode == KEY_ESCAPE:
pause_game()
elif event.keycode == KEY_R:
pause_game()
restart_level()
func _on_btn_resume_pressed() -> void:
pause_game()
func _on_btn_fullscreen_2_pressed() -> void:
fullscreen_game()
func _on_btn_restart_pressed() -> void:
restart_level()
func _on_btn_quit_pressed() -> void:
get_tree().quit()
2025-02-23 00:46:23 +01:00
"
2025-02-23 14:27:35 +01:00
[sub_resource type="LabelSettings" id="LabelSettings_0s07t"]
font_size = 32
outline_size = 10
outline_color = Color(0, 0, 0, 1)
2025-02-23 17:21:13 +01:00
[sub_resource type="LabelSettings" id="LabelSettings_1bs00"]
font_size = 160
outline_size = 20
outline_color = Color(0, 0, 0, 1)
2025-02-23 00:46:23 +01:00
[sub_resource type="LabelSettings" id="LabelSettings_0jegv"]
font_size = 32
shadow_size = 2
shadow_color = Color(0, 0, 0, 1)
shadow_offset = Vector2(0, 0)
[sub_resource type="LabelSettings" id="LabelSettings_nbp4i"]
font_size = 24
shadow_size = 2
shadow_color = Color(0, 0, 0, 1)
shadow_offset = Vector2(0, 0)
[sub_resource type="LabelSettings" id="LabelSettings_5jdmh"]
font_size = 20
shadow_size = 2
shadow_color = Color(0, 0, 0, 1)
shadow_offset = Vector2(0, 0)
[sub_resource type="Animation" id="Animation_glb01"]
length = 0.001
2025-02-23 00:46:23 +01:00
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
2025-02-23 00:46:23 +01:00
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
2025-02-23 00:46:23 +01:00
"update": 0,
"values": [Color(1, 1, 1, 1)]
2025-02-23 00:46:23 +01:00
}
[sub_resource type="Animation" id="Animation_75r06"]
resource_name = "fadeout"
step = 0.5
2025-02-23 00:46:23 +01:00
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 2
2025-02-23 00:46:23 +01:00
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
2025-02-23 00:46:23 +01:00
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
2025-02-23 00:46:23 +01:00
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5cb2g"]
_data = {
2025-03-23 14:48:54 +01:00
&"RESET": SubResource("Animation_glb01"),
&"fadeout": SubResource("Animation_75r06")
2025-02-23 00:46:23 +01:00
}
2025-02-22 00:19:28 +01:00
[node name="Game" type="Node"]
2025-02-23 00:46:23 +01:00
script = SubResource("GDScript_8n212")
2025-02-23 14:27:35 +01:00
[node name="Informations" type="Control" parent="."]
2025-02-23 17:21:13 +01:00
visible = false
2025-02-23 14:27:35 +01:00
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
2025-02-23 17:21:13 +01:00
[node name="VictoryScreen" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VictoryScreen"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
text = "YOU WON!"
label_settings = SubResource("LabelSettings_1bs00")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Levels" type="Node" parent="."]
[node name="Demo" parent="Levels" instance=ExtResource("1_08svf")]
[node name="Timer" type="Timer" parent="."]
wait_time = 0.1
2025-02-23 00:46:23 +01:00
[node name="StartMenu" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ColorRect" type="ColorRect" parent="StartMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
2025-02-23 17:21:13 +01:00
color = Color(0.522749, 0.477374, 0.510111, 0.501961)
2025-02-23 00:46:23 +01:00
[node name="VBoxContainer" type="VBoxContainer" parent="StartMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Presentation" type="MarginContainer" parent="StartMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="VBoxContainer" type="VBoxContainer" parent="StartMenu/VBoxContainer/Presentation"]
layout_mode = 2
[node name="Title" type="Label" parent="StartMenu/VBoxContainer/Presentation/VBoxContainer"]
layout_mode = 2
text = "DreamBall"
label_settings = SubResource("LabelSettings_0jegv")
horizontal_alignment = 1
[node name="Title2" type="Label" parent="StartMenu/VBoxContainer/Presentation/VBoxContainer"]
layout_mode = 2
text = "A game about changing gravity to make a ball fly through the air"
label_settings = SubResource("LabelSettings_nbp4i")
horizontal_alignment = 1
[node name="MarginContainer" type="MarginContainer" parent="StartMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="HBoxContainer" type="HBoxContainer" parent="StartMenu/VBoxContainer/MarginContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="Rules" type="VBoxContainer" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
[node name="Label" type="Label" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Rules"]
layout_mode = 2
text = "- Change the direction of the gravity with the ARROW KEYS"
[node name="Label2" type="Label" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Rules"]
layout_mode = 2
text = "- Keep LEFT SHIFT pressed to make the gravity stronger"
[node name="Label3" type="Label" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Rules"]
layout_mode = 2
text = "- Press ESCAPE to pause and unpause the game at any point"
[node name="Label4" type="Label" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Rules"]
layout_mode = 2
text = "- Press R to restart the current level from the beginning
(note that it won't reset the timer!)"
[node name="Buttons" type="VBoxContainer" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
[node name="Label5" type="Label" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons"]
layout_mode = 2
text = "Do your best to make the ball go through all the rings!"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons"]
layout_mode = 2
theme_override_constants/separation = 20
alignment = 1
[node name="Btn_Fullscreen" type="Button" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
action_mode = 0
text = "Toggle FULLSCREEN"
[node name="Btn_Start" type="Button" parent="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
text = "START the game!"
2025-02-23 16:18:14 +01:00
[node name="MarginContainer2" type="MarginContainer" parent="StartMenu/VBoxContainer"]
2025-02-23 00:46:23 +01:00
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
2025-02-23 16:18:14 +01:00
[node name="Notice" type="Label" parent="StartMenu/VBoxContainer/MarginContainer2"]
2025-02-23 00:46:23 +01:00
layout_mode = 2
text = "Made during the 21st edition of Alakajam!"
label_settings = SubResource("LabelSettings_5jdmh")
horizontal_alignment = 1
[node name="AnimationPlayer" type="AnimationPlayer" parent="StartMenu"]
libraries = {
2025-03-23 14:48:54 +01:00
&"": SubResource("AnimationLibrary_5cb2g")
2025-02-23 00:46:23 +01:00
}
2025-02-23 16:18:14 +01:00
[node name="PauseMenu" type="Control" parent="."]
visible = false
z_index = 2
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
2025-02-23 17:21:13 +01:00
[node name="ColorRect" type="ColorRect" parent="PauseMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(1, 0.54902, 1, 0.109804)
2025-02-23 16:18:14 +01:00
[node name="VBoxContainer" type="VBoxContainer" parent="PauseMenu"]
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = -50.5
offset_bottom = 50.5
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 10
[node name="Btn_Resume" type="Button" parent="PauseMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 6
text = "RESUME game"
[node name="Btn_Fullscreen2" type="Button" parent="PauseMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 6
text = "Toggle FULLSCREEN"
[node name="Btn_Restart" type="Button" parent="PauseMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 6
text = "RESTART the level"
[node name="Btn_Quit" type="Button" parent="PauseMenu/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 6
text = "QUIT game"
2025-02-23 17:21:13 +01:00
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
2025-02-23 00:46:23 +01:00
[connection signal="pressed" from="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons/HBoxContainer/Btn_Fullscreen" to="." method="_on_btn_fullscreen_pressed"]
[connection signal="pressed" from="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons/HBoxContainer/Btn_Start" to="." method="_on_btn_start_pressed"]
[connection signal="animation_finished" from="StartMenu/AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
2025-02-23 16:18:14 +01:00
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Resume" to="." method="_on_btn_resume_pressed"]
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Fullscreen2" to="." method="_on_btn_fullscreen_2_pressed"]
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Restart" to="." method="_on_btn_restart_pressed"]
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Quit" to="." method="_on_btn_quit_pressed"]