add game scene

This commit is contained in:
2025-08-03 23:22:26 +04:00
parent d9084606c8
commit 78a61fe33c
5 changed files with 50 additions and 2 deletions

12
scenes/game.gd Normal file
View File

@@ -0,0 +1,12 @@
extends Node
@onready var back_button: Button = $BackButtonContainer/BackButton
func _ready() -> void:
if not back_button.pressed.is_connected(_on_back_button_pressed):
back_button.pressed.connect(_on_back_button_pressed)
func _on_back_button_pressed() -> void:
AudioManager.play_ui_click()
GameManager.save_game()
GameManager.exit_to_main_menu()

1
scenes/game.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bvtr6yhlyuv4v

17
scenes/game.tscn Normal file
View File

@@ -0,0 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://dmwkyeq2l7u04"]
[ext_resource type="Script" uid="uid://bvtr6yhlyuv4v" path="res://scenes/game.gd" id="1_uwrxv"]
[node name="Game" type="Node"]
script = ExtResource("1_uwrxv")
[node name="BackButtonContainer" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="BackButton" type="Button" parent="BackButtonContainer"]
offset_right = 45.0
offset_bottom = 31.0
text = "back"

View File

@@ -1,4 +1,21 @@
extends Node
func _ready():
pass
const GAME_SCENE_PATH := "res://scenes/Game.tscn"
const MAIN_SCENE_PATH := "res://scenes/Main.tscn"
func start_new_game() -> void:
var packed_scene := load(GAME_SCENE_PATH)
if not packed_scene or not packed_scene is PackedScene:
push_error("Failed to load Game scene at: %s" % GAME_SCENE_PATH)
return
get_tree().change_scene_to_packed(packed_scene)
func save_game() -> void:
print("Game saved (mock)")
func exit_to_main_menu() -> void:
var packed_scene := load(MAIN_SCENE_PATH)
if not packed_scene or not packed_scene is PackedScene:
push_error("Failed to load Main scene at: %s" % MAIN_SCENE_PATH)
return
get_tree().change_scene_to_packed(packed_scene)

View File

@@ -8,6 +8,7 @@ func _ready():
func _on_new_game_button_pressed():
AudioManager.play_ui_click()
print("New Game pressed")
GameManager.start_new_game()
func _on_settings_button_pressed():
AudioManager.play_ui_click()