From b71faaabba7f0ec7ac6fd029b310138c369c0e21 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 20:06:28 +0200 Subject: [PATCH] Add deletion and debug spam --- converters/converter.gd | 15 +++++++++++++++ game/DebugTimer.gd | 7 +++++++ game/game.gd | 10 ++++++++++ game/game.tscn | 21 ++++++++++++++++++++- interface/game_ui.gd | 11 +++++++++++ interface/shop_ui.gd | 20 ++++++++++++++------ main.gd | 9 ++++++--- main.tscn | 6 +++++- project.godot | 8 ++++++++ 9 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 game/DebugTimer.gd diff --git a/converters/converter.gd b/converters/converter.gd index 17386ef..432d4d7 100644 --- a/converters/converter.gd +++ b/converters/converter.gd @@ -29,3 +29,18 @@ func _on_timer_timeout(): sound_working.stop() sound_complete.play() spawner.spawn() + +var is_pending_deletion: bool = false + +func pending_deletion(): + sprite_front.modulate = Color.RED + is_pending_deletion = true + +func ending_deletion(): + sprite_front.modulate = Color.WHITE + is_pending_deletion = false + +func _input(event: InputEvent): + if is_pending_deletion: + if event is InputEventMouseButton or event is InputEventScreenTouch: + queue_free() diff --git a/game/DebugTimer.gd b/game/DebugTimer.gd new file mode 100644 index 0000000..3e8e68a --- /dev/null +++ b/game/DebugTimer.gd @@ -0,0 +1,7 @@ +extends Timer +class_name DebugTimer + + +func _input(event): + if event.is_action("turbo"): + start() \ No newline at end of file diff --git a/game/game.gd b/game/game.gd index 423e2db..6800cf5 100644 --- a/game/game.gd +++ b/game/game.gd @@ -95,3 +95,13 @@ func _on_ghost_materialize(): var spawner = instantiated.find_child("Spawner") if spawner != null: spawner.target = self + +func _on_shop_ui_delete_begin(): + var converters = find_children("*", "Converter", true, false) + for converter in converters: + converter.pending_deletion() + +func _on_shop_ui_delete_end(): + var converters = find_children("*", "Converter", true, false) + for converter in converters: + converter.ending_deletion() diff --git a/game/game.tscn b/game/game.tscn index 227b867..ec45876 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://c3rxmcwa5nqng"] +[gd_scene load_steps=23 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"] @@ -15,6 +15,7 @@ [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="10_sayqn"] [ext_resource type="Texture2D" uid="uid://c8pvjgtr2ufjl" path="res://interface/upgrade_copper.png" id="11_lt33g"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper/coin_copper.tscn" id="13_4j8om"] +[ext_resource type="Script" path="res://game/DebugTimer.gd" id="13_6ai3c"] [ext_resource type="PackedScene" uid="uid://qtk4tm6l367w" path="res://interface/ghost.tscn" id="16_8vhx6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rh35r"] @@ -75,6 +76,23 @@ debug_color = Color(0, 0.6, 0.701961, 0) [node name="Timer" type="Timer" parent="TimeSpawner"] +[node name="DebugSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] +position = Vector2(136, 0) +scene = ExtResource("13_4j8om") +target = NodePath("..") +buffer_cap = 1 +spawn_rect = Rect2(-20, 0, 40, 0) +overlapping_body_count_limit = 128 +metadata/_edit_lock_ = true + +[node name="NeckShape" type="CollisionShape2D" parent="DebugSpawner"] +shape = SubResource("RectangleShape2D_4uksi") +debug_color = Color(0, 0.6, 0.701961, 0) + +[node name="DebugTimer" type="Timer" parent="DebugSpawner"] +wait_time = 0.017 +script = ExtResource("13_6ai3c") + [node name="ButtonSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(136, 0) scene = ExtResource("13_4j8om") @@ -169,4 +187,5 @@ debug_color = Color(0, 0, 0, 0.419608) [connection signal="changed" from="Bottle/Evaluator" to="." method="_on_score_changed"] [connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"] +[connection signal="timeout" from="DebugSpawner/DebugTimer" to="DebugSpawner" method="spawn"] [connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"] diff --git a/interface/game_ui.gd b/interface/game_ui.gd index c3db18c..50fb545 100644 --- a/interface/game_ui.gd +++ b/interface/game_ui.gd @@ -38,3 +38,14 @@ func _on_shop_ui_purchase_cancel(_what: PurchasableItem): func _on_shop_ui_purchase_success(_what: PurchasableItem): spawn_button.disabled = false spawn_button.text = "Put" + + +func _on_shop_ui_delete_begin(): + spawn_button.disabled = true + spawn_button.text = "Del" + spawn_button.modulate = Color.RED + +func _on_shop_ui_delete_cancel(): + spawn_button.disabled = false + spawn_button.text = "Put" + spawn_button.modulate = Color.WHITE diff --git a/interface/shop_ui.gd b/interface/shop_ui.gd index 33d6e0b..5c6c936 100644 --- a/interface/shop_ui.gd +++ b/interface/shop_ui.gd @@ -6,9 +6,6 @@ class_name ShopUI ## Emitted when the Score button is pressed. signal score_button_pressed -## Emitted when the Delete button is pressed. -signal delete_button_pressed - ## Emitted when the Back button is presesd. signal back_button_pressed @@ -74,9 +71,6 @@ func _on_game_score_changed(total: int): func _on_score_button_pressed(): score_button_pressed.emit() - -func _on_delete_button_pressed(): - delete_button_pressed.emit() func _on_back_button_pressed(): back_button_pressed.emit() @@ -151,3 +145,17 @@ func _on_buy_compressor_purchase_success(): func _on_buy_artifactomatic_purchase_success(): print("[ShopUI] Completing Arti-factory...") + + +var is_deleting = false + +signal delete_begin +signal delete_cancel + +func _on_delete_button_pressed(): + if is_deleting: + is_deleting = false + delete_cancel.emit() + else: + is_deleting = true + delete_begin.emit() diff --git a/main.gd b/main.gd index 4dbbc2b..21296a8 100644 --- a/main.gd +++ b/main.gd @@ -40,9 +40,6 @@ func _on_game_ui_score_button_pressed(): func _on_shop_ui_back_button_pressed(): ui_state = UIState.GAME -func _on_shop_ui_delete_button_pressed(): - ui_state = UIState.GAME - func _on_shop_ui_score_button_pressed(): ui_state = UIState.SCORE @@ -51,3 +48,9 @@ func _on_game_ui_shop_button_pressed(): func _on_shop_ui_purchase_begin(_what): ui_state = UIState.GAME + +func _on_shop_ui_delete_begin(): + ui_state = UIState.GAME + +func _on_shop_ui_delete_cancel(): + ui_state = UIState.GAME diff --git a/main.tscn b/main.tscn index 9619093..5a3fe62 100644 --- a/main.tscn +++ b/main.tscn @@ -82,7 +82,11 @@ layout_mode = 2 [connection signal="shop_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] [connection signal="spawn_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="CustomUI/GameViewport/Viewport/Game" method="trigger_spawn"] [connection signal="back_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] -[connection signal="delete_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] +[connection signal="delete_begin" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_begin"] +[connection signal="delete_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_shop_ui_delete_begin"] +[connection signal="delete_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameSafeUI/GameUI" method="_on_shop_ui_delete_begin"] +[connection signal="delete_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_cancel"] +[connection signal="delete_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameSafeUI/GameUI" method="_on_shop_ui_delete_cancel"] [connection signal="ghost_materialize" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_ghost_materialize"] [connection signal="ghost_requested" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_ghost_requested"] [connection signal="purchase_begin" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"] diff --git a/project.godot b/project.godot index dfc98a5..5228743 100644 --- a/project.godot +++ b/project.godot @@ -25,6 +25,14 @@ window/size/mode=2 window/stretch/aspect="keep_height" window/handheld/orientation=1 +[input] + +turbo={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194308,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} + [layer_names] 2d_physics/layer_1="Default"