implement the new main menu into the actual game
This commit is contained in:
parent
a73b32610e
commit
8f18e43af7
6 changed files with 96 additions and 226 deletions
234
index.tscn
234
index.tscn
|
@ -1,6 +1,4 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://ccgnnif026wb4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dtfybhftwfn00" path="res://levels/demo.tscn" id="1_356j3"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ccgnnif026wb4"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_8n212"]
|
||||
script/source = "extends Node
|
||||
|
@ -15,6 +13,7 @@ var levels = [
|
|||
preload(\"res://levels/forest/level.tscn\"),
|
||||
preload(\"res://levels/night/level.tscn\"),
|
||||
]
|
||||
var area_resource = preload(\"res://menus/main/area.tscn\")
|
||||
|
||||
func _ready() -> void:
|
||||
var os_name = OS.get_name()
|
||||
|
@ -26,19 +25,25 @@ func _ready() -> void:
|
|||
$PauseMenu.hide()
|
||||
## Add the version of the game and the name of the OS to the footer of the start menu
|
||||
if OS.has_feature(\"editor\"):
|
||||
$StartMenu/VBoxContainer/MarginContainer2/Notice.text = \"dev \"
|
||||
$StartMenu/VBoxContainer/MarginContainer2/Notice.text += \"build \" + ProjectSettings.get_setting(\"application/config/version\") + \" (\" + os_name + \")\"
|
||||
$DevInfos.text = \"dev \"
|
||||
$DevInfos.text += \"build \" + ProjectSettings.get_setting(\"application/config/version\") + \" (\" + os_name + \")\"
|
||||
launch_area()
|
||||
|
||||
func launch_area():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
var area := area_resource.instantiate()
|
||||
area.connect(\"request_start\", start_game)
|
||||
$Levels.add_child(area)
|
||||
|
||||
## Get all the levels that are currently being played!
|
||||
## In theory, there should ever be only zero or one,
|
||||
## but it turns out it's more simple to handle things by using Arrays.
|
||||
func get_current_levels() -> Array[Level]:
|
||||
var children = $Levels.get_children(true)
|
||||
var children := $Levels.get_children(true)
|
||||
var current_levels: Array[Level] = []
|
||||
for child in children:
|
||||
if is_instance_of(child, Level):
|
||||
current_levels.push_back(child)
|
||||
|
||||
return current_levels
|
||||
|
||||
func start_level(level_scene: PackedScene) -> void:
|
||||
|
@ -74,10 +79,8 @@ func stop_level() -> void:
|
|||
func win_game() -> void:
|
||||
$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)
|
||||
launch_area()
|
||||
$VictoryScreen.hide()
|
||||
|
||||
func restart_level() -> void:
|
||||
if changing_level == false:
|
||||
|
@ -110,25 +113,18 @@ func fullscreen_game() -> void:
|
|||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WindowMode.WINDOW_MODE_WINDOWED)
|
||||
|
||||
func _on_btn_start_pressed() -> void:
|
||||
func start_game() -> void:
|
||||
seconds_spent = 0.0
|
||||
current_level_int = 0
|
||||
|
||||
var current_levels = get_current_levels()
|
||||
var current_levels = $Levels.get_children(true)
|
||||
for level in current_levels:
|
||||
level.queue_free()
|
||||
|
||||
$Informations.show()
|
||||
$StartMenu/AnimationPlayer.play(\"fadeout\")
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
start_level(levels[0])
|
||||
|
||||
func _on_animation_player_animation_finished(_anim_name: StringName) -> void:
|
||||
if $StartMenu.modulate == Color(1,1,1,1):
|
||||
$StartMenu.show()
|
||||
else:
|
||||
$StartMenu.hide()
|
||||
|
||||
func update_timer(delta: float) -> void:
|
||||
if playing:
|
||||
seconds_spent += delta
|
||||
|
@ -145,7 +141,8 @@ func _process(delta: float) -> void:
|
|||
|
||||
func _unhandled_key_input(event: InputEvent) -> void:
|
||||
if event.is_pressed() and event is InputEventKey:
|
||||
if $StartMenu.visible == false and changing_level == false:
|
||||
var current_levels := get_current_levels()
|
||||
if len(current_levels) and changing_level == false:
|
||||
if event.keycode == KEY_ESCAPE:
|
||||
pause_game()
|
||||
elif event.keycode == KEY_R:
|
||||
|
@ -166,61 +163,6 @@ font_size = 160
|
|||
outline_size = 20
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[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
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_75r06"]
|
||||
resource_name = "fadeout"
|
||||
step = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5cb2g"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_glb01"),
|
||||
&"fadeout": SubResource("Animation_75r06")
|
||||
}
|
||||
|
||||
[node name="Game" type="Node"]
|
||||
script = SubResource("GDScript_8n212")
|
||||
|
||||
|
@ -293,133 +235,6 @@ vertical_alignment = 1
|
|||
|
||||
[node name="Levels" type="Node" parent="."]
|
||||
|
||||
[node name="Demo" parent="Levels" instance=ExtResource("1_356j3")]
|
||||
|
||||
[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
|
||||
color = Color(0.522749, 0.477374, 0.510111, 0.501961)
|
||||
|
||||
[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!"
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="StartMenu/VBoxContainer"]
|
||||
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
|
||||
|
||||
[node name="Notice" type="Label" parent="StartMenu/VBoxContainer/MarginContainer2"]
|
||||
layout_mode = 2
|
||||
label_settings = SubResource("LabelSettings_5jdmh")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="StartMenu"]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_5cb2g")
|
||||
}
|
||||
|
||||
[node name="PauseMenu" type="Control" parent="."]
|
||||
visible = false
|
||||
z_index = 2
|
||||
|
@ -472,9 +287,16 @@ layout_mode = 2
|
|||
size_flags_vertical = 6
|
||||
text = "QUIT game"
|
||||
|
||||
[connection signal="pressed" from="StartMenu/VBoxContainer/MarginContainer/HBoxContainer/Buttons/HBoxContainer/Btn_Fullscreen" to="." method="fullscreen_game"]
|
||||
[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"]
|
||||
[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
|
||||
|
||||
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Resume" to="." method="pause_game"]
|
||||
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Fullscreen2" to="." method="fullscreen_game"]
|
||||
[connection signal="pressed" from="PauseMenu/VBoxContainer/Btn_Restart" to="." method="restart_level"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue