diff --git a/base/Base.gd b/base/Base.gd new file mode 100644 index 0000000..ee462bf --- /dev/null +++ b/base/Base.gd @@ -0,0 +1,26 @@ +extends Node + + +var current_scn: Node = null +func change_scene(path: String): + var res: Resource = load(path) + var scn: Node = res.instantiate() + add_child(scn) + if current_scn: + current_scn.queue_free() + current_scn = scn + + +func start_game(): + print("Starting game...") + change_scene("res://island/Island.tscn") + + +func goto_menu(): + print("Going to the menu...") + change_scene("res://menu/Menu.tscn") + current_scn.connect("play_pressed", start_game) + + +func _ready(): + goto_menu() diff --git a/base/Base.tscn b/base/Base.tscn new file mode 100644 index 0000000..c4dea27 --- /dev/null +++ b/base/Base.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://vtsmwim5ayl8"] + +[ext_resource type="Script" path="res://base/Base.gd" id="1_fhviw"] + +[node name="Base" type="Node"] +script = ExtResource("1_fhviw") diff --git a/menu/Menu.gd b/menu/Menu.gd new file mode 100644 index 0000000..bfa9b0d --- /dev/null +++ b/menu/Menu.gd @@ -0,0 +1,9 @@ +extends Control + + +signal play_pressed() + + +func play(): + print("Play button was pressed.") + emit_signal("play_pressed") diff --git a/menu/Menu.tscn b/menu/Menu.tscn index c1c7841..cdccce4 100644 --- a/menu/Menu.tscn +++ b/menu/Menu.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://bufi0wh54u5x5"] +[gd_scene load_steps=4 format=3 uid="uid://bufi0wh54u5x5"] [ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_mkxnc"] +[ext_resource type="Script" path="res://menu/Menu.gd" id="2_6amk3"] [ext_resource type="Texture2D" uid="uid://bxyximtgui1ux" path="res://assets/grass_menu_tile.png" id="2_q14jx"] [node name="Menu" type="Control"] @@ -13,6 +14,7 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_vertical = 3 theme = ExtResource("1_mkxnc") +script = ExtResource("2_6amk3") [node name="Panel" type="TextureRect" parent="."] layout_mode = 1 @@ -72,3 +74,5 @@ layout_mode = 2 size_flags_vertical = 1 text = "Ludum Dare 52 - Harvest" horizontal_alignment = 1 + +[connection signal="pressed" from="Content/Control/Play" to="." method="play"] diff --git a/project.godot b/project.godot index b695500..360b925 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="LD52" -run/main_scene="res://menu/Menu.tscn" +run/main_scene="res://base/Base.tscn" config/features=PackedStringArray("4.0", "GL Compatibility") boot_splash/bg_color=Color(0.231373, 0.490196, 0.309804, 1) config/icon="res://assets/icon.svg"