From c9d93048b54be9ea431a83967955e1066964abfe Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Mon, 2 Oct 2023 00:18:57 +0200 Subject: [PATCH] converter kinda works --- bottle/bottle.tscn | 4 +-- convertors/converter_working.gd | 11 ++++++ convertors/copper_to_silver.gd | 13 +++++-- convertors/copper_to_silver.tscn | 31 +++++++++-------- game/game.tscn | 7 ++-- root.tscn | 58 ++++++++++++-------------------- 6 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 convertors/converter_working.gd diff --git a/bottle/bottle.tscn b/bottle/bottle.tscn index 0589b47..83d5ffe 100644 --- a/bottle/bottle.tscn +++ b/bottle/bottle.tscn @@ -15,11 +15,11 @@ sources/0 = SubResource("TileSetAtlasSource_midqx") 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) +layer_0/tile_data = PackedInt32Array(-1638406, 0, 0, -1638407, 0, 0, -1638408, 0, 0, -1572872, 0, 0, -1507336, 0, 0, -1441800, 0, 0, -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, -1507321, 0, 0, -1376249, 0, 0, -1310713, 0, 0, -1245177, 0, 0, -1179641, 0, 0, -1572857, 0, 0, -1638393, 0, 0, -1703929, 0, 0, -1703930, 0, 0, -1703931, 0, 0, -1638405, 0, 0, -1638404, 0, 0, -1703940, 0, 0, -1769476, 0, 0, -1835012, 0, 0, -1900548, 0, 0, -1703932, 0, 0, -1703933, 0, 0, -1769469, 0, 0, -1835005, 0, 0, -1900541, 0, 0, -1966077, 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) +polygon = PackedVector2Array(-320, -576, -320, 192, 320, 192, 320, -576, 48, -576, 48, -400, 112, -400, 112, -16, -112, -16, -112, -400, -48, -400, -48, -576) diff --git a/convertors/converter_working.gd b/convertors/converter_working.gd new file mode 100644 index 0000000..bbec3de --- /dev/null +++ b/convertors/converter_working.gd @@ -0,0 +1,11 @@ +extends AudioStreamPlayer + + +# 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/convertors/copper_to_silver.gd b/convertors/copper_to_silver.gd index 773a0bf..7b7cfd5 100644 --- a/convertors/copper_to_silver.gd +++ b/convertors/copper_to_silver.gd @@ -1,5 +1,7 @@ extends StaticBody2D +var coda : int = 0 + @export var scene: PackedScene @onready var _animated_sprite = $AnimatedSprite2D @@ -8,11 +10,16 @@ func _on_collector_collected(body): body.queue_free() func _on_collector_goal(): - $AnimatedSprite2D.play() - $converter_working.play() - $Timer.start() + coda+=1 + +func _process(delta): + if coda>=1 and $Timer.is_stopped(): + $AnimatedSprite2D.play() + $converter_working.play() + $Timer.start() func _on_timer_timeout(): + coda-=1 $AnimatedSprite2D.stop() $converter_working.stop() $New_item.play() diff --git a/convertors/copper_to_silver.tscn b/convertors/copper_to_silver.tscn index 1138a1a..8461cce 100644 --- a/convertors/copper_to_silver.tscn +++ b/convertors/copper_to_silver.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://ratkps4plkhl"] +[gd_scene load_steps=19 format=3 uid="uid://ratkps4plkhl"] [ext_resource type="Script" path="res://convertors/copper_to_silver.gd" id="1_jjv83"] [ext_resource type="PackedScene" uid="uid://dme22vvfgme5f" path="res://entity/coin_silver.tscn" id="2_orv64"] @@ -10,6 +10,7 @@ [ext_resource type="Texture2D" uid="uid://dg4qq1pgojk8d" path="res://entity/copper_to_silver/copper_converter_front_3.png" id="6_8ghce"] [ext_resource type="Texture2D" uid="uid://60502lbpup6" path="res://entity/copper_to_silver/copper_converter_front_4.png" id="7_e53sb"] [ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="10_uc0v7"] +[ext_resource type="Texture2D" uid="uid://440yhlpwpfw4" path="res://entity/copper_converter_back.png" id="11_c4wel"] [sub_resource type="AtlasTexture" id="AtlasTexture_62dyi"] atlas = ExtResource("4_04v4v") @@ -50,17 +51,11 @@ animations = [{ [sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"] size = Vector2(26, 5) -[sub_resource type="RectangleShape2D" id="RectangleShape2D_3i6q7"] -size = Vector2(3, 29) - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_eqmlo"] -size = Vector2(3, 28) - [sub_resource type="RectangleShape2D" id="RectangleShape2D_31dtl"] size = Vector2(25.8333, 5) [node name="CopperToSilver" type="StaticBody2D"] -scale = Vector2(2, 2) +scale = Vector2(3, 3) script = ExtResource("1_jjv83") scene = ExtResource("2_orv64") @@ -72,10 +67,16 @@ texture_filter = 1 sprite_frames = SubResource("SpriteFrames_4m3dg") frame_progress = 0.143561 +[node name="CopperConverterBack" type="Sprite2D" parent="."] +z_index = -10 +texture_filter = 1 +position = Vector2(0, -1) +texture = ExtResource("11_c4wel") + [node name="Collector" parent="." instance=ExtResource("3_a4naa")] collecting_types = Array[StringName]([&"Copper"]) collecting_collision_mask = 4 -collecting_amount = 2 +collecting_amount = 1 [node name="CollisionShape2D" type="CollisionShape2D" parent="Collector"] position = Vector2(0, 9.5) @@ -87,13 +88,11 @@ scene = ExtResource("2_orv64") buffer_cap = 1 spawn_rotation_range = 90.0 -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(-14.3333, -1) -shape = SubResource("RectangleShape2D_3i6q7") +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(-16, 13.5, -16, -16.5, -14.5, -17.5, -13, -16.5, -13, 13.5) -[node name="CollisionShape2D2" type="CollisionShape2D" parent="."] -position = Vector2(14.5, -1.66667) -shape = SubResource("RectangleShape2D_eqmlo") +[node name="CollisionPolygon2D2" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(13, 12.5, 13, -16.5, 14.5, -17.5, 16, -16.5, 16, 12.5) [node name="CollisionShape2D3" type="CollisionShape2D" parent="."] position = Vector2(0, 12.3333) @@ -103,7 +102,7 @@ one_way_collision = true one_way_collision_margin = 8.0 [node name="Timer" type="Timer" parent="."] -wait_time = 1.998 +wait_time = 0.518 one_shot = true [node name="New_item" type="AudioStreamPlayer" parent="."] diff --git a/game/game.tscn b/game/game.tscn index 81f9092..aca025f 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -12,16 +12,15 @@ texture_filter = 1 script = ExtResource("1_i3ly0") [node name="Bottle" parent="." instance=ExtResource("1_y7o2l")] -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) +position = Vector2(3, -298) [node name="TimeSpawner" parent="." instance=ExtResource("3_qwsty")] -position = Vector2(0, -144) +position = Vector2(0, -480) scene = ExtResource("4_e5nwi") buffer_cap = 1 spawn_position_range_x = 32.0 @@ -32,7 +31,7 @@ overlapping_body_count_limit = 4 [node name="Timer" type="Timer" parent="TimeSpawner"] [node name="ButtonSpawner" parent="." instance=ExtResource("3_qwsty")] -position = Vector2(0, -144) +position = Vector2(0, -480) scene = ExtResource("4_e5nwi") buffer_cap = 50 spawn_position_range_x = 32.0 diff --git a/root.tscn b/root.tscn index 8712d88..46ff088 100644 --- a/root.tscn +++ b/root.tscn @@ -1,17 +1,15 @@ -[gd_scene load_steps=8 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] [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="Script" path="res://View.gd" id="3_1ki2g"] -[ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="3_8gkpc"] +[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="Script" path="res://interface/SafeUI.gd" id="4_grf0c"] [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") -[node name="View" type="Control" parent="."] +[node name="UI" type="Control" parent="."] texture_filter = 1 layout_mode = 3 anchors_preset = 15 @@ -21,47 +19,33 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_vertical = 8 theme = ExtResource("1_h26ax") -script = ExtResource("3_1ki2g") -[node name="GameWI" type="CenterContainer" parent="View"] +[node name="GameContainer" type="Control" parent="UI"] process_mode = 1 layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 anchor_bottom = 1.0 grow_horizontal = 2 -grow_vertical = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 -metadata/_edit_vertical_guides_ = [] +grow_vertical = 0 -[node name="GameWorld" type="Control" parent="View/GameWI"] -layout_mode = 2 +[node name="Game" parent="UI/GameContainer" instance=ExtResource("3_hrdyr")] -[node name="Game" parent="View/GameWI/GameWorld" instance=ExtResource("3_8gkpc")] - -[node name="SafeUI" type="MarginContainer" parent="View"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("4_grf0c") - -[node name="GameUI" parent="View/SafeUI" instance=ExtResource("5_2cc15")] +[node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")] process_mode = 3 -layout_mode = 2 +layout_mode = 1 -[node name="ShopUI" parent="View/SafeUI" instance=ExtResource("3_lvefk")] +[node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] process_mode = 3 visible = false -layout_mode = 2 +layout_mode = 1 -[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="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"] -[connection signal="score_button_pressed" from="View/SafeUI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"] +[connection signal="score_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_score_button_pressed"] +[connection signal="shop_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] +[connection signal="spawn_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_spawn_button_pressed"] +[connection signal="back_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] +[connection signal="delete_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] +[connection signal="purchase_begin" from="UI/ShopUI" to="." method="_on_shop_ui_purchase_begin"] +[connection signal="score_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"]