diff --git a/main.gd b/main.gd index eec3aa8..c107106 100644 --- a/main.gd +++ b/main.gd @@ -61,7 +61,6 @@ func build_menu() -> void: scene_menu.selected_options.connect(_on_menu_selected_options) container.add_child(scene_menu) - ## Build the main menu. func build_game() -> void: scene_game = SCENE_GAME.instantiate() diff --git a/main.tscn b/main.tscn index 4f1fcf6..6e6b766 100644 --- a/main.tscn +++ b/main.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://b38wkla8e7rmo"] [ext_resource type="Script" path="res://main.gd" id="1_jyg3q"] -[ext_resource type="PackedScene" uid="uid://bkm7id1wdwywg" path="res://scenes/interface/safe_margin_container.tscn" id="2_ah6n8"] +[ext_resource type="PackedScene" uid="uid://bkm7id1wdwywg" path="res://scenes/menu/safe_margin_container.tscn" id="2_ah6n8"] [node name="Main" type="Node"] script = ExtResource("1_jyg3q") diff --git a/scenes/game/game.gd b/scenes/game/game.gd deleted file mode 100644 index 79dbeda..0000000 --- a/scenes/game/game.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends Node2D -class_name MainGame - -## Emitted when the player has clicked on the Options button. -signal selected_exit - - -func _on_exit_pressed() -> void: - selected_exit.emit() - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass diff --git a/scenes/game/game.tscn b/scenes/game/game.tscn deleted file mode 100644 index 5d1eda0..0000000 --- a/scenes/game/game.tscn +++ /dev/null @@ -1,26 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://cxj5aud02f40j"] - -[ext_resource type="Script" path="res://scenes/game/game.gd" id="1_tau5t"] -[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="2_8268g"] -[ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="3_48ps6"] - -[sub_resource type="TileSet" id="TileSet_g2dkm"] - -[node name="World" type="Node2D"] -script = ExtResource("1_tau5t") - -[node name="TileMap" type="TileMap" parent="."] -tile_set = SubResource("TileSet_g2dkm") -format = 2 - -[node name="Sheep" parent="." instance=ExtResource("2_8268g")] -position = Vector2(637, 318) -run_speed = 600 - -[node name="Gold" parent="." instance=ExtResource("3_48ps6")] - -[node name="Gold2" parent="." instance=ExtResource("3_48ps6")] -position = Vector2(368, 391) - -[node name="Gold3" parent="." instance=ExtResource("3_48ps6")] -position = Vector2(620, 464) diff --git a/scenes/game/menu_game.gd b/scenes/game/menu_game.gd new file mode 100644 index 0000000..2b0880e --- /dev/null +++ b/scenes/game/menu_game.gd @@ -0,0 +1,15 @@ +extends Node2D +class_name MainGame + + +## Get the first possible [MainGame] instance by climbing the scene tree one ancestor at a time. +static func get_ancestor(start: Node): + var current = start + while current is Node: + if current is MainGame: + return current + current = current.get_parent() + return null + + +@onready var gold_counter: Counter = $"GoldCounter" diff --git a/scenes/game/menu_game.tscn b/scenes/game/menu_game.tscn new file mode 100644 index 0000000..e231feb --- /dev/null +++ b/scenes/game/menu_game.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=3 uid="uid://cxj5aud02f40j"] + +[ext_resource type="Script" path="res://scenes/game/menu_game.gd" id="1_vrqkh"] +[ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="2_7flt7"] + +[sub_resource type="TileSet" id="TileSet_g2dkm"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_p1lg5"] +size = Vector2(1280, 720) + +[node name="MainGame" type="Node2D"] +script = ExtResource("1_vrqkh") + +[node name="TileMap" type="TileMap" parent="."] +tile_set = SubResource("TileSet_g2dkm") +format = 2 + +[node name="PlayArea" type="Area2D" parent="."] + +[node name="Shape" type="CollisionShape2D" parent="PlayArea"] +shape = SubResource("RectangleShape2D_p1lg5") +debug_color = Color(1, 1, 1, 0) + +[node name="Camera" type="Camera2D" parent="."] +editor_draw_screen = false + +[node name="GoldCounter" parent="." instance=ExtResource("2_7flt7")]