Add build directory to .gitignore, create export presets for Web and Windows Desktop, adjust z-index and mouse filter in level_1.tscn, add update_game_state function in level.gd, change main_scene path in project.godot, set rendering method to "gl_compatibility", add LevelSelect and related nodes in main_menu.tscn, create scene_manager.tscn with MainMenu node, implement functionality for menu button selection in main_menu.gd.
This commit is contained in:
parent
ca4788ce6f
commit
b6cdb68b4e
21 changed files with 499 additions and 10 deletions
|
|
@ -18,6 +18,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=20 format=3 uid="uid://cdk8rrve1fe3u"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://cdk8rrve1fe3u"]
|
||||
|
||||
[ext_resource type="Script" path="res://levels/scripts/level.gd" id="1_inuhq"]
|
||||
[ext_resource type="Script" path="res://scenes/scripts/main_menu.gd" id="1_ges7y"]
|
||||
[ext_resource type="Resource" uid="uid://bn4qhonifxne3" path="res://levels/rules/main_menu.tres" id="2_4iepj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn6aa6f2f4g4i" path="res://components/RulesComponent.tscn" id="2_hanec"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1uawawum16b0" path="res://scenes/elements/background.tscn" id="4_nllu8"]
|
||||
|
|
@ -19,9 +19,10 @@
|
|||
[ext_resource type="AudioStream" uid="uid://bgcbd6xf0lyrr" path="res://resources/music/bee_background.ogg" id="15_ixwoe"]
|
||||
[ext_resource type="AudioStream" uid="uid://dvsjpsh5dyixq" path="res://resources/SFX/mixkit-european-spring-forest-ambience-1219.wav" id="16_cqdjb"]
|
||||
[ext_resource type="Texture2D" uid="uid://15wckxixnr8y" path="res://resources/images/logo.png" id="19_jw5rd"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3tl5pihlrd8u" path="res://resources/cursors/navigation_s.png" id="20_fw4ew"]
|
||||
|
||||
[node name="MainMenu" type="Node2D"]
|
||||
script = ExtResource("1_inuhq")
|
||||
script = ExtResource("1_ges7y")
|
||||
|
||||
[node name="RulesComponent" parent="." instance=ExtResource("2_hanec")]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -182,4 +183,61 @@ autoplay = true
|
|||
position = Vector2(640, 167)
|
||||
texture = ExtResource("19_jw5rd")
|
||||
|
||||
[node name="LevelSelect" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 1280.0
|
||||
offset_bottom = 720.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="LevelSelect"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="LevelSelect/CenterContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_top = 100
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="LevelSelect/CenterContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MenuButton" type="MenuButton" parent="LevelSelect/CenterContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "Level Select"
|
||||
icon = ExtResource("20_fw4ew")
|
||||
flat = false
|
||||
icon_alignment = 2
|
||||
item_count = 6
|
||||
popup/item_0/text = "Level One"
|
||||
popup/item_0/id = 1
|
||||
popup/item_1/text = "Level Two"
|
||||
popup/item_1/id = 2
|
||||
popup/item_2/text = "Level Three"
|
||||
popup/item_2/id = 3
|
||||
popup/item_3/text = "Level Four"
|
||||
popup/item_3/id = 4
|
||||
popup/item_4/text = "Level Five"
|
||||
popup/item_4/id = 5
|
||||
popup/item_5/text = "Level Six"
|
||||
popup/item_5/id = 6
|
||||
|
||||
[node name="HighScores" type="Button" parent="LevelSelect/CenterContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "High Scores"
|
||||
|
||||
[node name="ExitGame" type="Button" parent="LevelSelect/CenterContainer/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Quit Game"
|
||||
|
||||
[editable path="DroneManager"]
|
||||
|
|
|
|||
14
scenes/scene_manager.tscn
Normal file
14
scenes/scene_manager.tscn
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cbsqd08rb8f83"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cdk8rrve1fe3u" path="res://scenes/main_menu.tscn" id="1_phmcp"]
|
||||
[ext_resource type="Script" path="res://scenes/scripts/scene_manager.gd" id="1_py1pt"]
|
||||
[ext_resource type="PackedScene" uid="uid://bhy041v5u551a" path="res://scenes/transition_scene.tscn" id="2_jhpbi"]
|
||||
|
||||
[node name="SceneManager" type="Node2D"]
|
||||
script = ExtResource("1_py1pt")
|
||||
|
||||
[node name="CurrentScene" type="Node" parent="."]
|
||||
|
||||
[node name="MainMenu" parent="CurrentScene" instance=ExtResource("1_phmcp")]
|
||||
|
||||
[node name="TransitionScene" parent="." instance=ExtResource("2_jhpbi")]
|
||||
38
scenes/scripts/main_menu.gd
Normal file
38
scenes/scripts/main_menu.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
extends Level
|
||||
class_name MainMenu
|
||||
|
||||
@onready var level_select = get_node("%MenuButton")
|
||||
@onready var high_scores = get_node("%HighScores")
|
||||
@onready var exit_button = get_node("%ExitGame")
|
||||
|
||||
func _ready():
|
||||
level_select.get_popup().id_pressed.connect(_on_item_menu_pressed)
|
||||
high_scores.connect("pressed", Callable(self, "on_high_scores_pressed"))
|
||||
exit_button.connect("pressed", Callable(self, "on_exit_pressed"))
|
||||
update_game_state()
|
||||
|
||||
|
||||
func _on_item_menu_pressed(id):
|
||||
## Load the appropriate level based on the selection that has been made
|
||||
Log.pr(id)
|
||||
|
||||
match id:
|
||||
1:
|
||||
# Load level 1
|
||||
SceneMgr.load_scene("LEVEL1")
|
||||
#get_tree().change_scene_to_file("res://levels/level_1.tscn")
|
||||
2:
|
||||
# Load level 2
|
||||
SceneMgr.load_scene("LEVEL2")
|
||||
3:
|
||||
# Load level 3
|
||||
SceneMgr.load_scene("LEVEL3")
|
||||
|
||||
func on_high_scores_pressed():
|
||||
## Load the high scores screen
|
||||
Log.pr("High scores button pressed")
|
||||
pass
|
||||
|
||||
func on_exit_pressed():
|
||||
# Quit the game
|
||||
get_tree().quit()
|
||||
33
scenes/scripts/scene_manager.gd
Normal file
33
scenes/scripts/scene_manager.gd
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
extends Node2D
|
||||
class_name SceneManager
|
||||
|
||||
const SCENES : Dictionary = {
|
||||
"MAINMENU" : "res://scenes/main_menu.tscn",
|
||||
"HIGHSCORES" : "res://scenes/highscores.tscn",
|
||||
"LEVEL1" : "res://levels/level_1.tscn",
|
||||
"LEVEL2" : "res://levels/level_2.tscn",
|
||||
"LEVEL3" : "res://levels/level_3.tscn",
|
||||
"LEVEL4" : "res://levels/level_4.tscn",
|
||||
"LEVEL5" : "res://levels/level_5.tscn",
|
||||
"LEVEL6" : "res://levels/level_6.tscn",
|
||||
}
|
||||
|
||||
var loading_scene_res : Resource = null
|
||||
|
||||
func _ready():
|
||||
Log.pr("SceneManager is ready.")
|
||||
SceneMgr.connect("change_scene", Callable(self, "_on_change_scene"))
|
||||
$TransitionScene.connect("transitioned", Callable(self, "_on_transition_scene_transitioned"))
|
||||
|
||||
func _on_change_scene(scene_name):
|
||||
Log.pr("Going to load a scene.", scene_name)
|
||||
if SCENES.has(scene_name):
|
||||
loading_scene_res = load(SCENES[scene_name])
|
||||
Log.pr("Loading scene: ", loading_scene_res)
|
||||
$TransitionScene.transition()
|
||||
else:
|
||||
loading_scene_res = null
|
||||
|
||||
func _on_transition_scene_transitioned():
|
||||
$CurrentScene.get_child(0).queue_free()
|
||||
$CurrentScene.add_child(loading_scene_res.instantiate())
|
||||
19
scenes/scripts/transition_scene.gd
Normal file
19
scenes/scripts/transition_scene.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends CanvasLayer
|
||||
|
||||
signal transitioned
|
||||
|
||||
func _ready():
|
||||
$AnimationPlayer.play("fade_to_normal")
|
||||
|
||||
func transition():
|
||||
$AnimationPlayer.play("fade_to_black")
|
||||
Log.pr("Fading to black")
|
||||
|
||||
func _on_animation_player_animation_finished(anim_name:StringName):
|
||||
if anim_name == "fade_to_black":
|
||||
Log.pr("Sending transitioned signal...")
|
||||
emit_signal("transitioned")
|
||||
$AnimationPlayer.play("fade_to_normal")
|
||||
if anim_name == "fade_to_normal":
|
||||
Log.pr("Faded to normal")
|
||||
|
||||
76
scenes/transition_scene.tscn
Normal file
76
scenes/transition_scene.tscn
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bhy041v5u551a"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/scripts/transition_scene.gd" id="1_pt42a"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ehfi2"]
|
||||
resource_name = "fade_to_black"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n8kpy"]
|
||||
resource_name = "fade_to_normal"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_skyqd"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0, 0, 0, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_lyb8n"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_skyqd"),
|
||||
"fade_to_black": SubResource("Animation_ehfi2"),
|
||||
"fade_to_normal": SubResource("Animation_n8kpy")
|
||||
}
|
||||
|
||||
[node name="TransitionScene" type="CanvasLayer"]
|
||||
script = ExtResource("1_pt42a")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_lyb8n")
|
||||
}
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue