diff --git a/game/game.gd b/game/game.gd new file mode 100644 index 0000000..e2e8253 --- /dev/null +++ b/game/game.gd @@ -0,0 +1,9 @@ +extends Node2D +class_name Game + + +@onready var button_spawner = $ButtonSpawner + + +func trigger_spawn(): + button_spawner.spawn() diff --git a/game/game.tscn b/game/game.tscn index 7d567d1..e5a29fd 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=5 format=3 uid="uid://c3rxmcwa5nqng"] +[gd_scene load_steps=6 format=3 uid="uid://c3rxmcwa5nqng"] +[ext_resource type="Script" path="res://game/game.gd" id="1_i3ly0"] [ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_y7o2l"] [ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_h2pfr"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_qwsty"] @@ -7,6 +8,7 @@ [node name="Game" type="Node2D"] texture_filter = 1 +script = ExtResource("1_i3ly0") [node name="Bottle" parent="." instance=ExtResource("1_y7o2l")] @@ -22,8 +24,6 @@ overlapping_bodies_collision_mask = 4 overlapping_body_count_limit = 4 [node name="Timer" type="Timer" parent="TimeSpawner"] -wait_time = 0.03 -autostart = true [node name="ButtonSpawner" parent="." instance=ExtResource("3_qwsty")] position = Vector2(0, -480) diff --git a/interface/game_container.tscn b/interface/game_container.tscn index ecbeb0b..fb1b98c 100644 --- a/interface/game_container.tscn +++ b/interface/game_container.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=2 format=3 uid="uid://mfa1v4fsnupp"] +[gd_scene load_steps=2 format=3 uid="uid://c0uce7ssweke"] [ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="1_dbqdv"] diff --git a/root.gd b/root.gd index d48e6e9..9256a51 100644 --- a/root.gd +++ b/root.gd @@ -3,6 +3,7 @@ class_name Root @onready var tree: SceneTree = get_tree() +@onready var game: Game = $UI/GameContainer/Game @onready var game_ui: GameUI = $UI/GameUI @onready var shop_ui: ShopUI = $UI/ShopUI @@ -46,4 +47,4 @@ func _on_game_ui_shop_button_pressed(): ui_state = UIState.SHOP func _on_game_ui_spawn_button_pressed(): - pass # Replace with function body. + game.trigger_spawn() diff --git a/root.tscn b/root.tscn index e2b50af..139e6aa 100644 --- a/root.tscn +++ b/root.tscn @@ -2,12 +2,13 @@ [ext_resource type="Script" path="res://root.gd" id="1_8jrhk"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_h26ax"] -[ext_resource type="PackedScene" uid="uid://mfa1v4fsnupp" path="res://interface/game_container.tscn" id="1_xjgvu"] +[ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="3_hrdyr"] [ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="3_lvefk"] [ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="5_2cc15"] [node name="Root" type="Node"] script = ExtResource("1_8jrhk") +ui_state = null [node name="UI" type="Control" parent="."] texture_filter = 1 @@ -20,9 +21,18 @@ grow_vertical = 2 size_flags_vertical = 8 theme = ExtResource("1_h26ax") -[node name="GameContainer" parent="UI" instance=ExtResource("1_xjgvu")] +[node name="GameContainer" type="Control" parent="UI"] process_mode = 1 layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="Game" parent="UI/GameContainer" instance=ExtResource("3_hrdyr")] [node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")] process_mode = 3