[gd_scene load_steps=7 format=3 uid="uid://ccgnnif026wb4"] [ext_resource type="PackedScene" uid="uid://xd3nsiglcdfc" path="res://gui/timer.tscn" id="1_356j3"] [ext_resource type="PackedScene" uid="uid://cckeamgkt8bqo" path="res://gui/speed.tscn" id="2_2gn6w"] [ext_resource type="PackedScene" uid="uid://cn55m5dqo3m6u" path="res://gui/rings.tscn" id="3_mbj17"] [ext_resource type="PackedScene" uid="uid://dkxtwpcy4moyo" path="res://menus/pause_menu.tscn" id="4_3bfj3"] [sub_resource type="GDScript" id="GDScript_8n212"] script/source = "extends Node var playing: bool = false var changing_level: bool = false var main_menu: Node var current_level: Level const res_main_menu = preload(\"res://menus/main/main_menu.tscn\") @onready var gui_timer := $GUI/TopLeft/Timer @onready var gui_speed := $GUI/TopRight/Speed @onready var gui_rings := $GUI/BottomRight/Rings @onready var pause_menu := $PauseMenu func _ready() -> void: ## Add the version of the game and the name of the OS to the footer of the start menu if OS.has_feature(\"editor\"): $DevInfos.text = \"dev \" $DevInfos.text += \"build \" + ProjectSettings.get_setting(\"application/config/version\") + \" (\" + OS.get_name() + \")\" ## Hide UI stuff that shouldn't be visible until later in the game $VictoryScreen.hide() $GUI.hide() pause_menu.hide() ## Connect to necessary signals pause_menu.connect(\"request_pause\", pause_game) pause_menu.connect(\"request_fullscreen\", fullscreen_game) pause_menu.connect(\"request_restart\", restart_level) set_main_menu() func set_main_menu(): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) main_menu = res_main_menu.instantiate() main_menu.connect(\"request_play_level\", start_level) add_child(main_menu) func start_level(level_scene: PackedScene) -> void: if is_instance_valid(current_level): current_level.queue_free() if is_instance_valid(main_menu): main_menu.queue_free() current_level = level_scene.instantiate() add_child(current_level) current_level.connect(\"completed\", finish_current_level) current_level.connect(\"ring_collected\", func(): gui_rings.remaining_rings = len(current_level.rings) - current_level.finished_rings_count ) gui_rings.remaining_rings = len(current_level.rings) - current_level.finished_rings_count $GUI.show() Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) playing = true PhysicsServer3D.area_set_param( get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR, Vector3.DOWN ) changing_level = false gui_timer.seconds_spent_level_attempt = 0.0 gui_timer.enabled = true func finish_current_level() -> void: gui_timer.enabled = false PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, 1) playing = false changing_level = true SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file) var save_file_data = SaveFiles.read(SaveFiles.selected_file) var property_name := current_level.id + \"_best_time\" if !save_file_data.has(property_name) or save_file_data[property_name] is not float or save_file_data[property_name] > gui_timer.seconds_spent_level_attempt: SaveFiles.change_property(property_name, gui_timer.seconds_spent_level_attempt, SaveFiles.selected_file) current_level.music.fadeOut(2) await get_tree().create_timer(2).timeout current_level.queue_free() win_game() func win_game() -> void: $VictoryScreen.show() await get_tree().create_timer(2).timeout set_main_menu() $VictoryScreen.hide() func restart_level() -> void: return #idk yet func pause_game(to_pause: bool) -> void: if is_instance_valid(current_level) or changing_level: return SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file) if to_pause: $Levels.process_mode = Node.PROCESS_MODE_DISABLED playing = false pause_menu.show() Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) else: $Levels.process_mode = Node.PROCESS_MODE_INHERIT playing = true pause_menu.hide() Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) func fullscreen_game() -> void: 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) func _process(_delta: float) -> void: if is_instance_valid(current_level): gui_speed.ball_velocity = current_level.velocity func _input(_event: InputEvent) -> void: if Input.is_action_just_pressed(\"restart_level\"): restart_level() func _on_btn_quit_pressed() -> void: get_tree().quit() " [sub_resource type="LabelSettings" id="LabelSettings_1bs00"] font_size = 160 outline_size = 20 outline_color = Color(0, 0, 0, 1) [node name="Game" type="Node"] script = SubResource("GDScript_8n212") [node name="GUI" 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="TopLeft" type="MarginContainer" parent="GUI"] layout_mode = 1 offset_right = 160.0 offset_bottom = 85.0 rotation = 0.0523599 theme_override_constants/margin_left = 15 [node name="Timer" parent="GUI/TopLeft" instance=ExtResource("1_356j3")] layout_mode = 2 [node name="TopRight" type="MarginContainer" parent="GUI"] layout_mode = 1 anchors_preset = 1 anchor_left = 1.0 anchor_right = 1.0 offset_left = -106.0 offset_bottom = 51.0 grow_horizontal = 0 rotation = -0.0523599 theme_override_constants/margin_top = 5 theme_override_constants/margin_right = 15 [node name="Speed" parent="GUI/TopRight" instance=ExtResource("2_2gn6w")] layout_mode = 2 [node name="BottomRight" type="MarginContainer" parent="GUI"] layout_mode = 1 anchors_preset = 3 anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 offset_left = -222.0 offset_top = -51.0 grow_horizontal = 0 grow_vertical = 0 rotation = 0.0523599 theme_override_constants/margin_right = 15 theme_override_constants/margin_bottom = 15 [node name="Rings" parent="GUI/BottomRight" instance=ExtResource("3_mbj17")] layout_mode = 2 [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="PauseMenu" parent="." instance=ExtResource("4_3bfj3")] [node name="DevInfos" type="Label" parent="."] anchors_preset = 12 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 offset_top = -23.0 grow_horizontal = 2 grow_vertical = 0 horizontal_alignment = 1