From b713c3acb9482c49c1fdc015ed0975a0dc47e2d7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 23:56:25 +0200 Subject: [PATCH] WIP stuff just for merge --- bottle/bottle.tscn | 7 ------- game/game.tscn | 15 +++++++-------- root.gd | 4 ---- root.tscn | 2 +- spawner/spawner.gd | 5 +++-- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/bottle/bottle.tscn b/bottle/bottle.tscn index 0589b47..b17133b 100644 --- a/bottle/bottle.tscn +++ b/bottle/bottle.tscn @@ -16,10 +16,3 @@ tile_set = SubResource("TileSet_tr7be") collision_visibility_mode = 1 format = 2 layer_0/tile_data = PackedInt32Array(-1376264, 0, 0, -1310728, 0, 0, -1245192, 0, 0, -393224, 0, 0, -327688, 0, 0, -262152, 0, 0, -458760, 0, 0, -524296, 0, 0, -589832, 0, 0, -655368, 0, 0, -720904, 0, 0, -786440, 0, 0, -851976, 0, 0, -917512, 0, 0, -983048, 0, 0, -1048584, 0, 0, -1114120, 0, 0, -1179656, 0, 0, -196616, 0, 0, -131080, 0, 0, -65544, 0, 0, -8, 0, 0, -7, 0, 0, -4, 0, 0, -3, 0, 0, -2, 0, 0, -1, 0, 0, -5, 0, 0, -6, 0, 0, -65536, 0, 0, -65535, 0, 0, -65534, 0, 0, -65533, 0, 0, -65532, 0, 0, -65531, 0, 0, -65530, 0, 0, -65529, 0, 0, -131065, 0, 0, -196601, 0, 0, -262137, 0, 0, -327673, 0, 0, -393209, 0, 0, -458745, 0, 0, -524281, 0, 0, -589817, 0, 0, -655353, 0, 0, -720889, 0, 0, -786425, 0, 0, -851961, 0, 0, -917497, 0, 0, -983033, 0, 0, -1048569, 0, 0, -1114105, 0, 0, -1441785, 0, 0, -1376249, 0, 0, -1310713, 0, 0, -1245177, 0, 0, -1179641, 0, 0, -1638404, 0, 0, -1703933, 0, 0, -1572868, 0, 0, -1507332, 0, 0, -1441796, 0, 0, -1376260, 0, 0, -1376261, 0, 0, -1376262, 0, 0, -1376263, 0, 0, -1638397, 0, 0, -1572861, 0, 0, -1507325, 0, 0, -1441789, 0, 0, -1441788, 0, 0, -1441787, 0, 0, -1441786, 0, 0) - -[node name="StaticBody2D" type="StaticBody2D" parent="."] -collision_layer = 3 -collision_mask = 0 - -[node name="Poly" type="CollisionPolygon2D" parent="StaticBody2D"] -polygon = PackedVector2Array(-320, -576, -320, 192, 320, 192, 320, -576, 48, -576, 48, -336, 112, -336, 112, -16, -112, -16, -112, -336, -48, -336, -48, -576) diff --git a/game/game.tscn b/game/game.tscn index 81f9092..98bb783 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=7 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"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="4_e5nwi"] -[ext_resource type="PackedScene" uid="uid://ratkps4plkhl" path="res://convertors/copper_to_silver.tscn" id="6_tf2pv"] [node name="Game" type="Node2D"] texture_filter = 1 @@ -16,13 +15,10 @@ position = Vector2(0, 240) [node name="GravityFromGyro" parent="Bottle" instance=ExtResource("2_h2pfr")] -[node name="CopperToSilver" parent="." instance=ExtResource("6_tf2pv")] -z_index = 10 -position = Vector2(2, -314) - -[node name="TimeSpawner" parent="." instance=ExtResource("3_qwsty")] +[node name="TimeSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(0, -144) scene = ExtResource("4_e5nwi") +target = NodePath("..") buffer_cap = 1 spawn_position_range_x = 32.0 spawn_rotation_range = 15.0 @@ -30,10 +26,13 @@ overlapping_bodies_collision_mask = 4 overlapping_body_count_limit = 4 [node name="Timer" type="Timer" parent="TimeSpawner"] +wait_time = 0.017 +autostart = true -[node name="ButtonSpawner" parent="." instance=ExtResource("3_qwsty")] +[node name="ButtonSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(0, -144) scene = ExtResource("4_e5nwi") +target = NodePath("..") buffer_cap = 50 spawn_position_range_x = 32.0 spawn_rotation_range = 15.0 diff --git a/root.gd b/root.gd index 9ba5ed7..4cf1b2e 100644 --- a/root.gd +++ b/root.gd @@ -3,7 +3,6 @@ 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,8 +45,5 @@ func _on_shop_ui_score_button_pressed(): func _on_game_ui_shop_button_pressed(): ui_state = UIState.SHOP -func _on_game_ui_spawn_button_pressed(): - game.trigger_spawn() - func _on_shop_ui_purchase_begin(_what): ui_state = UIState.GAME diff --git a/root.tscn b/root.tscn index 8712d88..5633eb1 100644 --- a/root.tscn +++ b/root.tscn @@ -60,7 +60,7 @@ layout_mode = 2 [connection signal="score_button_pressed" from="View/SafeUI/GameUI" to="." method="_on_game_ui_score_button_pressed"] [connection signal="shop_button_pressed" from="View/SafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] -[connection signal="spawn_button_pressed" from="View/SafeUI/GameUI" to="." method="_on_game_ui_spawn_button_pressed"] +[connection signal="spawn_button_pressed" from="View/SafeUI/GameUI" to="View/GameWI/GameWorld/Game" method="trigger_spawn"] [connection signal="back_button_pressed" from="View/SafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] [connection signal="delete_button_pressed" from="View/SafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] [connection signal="purchase_begin" from="View/SafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index ca416ce..25f02f5 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -3,6 +3,7 @@ class_name Spawner @export var scene: PackedScene +@export var target: Node var buffer: int = 0 @export var buffer_cap: int @@ -43,9 +44,9 @@ func _do_spawn(): if _count_overlapping_bodies() > overlapping_body_count_limit: return var scene_instant = scene.instantiate() - scene_instant.position = _select_spawn_position() + scene_instant.global_position = global_position + _select_spawn_position() scene_instant.rotation_degrees = _select_spawn_rotation() - add_child(scene_instant) + target.add_child(scene_instant) emit_signal("spawned", scene_instant) buffer -= 1