From 0f51e2e8d6b119ac3b136c228dc33d04b69befb6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 00:05:15 +0200 Subject: [PATCH 01/43] Prevent spawn if coins would overlap --- spawner/spawner.gd | 2 +- spawner/spawner.tscn | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 1cc21d5..be94ffb 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -4,7 +4,7 @@ class_name Spawner @export var target_parent: NodePath func spawn(): - if len($Area2D.get_overlapping_bodies()) > 0: + if len($Area.get_overlapping_bodies()) > 0: return var scene_instant = scene.instantiate() scene_instant.position=Vector2.ZERO diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index b97d4f9..399531f 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -2,8 +2,8 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_xnebx"] -size = Vector2(100, 20) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] +size = Vector2(16, 5) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") @@ -12,11 +12,11 @@ script = ExtResource("1_xqfmg") wait_time = 0.1 autostart = true -[node name="Area2D" type="Area2D" parent="."] +[node name="Area" type="Area2D" parent="."] collision_mask = 4 -[node name="Shape" type="CollisionShape2D" parent="Area2D"] -position = Vector2(0, -15) -shape = SubResource("RectangleShape2D_xnebx") +[node name="CoinShape" type="CollisionShape2D" parent="Area"] +scale = Vector2(3, 3) +shape = SubResource("RectangleShape2D_p13i4") [connection signal="timeout" from="Timer" to="." method="spawn"] From de09accad52f5f6db6cc82c465d1cb94eb28ddda Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 00:06:50 +0200 Subject: [PATCH 02/43] Commit export presets --- .gitignore | 1 - export_presets.cfg | 201 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 export_presets.cfg diff --git a/.gitignore b/.gitignore index dd59a16..d44a61b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ .import/ .export/ export.cfg -export_presets.cfg # Imported translations (automatically generated from CSV files) *.translation diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..20ed2b4 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,201 @@ +[preset.0] + +name="Android" +platform="Android" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +gradle_build/use_gradle_build=false +gradle_build/export_format=0 +gradle_build/min_sdk="" +gradle_build/target_sdk="" +architectures/armeabi-v7a=false +architectures/arm64-v8a=true +architectures/x86=false +architectures/x86_64=false +version/code=1 +version/name="1.0" +package/unique_name="org.godotengine.$genname" +package/name="" +package/signed=true +package/app_category=2 +package/retain_data_on_uninstall=false +package/exclude_from_recents=false +launcher_icons/main_192x192="" +launcher_icons/adaptive_foreground_432x432="" +launcher_icons/adaptive_background_432x432="" +graphics/opengl_debug=false +xr_features/xr_mode=0 +xr_features/hand_tracking=0 +xr_features/hand_tracking_frequency=0 +xr_features/passthrough=0 +screen/immersive_mode=true +screen/support_small=true +screen/support_normal=true +screen/support_large=true +screen/support_xlarge=true +user_data_backup/allow=false +command_line/extra_args="" +apk_expansion/enable=false +apk_expansion/SALT="" +apk_expansion/public_key="" +permissions/custom_permissions=PackedStringArray() +permissions/access_checkin_properties=false +permissions/access_coarse_location=false +permissions/access_fine_location=false +permissions/access_location_extra_commands=false +permissions/access_mock_location=false +permissions/access_network_state=false +permissions/access_surface_flinger=false +permissions/access_wifi_state=false +permissions/account_manager=false +permissions/add_voicemail=false +permissions/authenticate_accounts=false +permissions/battery_stats=false +permissions/bind_accessibility_service=false +permissions/bind_appwidget=false +permissions/bind_device_admin=false +permissions/bind_input_method=false +permissions/bind_nfc_service=false +permissions/bind_notification_listener_service=false +permissions/bind_print_service=false +permissions/bind_remoteviews=false +permissions/bind_text_service=false +permissions/bind_vpn_service=false +permissions/bind_wallpaper=false +permissions/bluetooth=false +permissions/bluetooth_admin=false +permissions/bluetooth_privileged=false +permissions/brick=false +permissions/broadcast_package_removed=false +permissions/broadcast_sms=false +permissions/broadcast_sticky=false +permissions/broadcast_wap_push=false +permissions/call_phone=false +permissions/call_privileged=false +permissions/camera=false +permissions/capture_audio_output=false +permissions/capture_secure_video_output=false +permissions/capture_video_output=false +permissions/change_component_enabled_state=false +permissions/change_configuration=false +permissions/change_network_state=false +permissions/change_wifi_multicast_state=false +permissions/change_wifi_state=false +permissions/clear_app_cache=false +permissions/clear_app_user_data=false +permissions/control_location_updates=false +permissions/delete_cache_files=false +permissions/delete_packages=false +permissions/device_power=false +permissions/diagnostic=false +permissions/disable_keyguard=false +permissions/dump=false +permissions/expand_status_bar=false +permissions/factory_test=false +permissions/flashlight=false +permissions/force_back=false +permissions/get_accounts=false +permissions/get_package_size=false +permissions/get_tasks=false +permissions/get_top_activity_info=false +permissions/global_search=false +permissions/hardware_test=false +permissions/inject_events=false +permissions/install_location_provider=false +permissions/install_packages=false +permissions/install_shortcut=false +permissions/internal_system_window=false +permissions/internet=false +permissions/kill_background_processes=false +permissions/location_hardware=false +permissions/manage_accounts=false +permissions/manage_app_tokens=false +permissions/manage_documents=false +permissions/manage_external_storage=false +permissions/master_clear=false +permissions/media_content_control=false +permissions/modify_audio_settings=false +permissions/modify_phone_state=false +permissions/mount_format_filesystems=false +permissions/mount_unmount_filesystems=false +permissions/nfc=false +permissions/persistent_activity=false +permissions/process_outgoing_calls=false +permissions/read_calendar=false +permissions/read_call_log=false +permissions/read_contacts=false +permissions/read_external_storage=false +permissions/read_frame_buffer=false +permissions/read_history_bookmarks=false +permissions/read_input_state=false +permissions/read_logs=false +permissions/read_phone_state=false +permissions/read_profile=false +permissions/read_sms=false +permissions/read_social_stream=false +permissions/read_sync_settings=false +permissions/read_sync_stats=false +permissions/read_user_dictionary=false +permissions/reboot=false +permissions/receive_boot_completed=false +permissions/receive_mms=false +permissions/receive_sms=false +permissions/receive_wap_push=false +permissions/record_audio=false +permissions/reorder_tasks=false +permissions/restart_packages=false +permissions/send_respond_via_message=false +permissions/send_sms=false +permissions/set_activity_watcher=false +permissions/set_alarm=false +permissions/set_always_finish=false +permissions/set_animation_scale=false +permissions/set_debug_app=false +permissions/set_orientation=false +permissions/set_pointer_speed=false +permissions/set_preferred_applications=false +permissions/set_process_limit=false +permissions/set_time=false +permissions/set_time_zone=false +permissions/set_wallpaper=false +permissions/set_wallpaper_hints=false +permissions/signal_persistent_processes=false +permissions/status_bar=false +permissions/subscribed_feeds_read=false +permissions/subscribed_feeds_write=false +permissions/system_alert_window=false +permissions/transmit_ir=false +permissions/uninstall_shortcut=false +permissions/update_device_stats=false +permissions/use_credentials=false +permissions/use_sip=false +permissions/vibrate=false +permissions/wake_lock=false +permissions/write_apn_settings=false +permissions/write_calendar=false +permissions/write_call_log=false +permissions/write_contacts=false +permissions/write_external_storage=false +permissions/write_gservices=false +permissions/write_history_bookmarks=false +permissions/write_profile=false +permissions/write_secure_settings=false +permissions/write_settings=false +permissions/write_sms=false +permissions/write_social_stream=false +permissions/write_sync_settings=false +permissions/write_user_dictionary=false From 4e90184a2e4d6046d942a82dfc3366ab72fc9eff Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 00:07:28 +0200 Subject: [PATCH 03/43] Update export presets --- export_presets.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/export_presets.cfg b/export_presets.cfg index 20ed2b4..e66f044 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -28,8 +28,8 @@ architectures/x86=false architectures/x86_64=false version/code=1 version/name="1.0" -package/unique_name="org.godotengine.$genname" -package/name="" +package/unique_name="eu.steffo.ld54s" +package/name="Garasautos" package/signed=true package/app_category=2 package/retain_data_on_uninstall=false From be64f3d8d76a60d1b8928598c8a064ca863a6d06 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 00:25:13 +0200 Subject: [PATCH 04/43] implemented logic for manual and automatic spawner --- entity/coin_copper.tscn | 2 +- root.tscn | 13 ++++++++++++- spawner/spawner.gd | 1 + spawner/spawner.tscn | 6 ------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index a788a5f..034efc9 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -5,7 +5,7 @@ [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] -size = Vector2(16, 5) +size = Vector2(14, 3) [node name="CoinCopper" type="RigidBody2D"] collision_layer = 5 diff --git a/root.tscn b/root.tscn index b24a08c..35ea7ee 100644 --- a/root.tscn +++ b/root.tscn @@ -79,6 +79,17 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] [node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -400) +position = Vector2(-24, -407) scene = ExtResource("2_dv01l") target_parent = NodePath("..") + +[node name="Timer2" type="Timer" parent="UI/GameContainer/Game/Spawner"] +autostart = true + +[node name="TouchSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(23, -424) +scene = ExtResource("2_dv01l") +target_parent = NodePath("..") + +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/TouchSpawner" method="spawn"] +[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer2" to="UI/GameContainer/Game/Spawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index be94ffb..de26e49 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -9,3 +9,4 @@ func spawn(): var scene_instant = scene.instantiate() scene_instant.position=Vector2.ZERO add_child(scene_instant) + diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 399531f..fd59048 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -8,15 +8,9 @@ size = Vector2(16, 5) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") -[node name="Timer" type="Timer" parent="."] -wait_time = 0.1 -autostart = true - [node name="Area" type="Area2D" parent="."] collision_mask = 4 [node name="CoinShape" type="CollisionShape2D" parent="Area"] scale = Vector2(3, 3) shape = SubResource("RectangleShape2D_p13i4") - -[connection signal="timeout" from="Timer" to="." method="spawn"] From ca7a4a6d1c1aa867cb653664714aa8f084b65b61 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 00:47:50 +0200 Subject: [PATCH 05/43] made converter (absolutely unfinished and broken ) --- Convertitore.gd | 19 +++++++++++++++++++ convertitore.tscn | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Convertitore.gd create mode 100644 convertitore.tscn diff --git a/Convertitore.gd b/Convertitore.gd new file mode 100644 index 0000000..fd728c5 --- /dev/null +++ b/Convertitore.gd @@ -0,0 +1,19 @@ +extends Node2D +var conta_soldi: int = 0 + +# 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 + + +func _on_ingresso_body_shape_entered(body_rid, body, body_shape_index, local_shape_index): + body.queue_free() + conta_soldi+=1 + if conta_soldi>=10: + conta_soldi=0 + diff --git a/convertitore.tscn b/convertitore.tscn new file mode 100644 index 0000000..8b33da9 --- /dev/null +++ b/convertitore.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=3 format=3 uid="uid://cxtgmrrq432tc"] + +[ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"] +[ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"] + +[node name="Convertitore" type="Node2D"] +script = ExtResource("1_7de38") + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(61, 76) +rotation = 1.5708 +scale = Vector2(0.2, 0.2) +texture = ExtResource("2_8bfs6") + +[node name="StaticBody2D" type="StaticBody2D" parent="."] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"] +polygon = PackedVector2Array(36, 114, 36, 38, 42, 56, 61, 57, 79, 56, 85, 38, 85, 115, 61, 91) + +[node name="Ingresso" type="Area2D" parent="."] +position = Vector2(56, 42) + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Ingresso"] +polygon = PackedVector2Array(-20, -6, 29, -6, 23, 11, 5, 14, -12, 12) + +[connection signal="body_shape_entered" from="Ingresso" to="." method="_on_ingresso_body_shape_entered"] From 50a1ba1873504a857c2130f3a3a66a943282e3b3 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 00:49:59 +0200 Subject: [PATCH 06/43] ? --- root.tscn | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/root.tscn b/root.tscn index 35ea7ee..6c19925 100644 --- a/root.tscn +++ b/root.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] [ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] [ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] +[ext_resource type="PackedScene" uid="uid://cxtgmrrq432tc" path="res://convertitore.tscn" id="5_6hpcd"] [node name="Root" type="Node"] @@ -91,5 +92,8 @@ position = Vector2(23, -424) scene = ExtResource("2_dv01l") target_parent = NodePath("..") +[node name="Convertitore" parent="UI/GameContainer/Game" instance=ExtResource("5_6hpcd")] +position = Vector2(-110, -257) + [connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/TouchSpawner" method="spawn"] [connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer2" to="UI/GameContainer/Game/Spawner" method="spawn"] From 5b5e606f0f3e1fbd3d1de184be53cd3101c81774 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:25:38 +0200 Subject: [PATCH 07/43] Update changed resources --- convertitore.tscn | 2 +- root.tscn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/convertitore.tscn b/convertitore.tscn index 8b33da9..95f36ae 100644 --- a/convertitore.tscn +++ b/convertitore.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3 uid="uid://cxtgmrrq432tc"] +[gd_scene load_steps=3 format=3 uid="uid://d34gt53jcq1uw"] [ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"] [ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"] diff --git a/root.tscn b/root.tscn index 6c19925..3be6353 100644 --- a/root.tscn +++ b/root.tscn @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] [ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] -[ext_resource type="PackedScene" uid="uid://cxtgmrrq432tc" path="res://convertitore.tscn" id="5_6hpcd"] +[ext_resource type="PackedScene" path="res://convertitore.tscn" id="5_6hpcd"] [node name="Root" type="Node"] From f844cd02d22abdd8d1ce89eb86c75d7c2c1a5f34 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:33:54 +0200 Subject: [PATCH 08/43] Configure spawners --- entity/coin_copper.tscn | 2 +- root.tscn | 20 ++++++++------------ spawner/spawner.gd | 18 ++++++++++++------ spawner/spawner.tscn | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index 034efc9..a788a5f 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -5,7 +5,7 @@ [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] -size = Vector2(14, 3) +size = Vector2(16, 5) [node name="CoinCopper" type="RigidBody2D"] collision_layer = 5 diff --git a/root.tscn b/root.tscn index 3be6353..19e6525 100644 --- a/root.tscn +++ b/root.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] [ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] [ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] -[ext_resource type="PackedScene" path="res://convertitore.tscn" id="5_6hpcd"] [node name="Root" type="Node"] @@ -79,21 +78,18 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] -[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(-24, -407) +[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(-24, -490) scene = ExtResource("2_dv01l") target_parent = NodePath("..") -[node name="Timer2" type="Timer" parent="UI/GameContainer/Game/Spawner"] +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] autostart = true -[node name="TouchSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(23, -424) +[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(24, -490) scene = ExtResource("2_dv01l") target_parent = NodePath("..") -[node name="Convertitore" parent="UI/GameContainer/Game" instance=ExtResource("5_6hpcd")] -position = Vector2(-110, -257) - -[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/TouchSpawner" method="spawn"] -[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer2" to="UI/GameContainer/Game/Spawner" method="spawn"] +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] +[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index de26e49..f749c76 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -1,12 +1,18 @@ extends Node2D class_name Spawner + + @export var scene: PackedScene -@export var target_parent: NodePath + func spawn(): - if len($Area.get_overlapping_bodies()) > 0: - return - var scene_instant = scene.instantiate() - scene_instant.position=Vector2.ZERO - add_child(scene_instant) + var overlapping_bodies = $Area.get_overlapping_bodies() + for overlapping_body in overlapping_bodies: + if overlapping_body.collision_layer && 0b100: + print("[Spawner] Not spawning, overlapping with: ", overlapping_body) + return + var scene_instant = scene.instantiate() + scene_instant.position = Vector2.ZERO + print("[Spawner] Created: ", scene_instant) + add_child(scene_instant) diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index fd59048..0a69c47 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] -size = Vector2(16, 5) +size = Vector2(14, 3) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") From 40089db03ae7071cc58c1a33b7b2adf365edb959 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:37:25 +0200 Subject: [PATCH 09/43] Default to down gravity if accelerometer is not supported --- bottle/gravity_from_gyro.gd | 4 +++- root.tscn | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bottle/gravity_from_gyro.gd b/bottle/gravity_from_gyro.gd index 52cc29b..7d91eb0 100644 --- a/bottle/gravity_from_gyro.gd +++ b/bottle/gravity_from_gyro.gd @@ -4,6 +4,8 @@ class_name GravityFromGyro func _physics_process(_delta): var accel_3d = Input.get_accelerometer() + if accel_3d == Vector3.ZERO: # If accelerometer is not supported + accel_3d = Vector3.DOWN * 9.8 + var accel_2d = Vector2(accel_3d.x, -accel_3d.y) / 9.8 PhysicsServer2D.area_set_param(get_viewport().find_world_2d().space, PhysicsServer2D.AREA_PARAM_GRAVITY_VECTOR, accel_2d) - diff --git a/root.tscn b/root.tscn index 19e6525..8118017 100644 --- a/root.tscn +++ b/root.tscn @@ -81,7 +81,6 @@ texture_filter = 1 [node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] position = Vector2(-24, -490) scene = ExtResource("2_dv01l") -target_parent = NodePath("..") [node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] autostart = true @@ -89,7 +88,6 @@ autostart = true [node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] position = Vector2(24, -490) scene = ExtResource("2_dv01l") -target_parent = NodePath("..") [connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] [connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] From cc60fc1ff910f3525309cff449f182cc3ca9e89d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:56:54 +0200 Subject: [PATCH 10/43] Buffer coin spawns --- root.tscn | 8 +++++--- spawner/spawner.gd | 29 +++++++++++++++++++---------- spawner/spawner.tscn | 3 ++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/root.tscn b/root.tscn index 8118017..1f2efea 100644 --- a/root.tscn +++ b/root.tscn @@ -78,16 +78,18 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] -[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] position = Vector2(-24, -490) scene = ExtResource("2_dv01l") +buffer_cap = 10 -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/Spawner"] autostart = true [node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] position = Vector2(24, -490) scene = ExtResource("2_dv01l") +buffer_cap = 10 [connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] -[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] +[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer" to="UI/GameContainer/Game/Spawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index f749c76..5b95c97 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -4,15 +4,24 @@ class_name Spawner @export var scene: PackedScene +var buffer: int = 0 +@export var buffer_cap: int + func spawn(): - var overlapping_bodies = $Area.get_overlapping_bodies() - for overlapping_body in overlapping_bodies: - if overlapping_body.collision_layer && 0b100: - print("[Spawner] Not spawning, overlapping with: ", overlapping_body) - return - - var scene_instant = scene.instantiate() - scene_instant.position = Vector2.ZERO - print("[Spawner] Created: ", scene_instant) - add_child(scene_instant) + buffer = clampi(buffer + 1, 0, buffer_cap) + + +func _physics_process(_delta): + if buffer > 0: + var overlapping_bodies = $Area.get_overlapping_bodies() + for overlapping_body in overlapping_bodies: + if overlapping_body.collision_layer && 0b100: + print("[Spawner] Not spawning, overlapping with: ", overlapping_body) + return + + var scene_instant = scene.instantiate() + scene_instant.position = Vector2.ZERO + print("[Spawner] Spawned ", buffer, "/", buffer_cap, ": ", scene_instant) + buffer -= 1 + add_child(scene_instant) diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 0a69c47..101db56 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] -size = Vector2(14, 3) +size = Vector2(14, 2) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") @@ -12,5 +12,6 @@ script = ExtResource("1_xqfmg") collision_mask = 4 [node name="CoinShape" type="CollisionShape2D" parent="Area"] +position = Vector2(0, -3) scale = Vector2(3, 3) shape = SubResource("RectangleShape2D_p13i4") From 265da5fe506b342b725f01aafc11ae2d1a334b34 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:58:46 +0200 Subject: [PATCH 11/43] Cache $Area reference in Spawner --- spawner/spawner.gd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 5b95c97..672d27b 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -7,6 +7,8 @@ class_name Spawner var buffer: int = 0 @export var buffer_cap: int +@onready var area: Area2D = $Area + func spawn(): buffer = clampi(buffer + 1, 0, buffer_cap) @@ -14,14 +16,11 @@ func spawn(): func _physics_process(_delta): if buffer > 0: - var overlapping_bodies = $Area.get_overlapping_bodies() + var overlapping_bodies = area.get_overlapping_bodies() for overlapping_body in overlapping_bodies: if overlapping_body.collision_layer && 0b100: - print("[Spawner] Not spawning, overlapping with: ", overlapping_body) - return - + return var scene_instant = scene.instantiate() scene_instant.position = Vector2.ZERO - print("[Spawner] Spawned ", buffer, "/", buffer_cap, ": ", scene_instant) buffer -= 1 add_child(scene_instant) From abfadcee49f10cd7e75433e2febfdb6835dba568 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 01:59:28 +0200 Subject: [PATCH 12/43] Do not use clampi to keep code simple --- spawner/spawner.gd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 672d27b..f188599 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -11,7 +11,9 @@ var buffer: int = 0 func spawn(): - buffer = clampi(buffer + 1, 0, buffer_cap) + buffer += 1 + if buffer > buffer_cap: + buffer = buffer_cap func _physics_process(_delta): From a10335c0b9c58c450886ea25a4461fa107c64594 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:18:08 +0200 Subject: [PATCH 13/43] Spawn coins at random positions along the shape extents --- root.tscn | 14 +++++++------- spawner/spawner.gd | 29 +++++++++++++++++++++-------- spawner/spawner.tscn | 4 ++-- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/root.tscn b/root.tscn index 1f2efea..dfbeef2 100644 --- a/root.tscn +++ b/root.tscn @@ -78,18 +78,18 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] -[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(-24, -490) +[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -490) scene = ExtResource("2_dv01l") -buffer_cap = 10 +buffer_cap = 1 -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/Spawner"] +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] autostart = true [node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(24, -490) +position = Vector2(0, -490) scene = ExtResource("2_dv01l") -buffer_cap = 10 +buffer_cap = 50 [connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] -[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer" to="UI/GameContainer/Game/Spawner" method="spawn"] +[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index f188599..3bd99bc 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -8,21 +8,34 @@ var buffer: int = 0 @export var buffer_cap: int @onready var area: Area2D = $Area +@onready var shape: CollisionShape2D = $Area/Shape + +@onready var rng: RandomNumberGenerator = RandomNumberGenerator.new() func spawn(): buffer += 1 if buffer > buffer_cap: + print("Hit buffer!") buffer = buffer_cap +func _select_spawn_position() -> Vector2: + var variance = shape.shape.size.x / 2 + var x = rng.randf_range(-variance, +variance) + return Vector2(x, 0) + +func _do_spawn(): + var overlapping_bodies = area.get_overlapping_bodies() + for overlapping_body in overlapping_bodies: + if overlapping_body.collision_layer && 0b100: + return + var scene_instant = scene.instantiate() + scene_instant.position = _select_spawn_location() + add_child(scene_instant) + buffer -= 1 + + func _physics_process(_delta): if buffer > 0: - var overlapping_bodies = area.get_overlapping_bodies() - for overlapping_body in overlapping_bodies: - if overlapping_body.collision_layer && 0b100: - return - var scene_instant = scene.instantiate() - scene_instant.position = Vector2.ZERO - buffer -= 1 - add_child(scene_instant) + _do_spawn() diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 101db56..56a8b1d 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] -size = Vector2(14, 2) +size = Vector2(32, 2) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") @@ -11,7 +11,7 @@ script = ExtResource("1_xqfmg") [node name="Area" type="Area2D" parent="."] collision_mask = 4 -[node name="CoinShape" type="CollisionShape2D" parent="Area"] +[node name="Shape" type="CollisionShape2D" parent="Area"] position = Vector2(0, -3) scale = Vector2(3, 3) shape = SubResource("RectangleShape2D_p13i4") From c9c57a1ff97bf590bb9c0082fb068fd76055b3df Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:27:49 +0200 Subject: [PATCH 14/43] Add spawn randomization --- export_presets.cfg | 4 ++-- root.tscn | 8 ++++++-- spawner/spawner.gd | 13 ++++++++----- spawner/spawner.tscn | 5 ++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/export_presets.cfg b/export_presets.cfg index e66f044..20ed2b4 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -28,8 +28,8 @@ architectures/x86=false architectures/x86_64=false version/code=1 version/name="1.0" -package/unique_name="eu.steffo.ld54s" -package/name="Garasautos" +package/unique_name="org.godotengine.$genname" +package/name="" package/signed=true package/app_category=2 package/retain_data_on_uninstall=false diff --git a/root.tscn b/root.tscn index dfbeef2..026284d 100644 --- a/root.tscn +++ b/root.tscn @@ -79,17 +79,21 @@ texture_filter = 1 [node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] [node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -490) +position = Vector2(0, -480) scene = ExtResource("2_dv01l") buffer_cap = 1 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 [node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] autostart = true [node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -490) +position = Vector2(0, -480) scene = ExtResource("2_dv01l") buffer_cap = 50 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 [connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] [connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 3bd99bc..9764dd0 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -8,8 +8,9 @@ var buffer: int = 0 @export var buffer_cap: int @onready var area: Area2D = $Area -@onready var shape: CollisionShape2D = $Area/Shape +@export var spawn_position_range_x: float +@export_range(0, 90) var spawn_rotation_range: float @onready var rng: RandomNumberGenerator = RandomNumberGenerator.new() @@ -21,9 +22,10 @@ func spawn(): func _select_spawn_position() -> Vector2: - var variance = shape.shape.size.x / 2 - var x = rng.randf_range(-variance, +variance) - return Vector2(x, 0) + return Vector2(rng.randf_range(-spawn_position_range_x, +spawn_position_range_x), 0) + +func _select_spawn_rotation() -> float: + return rng.randf_range(-spawn_rotation_range, spawn_rotation_range) func _do_spawn(): var overlapping_bodies = area.get_overlapping_bodies() @@ -31,7 +33,8 @@ func _do_spawn(): if overlapping_body.collision_layer && 0b100: return var scene_instant = scene.instantiate() - scene_instant.position = _select_spawn_location() + scene_instant.position = _select_spawn_position() + scene_instant.rotation_degrees = _select_spawn_rotation() add_child(scene_instant) buffer -= 1 diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 56a8b1d..788a581 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] -size = Vector2(32, 2) +size = Vector2(96, 32) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") @@ -12,6 +12,5 @@ script = ExtResource("1_xqfmg") collision_mask = 4 [node name="Shape" type="CollisionShape2D" parent="Area"] -position = Vector2(0, -3) -scale = Vector2(3, 3) +position = Vector2(0, -16) shape = SubResource("RectangleShape2D_p13i4") From e80e81b938349773321d3a9f28ed8190abe52aeb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:38:27 +0200 Subject: [PATCH 15/43] Buffer area overlapping bodies as well so spawns are more natural --- root.tscn | 75 +++++++++++++++++++++++--------------------- spawner/spawner.gd | 17 +++++++--- spawner/spawner.tscn | 3 +- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/root.tscn b/root.tscn index 026284d..0884c6b 100644 --- a/root.tscn +++ b/root.tscn @@ -16,6 +16,45 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_vertical = 8 +[node name="GameContainer" type="Control" parent="UI"] +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" type="Node2D" parent="UI/GameContainer"] +texture_filter = 1 + +[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] + +[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] + +[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 1 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] +wait_time = 0.03 +autostart = true + +[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 50 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + [node name="Rows" type="VBoxContainer" parent="UI"] layout_mode = 1 anchors_preset = 15 @@ -61,39 +100,5 @@ size_flags_horizontal = 8 text = "Shop" alignment = 2 -[node name="GameContainer" type="Control" parent="UI"] -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" type="Node2D" parent="UI/GameContainer"] -texture_filter = 1 - -[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] - -[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] - -[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 1 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 - -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] -autostart = true - -[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 50 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 - -[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] [connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 9764dd0..b974503 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -13,6 +13,9 @@ var buffer: int = 0 @export_range(0, 90) var spawn_rotation_range: float @onready var rng: RandomNumberGenerator = RandomNumberGenerator.new() +@export_flags_2d_physics var overlapping_bodies_collision_mask: int +@export_range(0, 16) var overlapping_body_count_limit: int + func spawn(): buffer += 1 @@ -20,6 +23,14 @@ func spawn(): print("Hit buffer!") buffer = buffer_cap +func _count_overlapping_bodies() -> int: + var overlapping_bodies = area.get_overlapping_bodies() + var overlapping_body_count = 0 + for overlapping_body in overlapping_bodies: + if overlapping_body.collision_layer && overlapping_bodies_collision_mask: + overlapping_body_count += 1 + return overlapping_body_count + func _select_spawn_position() -> Vector2: return Vector2(rng.randf_range(-spawn_position_range_x, +spawn_position_range_x), 0) @@ -28,10 +39,8 @@ func _select_spawn_rotation() -> float: return rng.randf_range(-spawn_rotation_range, spawn_rotation_range) func _do_spawn(): - var overlapping_bodies = area.get_overlapping_bodies() - for overlapping_body in overlapping_bodies: - if overlapping_body.collision_layer && 0b100: - return + if _count_overlapping_bodies() > overlapping_body_count_limit: + return var scene_instant = scene.instantiate() scene_instant.position = _select_spawn_position() scene_instant.rotation_degrees = _select_spawn_rotation() diff --git a/spawner/spawner.tscn b/spawner/spawner.tscn index 788a581..fb79f06 100644 --- a/spawner/spawner.tscn +++ b/spawner/spawner.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"] -size = Vector2(96, 32) +size = Vector2(96, 96) [node name="Spawner" type="Node2D"] script = ExtResource("1_xqfmg") @@ -12,5 +12,4 @@ script = ExtResource("1_xqfmg") collision_mask = 4 [node name="Shape" type="CollisionShape2D" parent="Area"] -position = Vector2(0, -16) shape = SubResource("RectangleShape2D_p13i4") From 8e83184150f9b2d9b3d58da1fdf09af163dd21bf Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:41:39 +0200 Subject: [PATCH 16/43] Add `spawned` signal to spawner --- spawner/spawner.gd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index b974503..b84884b 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -16,6 +16,8 @@ var buffer: int = 0 @export_flags_2d_physics var overlapping_bodies_collision_mask: int @export_range(0, 16) var overlapping_body_count_limit: int +signal spawned(what: RigidBody2D) + func spawn(): buffer += 1 @@ -45,6 +47,7 @@ func _do_spawn(): scene_instant.position = _select_spawn_position() scene_instant.rotation_degrees = _select_spawn_rotation() add_child(scene_instant) + emit_signal("spawned", scene_instant) buffer -= 1 From 5f3e361a9dd2e89c54a2ae06667fb0e8af9ca7c0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:41:49 +0200 Subject: [PATCH 17/43] Remove hit buffer print log --- spawner/spawner.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index b84884b..1867032 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -22,7 +22,6 @@ signal spawned(what: RigidBody2D) func spawn(): buffer += 1 if buffer > buffer_cap: - print("Hit buffer!") buffer = buffer_cap func _count_overlapping_bodies() -> int: From 227487f58c85942ddfaa56adeeb6aedeb6357b0a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:47:54 +0200 Subject: [PATCH 18/43] Use bitwise and for spawner overlap collision mask --- spawner/spawner.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 1867032..9c2a33a 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -28,7 +28,7 @@ func _count_overlapping_bodies() -> int: var overlapping_bodies = area.get_overlapping_bodies() var overlapping_body_count = 0 for overlapping_body in overlapping_bodies: - if overlapping_body.collision_layer && overlapping_bodies_collision_mask: + if overlapping_body.collision_layer & overlapping_bodies_collision_mask: overlapping_body_count += 1 return overlapping_body_count From 2d864c8c283122b6ec262213fa2cf12c786de6a4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 02:57:06 +0200 Subject: [PATCH 19/43] Fix `spawned` signal parameter type --- spawner/spawner.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 9c2a33a..8e6a5f1 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -16,7 +16,7 @@ var buffer: int = 0 @export_flags_2d_physics var overlapping_bodies_collision_mask: int @export_range(0, 16) var overlapping_body_count_limit: int -signal spawned(what: RigidBody2D) +signal spawned(what: Node2D) func spawn(): From e90830cd06112eed90a9dbb7eb28a307e29082e8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 03:03:03 +0200 Subject: [PATCH 20/43] Add collector entity --- collector/collectible.gd | 23 +++++++++++++++++++++++ collector/collectible.tscn | 6 ++++++ collector/collector.gd | 20 ++++++++++++++++++++ collector/collector.tscn | 8 ++++++++ 4 files changed, 57 insertions(+) create mode 100644 collector/collectible.gd create mode 100644 collector/collectible.tscn create mode 100644 collector/collector.gd create mode 100644 collector/collector.tscn diff --git a/collector/collectible.gd b/collector/collectible.gd new file mode 100644 index 0000000..941a2f5 --- /dev/null +++ b/collector/collectible.gd @@ -0,0 +1,23 @@ +extends Node +class_name Collectible + +enum CollectibleType { + UNSET, + COIN_COPPER, + COIN_SILVER, + COIN_GOLD, + GEM, + DIAMOND, + COAL, + CROWN, + SUPERCROWN, +} + +@export var type: CollectibleType + +signal collected + + +func collect(): + emit_signal("collected") + get_parent().queue_free() diff --git a/collector/collectible.tscn b/collector/collectible.tscn new file mode 100644 index 0000000..7f6b2a1 --- /dev/null +++ b/collector/collectible.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bk1vvq5rug01m"] + +[ext_resource type="Script" path="res://collector/collectible.gd" id="1_qilbk"] + +[node name="Collectible" type="Node"] +script = ExtResource("1_qilbk") diff --git a/collector/collector.gd b/collector/collector.gd new file mode 100644 index 0000000..2cc74c3 --- /dev/null +++ b/collector/collector.gd @@ -0,0 +1,20 @@ +extends Area2D +class_name Collector + + +var collected_count: int = 0 + +@export var collecting_types: Array[Collectible.CollectibleType] +@export_flags_2d_physics var collecting_collision_mask: int + +signal collected(what: PhysicsBody2D) + + +func _on_body_entered(body: Node2D): + if body is PhysicsBody2D: + if body.collision_layer & collecting_collision_mask: + var collectible: Collectible = body.get_node("Collectible") + if collectible.type in collecting_types: + collected_count += 1 + collectible.collect() + emit_signal("collected", body) diff --git a/collector/collector.tscn b/collector/collector.tscn new file mode 100644 index 0000000..0273735 --- /dev/null +++ b/collector/collector.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"] + +[ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"] + +[node name="Collector" type="Area2D"] +script = ExtResource("1_1xtt5") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] From a3826b9801215aee210335f8f10b4d998a8742b7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 03:20:47 +0200 Subject: [PATCH 21/43] Document collector entity --- collector/collectible.gd | 23 +++++++++-------------- collector/collector.gd | 21 ++++++++++++++++++++- entity/coin_copper.tscn | 5 ++++- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/collector/collectible.gd b/collector/collectible.gd index 941a2f5..7905c1e 100644 --- a/collector/collectible.gd +++ b/collector/collectible.gd @@ -1,23 +1,18 @@ extends Node class_name Collectible +## A marker for collectible entities. +## +## Used by [Collector]s to determine which entities to pick up. -enum CollectibleType { - UNSET, - COIN_COPPER, - COIN_SILVER, - COIN_GOLD, - GEM, - DIAMOND, - COAL, - CROWN, - SUPERCROWN, -} -@export var type: CollectibleType +## The type of collectible entity the parent entity represents. +@export var type: StringName +## Emitted when this entity has been collected by a collector. signal collected - +## Mark this entity as collected. +## +## You'll probably want to connect this to an AudioSource2D, which will disable the node and play a sound, and when the sound is over a new signal will queue_free it. func collect(): emit_signal("collected") - get_parent().queue_free() diff --git a/collector/collector.gd b/collector/collector.gd index 2cc74c3..c9a4266 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -1,14 +1,30 @@ extends Area2D class_name Collector +## Area that will pick up [Collectible]s with a given name, keeping track of the amount collected. +## The current amount of collected entities. var collected_count: int = 0 -@export var collecting_types: Array[Collectible.CollectibleType] +## The types of [Collectible]s to pick up. +## +## The strings will match only if exactly the same. +@export var collecting_types: Array[StringName] + +## The collision mask to check colliding body against. @export_flags_2d_physics var collecting_collision_mask: int +## The goal amount of entities to collect. +## +## When [collected_count] reaches it, it will be reset to zero, and the "goal" signal will be emitted. +@export var collecting_amount: int + +## The collector has picked up an object. signal collected(what: PhysicsBody2D) +## The collector has received its collection goal and is about to reset. +signal goal + func _on_body_entered(body: Node2D): if body is PhysicsBody2D: @@ -18,3 +34,6 @@ func _on_body_entered(body: Node2D): collected_count += 1 collectible.collect() emit_signal("collected", body) + if collected_count >= collecting_amount: + emit_signal("goal") + collected_count = 0 diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index a788a5f..6deddd0 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://c3kitncwpi42j"] +[gd_scene load_steps=6 format=3 uid="uid://c3kitncwpi42j"] [ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="1_8k46m"] [ext_resource type="Texture2D" uid="uid://dbdkb4vt7dh85" path="res://entity/coin_copper_4.png" id="1_wedw1"] [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"] +[ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="4_yefrx"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] size = Vector2(16, 5) @@ -28,3 +29,5 @@ texture = ExtResource("1_wedw1") z_index = -10 texture_filter = 1 texture = ExtResource("2_2ifq3") + +[node name="Collectible" parent="." instance=ExtResource("4_yefrx")] From e71fb904017a4e22546f5230adc7a061636efb32 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 03:21:08 +0200 Subject: [PATCH 22/43] Give `CoinCopper` the collectible name `&Copper` --- entity/coin_copper.tscn | 1 + 1 file changed, 1 insertion(+) diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index 6deddd0..c3538a8 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -31,3 +31,4 @@ texture_filter = 1 texture = ExtResource("2_2ifq3") [node name="Collectible" parent="." instance=ExtResource("4_yefrx")] +type = &"Copper" From cf3cef96e449c306927690f680e1abd0fd15e053 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 13:09:07 +0200 Subject: [PATCH 23/43] Configure VSCode things --- .vscode/extensions.json | 5 +++++ .vscode/settings.json | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..2948ac0 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "geequlim.godot-tools", + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..71e1197 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "files.exclude": { + ".godot": true, + "**/*.godot": true, + "**/*.tres": true, + "**/*.tscn": true, + "**/*.import": true, + }, + "files.associations": { + "*.gdignore": "ignore", + }, + "editor.insertSpaces": false, +} From 73ede51027d778796596106a6602dcb7272ed7ec Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 14:39:16 +0200 Subject: [PATCH 24/43] Begin creation of ShopUI --- game/game.tscn | 37 ++++++++ interface/game_container.tscn | 15 ++++ interface/game_ui.tscn | 45 ++++++++++ interface/interface_theme.tres | 6 ++ interface/purchasable_item.gd | 78 ++++++++++++++++ interface/purchasable_item.tscn | 115 ++++++++++++++++++++++++ interface/purchasable_item_padding.tscn | 6 ++ interface/shop_ui.gd | 2 + interface/shop_ui.tscn | 63 +++++++++++++ root.tscn | 96 +++----------------- 10 files changed, 377 insertions(+), 86 deletions(-) create mode 100644 game/game.tscn create mode 100644 interface/game_container.tscn create mode 100644 interface/game_ui.tscn create mode 100644 interface/interface_theme.tres create mode 100644 interface/purchasable_item.gd create mode 100644 interface/purchasable_item.tscn create mode 100644 interface/purchasable_item_padding.tscn create mode 100644 interface/shop_ui.gd create mode 100644 interface/shop_ui.tscn diff --git a/game/game.tscn b/game/game.tscn new file mode 100644 index 0000000..7d567d1 --- /dev/null +++ b/game/game.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=5 format=3 uid="uid://c3rxmcwa5nqng"] + +[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"] + +[node name="Game" type="Node2D"] +texture_filter = 1 + +[node name="Bottle" parent="." instance=ExtResource("1_y7o2l")] + +[node name="GravityFromGyro" parent="Bottle" instance=ExtResource("2_h2pfr")] + +[node name="TimeSpawner" parent="." instance=ExtResource("3_qwsty")] +position = Vector2(0, -480) +scene = ExtResource("4_e5nwi") +buffer_cap = 1 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +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) +scene = ExtResource("4_e5nwi") +buffer_cap = 50 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"] diff --git a/interface/game_container.tscn b/interface/game_container.tscn new file mode 100644 index 0000000..ecbeb0b --- /dev/null +++ b/interface/game_container.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=2 format=3 uid="uid://mfa1v4fsnupp"] + +[ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="1_dbqdv"] + +[node name="GameContainer" type="Control"] +layout_mode = 3 +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="." instance=ExtResource("1_dbqdv")] diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn new file mode 100644 index 0000000..468f291 --- /dev/null +++ b/interface/game_ui.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=2 format=3 uid="uid://bo5unrhqpoyim"] + +[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_ppf8y"] + +[node name="Rows" type="VBoxContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_ppf8y") + +[node name="UpperButtons" type="HBoxContainer" parent="."] +custom_minimum_size = Vector2(0, 54) +layout_mode = 2 +size_flags_vertical = 8 +alignment = 1 + +[node name="MoneyButton" type="Button" parent="UpperButtons"] +custom_minimum_size = Vector2(72, 0) +layout_mode = 2 +size_flags_horizontal = 0 +text = "$0" +alignment = 0 + +[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="SpawnButton" type="Button" parent="UpperButtons"] +custom_minimum_size = Vector2(72, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "Drop" + +[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ShopButton" type="Button" parent="UpperButtons"] +custom_minimum_size = Vector2(72, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Shop" +alignment = 2 diff --git a/interface/interface_theme.tres b/interface/interface_theme.tres new file mode 100644 index 0000000..7381328 --- /dev/null +++ b/interface/interface_theme.tres @@ -0,0 +1,6 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://ba5utvfhnxa5i"] + +[ext_resource type="FontFile" uid="uid://cs8tiwyb76gig" path="res://font/press-start/prstart.ttf" id="1_mtdor"] + +[resource] +default_font = ExtResource("1_mtdor") diff --git a/interface/purchasable_item.gd b/interface/purchasable_item.gd new file mode 100644 index 0000000..a0fe873 --- /dev/null +++ b/interface/purchasable_item.gd @@ -0,0 +1,78 @@ +extends Panel +class_name PurchasableItem + +## Name of the item that can be purchased. +@export var item_name: String: + get: + return item_name + set(value): + item_name = value + $Contents/Header/NameLabel.text = value + +## Description of the item that can be purchased. +@export var item_description: String: + get: + return item_description + set(value): + item_description = value + $Contents/Header/DescriptionLabel.text = value + +## Text to be displayed on the cost label of the item. +@export var item_cost_text: String: + get: + return item_cost_text + set(value): + item_cost_text = value + $Contents/Action/CostLabel.text = value + +## Collectible type of the item required to buy the item. +@export var item_cost_type: StringName + +## Amount of items of the given type to collect to buy the item. +@export var item_cost_goal: int + +## Whether the player can click or not the Buy button. +## +## Used to prevent two items from getting bought at the same time. +@export var can_buy: bool: + get: + return can_buy + set(value): + can_buy = value + $Contents/Action/BuyButton.disabled = not can_buy + +## Whether the player is currently buying this item. +## +## Used to cancel the purchase. +var is_buying: bool: + get: + return is_buying + set(value): + is_buying = value + $Contents/Action/BuyButton.text = "Cancel" if value else "Buy" + + +## Emitted when a purchase has started. +signal purchase_begin + +## Emitted when a purchase is cancelled. +signal purchase_cancel + +## Emitted when a purchase is completed. +## +## Emitted by complete_purchase(). +signal purchase_success + + +func _on_buy_button_pressed(): + if is_buying: + is_buying = false + purchase_cancel.emit() + else: + is_buying = true + purchase_begin.emit() + + +func complete_purchase(): + is_buying = false + purchase_success.emit() \ No newline at end of file diff --git a/interface/purchasable_item.tscn b/interface/purchasable_item.tscn new file mode 100644 index 0000000..af7ba38 --- /dev/null +++ b/interface/purchasable_item.tscn @@ -0,0 +1,115 @@ +[gd_scene load_steps=3 format=3 uid="uid://dul1fpyh733t7"] + +[ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="1_drwcj"] +[ext_resource type="Script" path="res://interface/purchasable_item.gd" id="1_h8jix"] + +[node name="PurchasableItem" type="Panel"] +custom_minimum_size = Vector2(0, 182) +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +size_flags_horizontal = 3 +script = ExtResource("1_h8jix") + +[node name="Contents" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="HeaderPaddingTop" type="Control" parent="Contents"] +custom_minimum_size = Vector2(0, 4) +layout_mode = 2 + +[node name="Header" type="HBoxContainer" parent="Contents"] +layout_mode = 2 +size_flags_vertical = 8 + +[node name="IconPaddingLeft" type="Control" parent="Contents/Header"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="IconRect" type="TextureRect" parent="Contents/Header"] +custom_minimum_size = Vector2(54, 54) +layout_mode = 2 +texture = ExtResource("1_drwcj") +expand_mode = 2 + +[node name="IconNameSeparator" type="Control" parent="Contents/Header"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="NameLabel" type="Label" parent="Contents/Header"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 20 +text = "Garasaut" +uppercase = true + +[node name="NamePaddingRight" type="Control" parent="Contents/Header"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="HeaderDescriptionPadding" type="Control" parent="Contents"] +custom_minimum_size = Vector2(0, 4) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Description" type="HBoxContainer" parent="Contents"] +layout_mode = 2 +size_flags_vertical = 4 + +[node name="DescriptionPaddingLeft" type="Control" parent="Contents/Description"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="DescriptionLabel" type="Label" parent="Contents/Description"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 12 +text = "Garasa tutte le auto della zona per ottenere upgrade" +autowrap_mode = 2 + +[node name="DescriptionPaddingRight" type="Control" parent="Contents/Description"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="DescriptionActionPadding" type="Control" parent="Contents"] +custom_minimum_size = Vector2(0, 4) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Action" type="HBoxContainer" parent="Contents"] +layout_mode = 2 +size_flags_vertical = 0 + +[node name="BuyButtonPaddingLeft" type="Control" parent="Contents/Action"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="BuyButton" type="Button" parent="Contents/Action"] +layout_mode = 2 +text = "Buy" + +[node name="BuyCostPadding" type="Control" parent="Contents/Action"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="CostLabel" type="Label" parent="Contents/Action"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_font_sizes/font_size = 8 +text = "3 copper coins" +vertical_alignment = 1 + +[node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"] +custom_minimum_size = Vector2(8, 0) +layout_mode = 2 + +[node name="ActionPaddingBottom" type="Control" parent="Contents"] +custom_minimum_size = Vector2(0, 4) +layout_mode = 2 + +[connection signal="pressed" from="Contents/Action/BuyButton" to="." method="_on_buy_button_pressed"] diff --git a/interface/purchasable_item_padding.tscn b/interface/purchasable_item_padding.tscn new file mode 100644 index 0000000..a249774 --- /dev/null +++ b/interface/purchasable_item_padding.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://wodgj6rp2ewm"] + +[node name="PurchasableItemPadding" type="Control"] +custom_minimum_size = Vector2(0, 8) +layout_mode = 3 +anchors_preset = 0 diff --git a/interface/shop_ui.gd b/interface/shop_ui.gd new file mode 100644 index 0000000..1a5bf66 --- /dev/null +++ b/interface/shop_ui.gd @@ -0,0 +1,2 @@ +extends Panel +class_name ShopUI diff --git a/interface/shop_ui.tscn b/interface/shop_ui.tscn new file mode 100644 index 0000000..23f99ab --- /dev/null +++ b/interface/shop_ui.tscn @@ -0,0 +1,63 @@ +[gd_scene load_steps=4 format=3 uid="uid://cklkdygv61bny"] + +[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_qdf0y"] +[ext_resource type="PackedScene" uid="uid://dul1fpyh733t7" path="res://interface/purchasable_item.tscn" id="2_2dtc0"] +[ext_resource type="PackedScene" uid="uid://wodgj6rp2ewm" path="res://interface/purchasable_item_padding.tscn" id="3_4feaj"] + +[node name="ShopUI" type="Panel"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_qdf0y") + +[node name="Rows" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="UpperButtons" type="HBoxContainer" parent="Rows"] +custom_minimum_size = Vector2(0, 54) +layout_mode = 2 + +[node name="MoneyButton" type="Button" parent="Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 0 +text = "$0" +alignment = 0 + +[node name="UpperButtonsSpacer" type="PanelContainer" parent="Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="BackButton" type="Button" parent="Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Back" +alignment = 2 + +[node name="Scrollable" type="ScrollContainer" parent="Rows"] +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 +vertical_scroll_mode = 2 + +[node name="ScrollableItems" type="VBoxContainer" parent="Rows/Scrollable"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +layout_mode = 2 diff --git a/root.tscn b/root.tscn index 0884c6b..0b7c961 100644 --- a/root.tscn +++ b/root.tscn @@ -1,13 +1,14 @@ [gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] -[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] -[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] -[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] -[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] +[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://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"] [node name="UI" type="Control" parent="."] +texture_filter = 1 layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -15,90 +16,13 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 size_flags_vertical = 8 +theme = ExtResource("1_h26ax") -[node name="GameContainer" type="Control" parent="UI"] +[node name="GameContainer" parent="UI" instance=ExtResource("1_xjgvu")] 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" type="Node2D" parent="UI/GameContainer"] -texture_filter = 1 - -[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] - -[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] - -[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 1 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] -wait_time = 0.03 -autostart = true - -[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 50 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Rows" type="VBoxContainer" parent="UI"] +[node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")] layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"] -custom_minimum_size = Vector2(0, 54) -layout_mode = 2 -size_flags_vertical = 8 - -[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "$0" -alignment = 0 - -[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Drop" - -[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Shop" -alignment = 2 - -[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] -[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] +[node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] +layout_mode = 1 From 94fef9e231a750e72d408a0c49089349bec9360a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 14:43:38 +0200 Subject: [PATCH 25/43] Default can_buy to true --- interface/purchasable_item.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/purchasable_item.gd b/interface/purchasable_item.gd index a0fe873..c130b48 100644 --- a/interface/purchasable_item.gd +++ b/interface/purchasable_item.gd @@ -34,7 +34,7 @@ class_name PurchasableItem ## Whether the player can click or not the Buy button. ## ## Used to prevent two items from getting bought at the same time. -@export var can_buy: bool: +@export var can_buy: bool = true: get: return can_buy set(value): From 3f59b56aa83dc3848527f2bcd552230df4e72c4c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 14:50:47 +0200 Subject: [PATCH 26/43] Add configurable icon to PurchasableItem --- interface/purchasable_item.gd | 23 ++++++++++++++++++++--- interface/purchasable_item.tscn | 6 +++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/interface/purchasable_item.gd b/interface/purchasable_item.gd index c130b48..817e5fb 100644 --- a/interface/purchasable_item.gd +++ b/interface/purchasable_item.gd @@ -1,6 +1,14 @@ extends Panel class_name PurchasableItem +## Icon of the item that can be purchased. +@export var item_icon: Texture2D: + get: + return item_icon + set(value): + item_icon = value + $Contents/Header/IconRect.texture = item_icon + ## Name of the item that can be purchased. @export var item_name: String: get: @@ -39,7 +47,17 @@ class_name PurchasableItem return can_buy set(value): can_buy = value - $Contents/Action/BuyButton.disabled = not can_buy + $Contents/Action/BuyButton.disabled = not (can_buy && has_unlocked) + +## Whether the player has unlocked this item for purchase. +## +## Used to force the player to follow the tech tree. +@export var has_unlocked: bool = true: + get: + return has_unlocked + set(value): + has_unlocked = value + $Contents/Action/BuyButton.disabled = not (can_buy && has_unlocked) ## Whether the player is currently buying this item. ## @@ -72,7 +90,6 @@ func _on_buy_button_pressed(): is_buying = true purchase_begin.emit() - func complete_purchase(): is_buying = false - purchase_success.emit() \ No newline at end of file + purchase_success.emit() diff --git a/interface/purchasable_item.tscn b/interface/purchasable_item.tscn index af7ba38..b4ab008 100644 --- a/interface/purchasable_item.tscn +++ b/interface/purchasable_item.tscn @@ -45,7 +45,7 @@ layout_mode = 2 layout_mode = 2 size_flags_horizontal = 3 theme_override_font_sizes/font_size = 20 -text = "Garasaut" +text = "ITEMNAME" uppercase = true [node name="NamePaddingRight" type="Control" parent="Contents/Header"] @@ -69,7 +69,7 @@ layout_mode = 2 layout_mode = 2 size_flags_horizontal = 3 theme_override_font_sizes/font_size = 12 -text = "Garasa tutte le auto della zona per ottenere upgrade" +text = "What does this item do? Nobody knows." autowrap_mode = 2 [node name="DescriptionPaddingRight" type="Control" parent="Contents/Description"] @@ -101,7 +101,7 @@ layout_mode = 2 layout_mode = 2 size_flags_horizontal = 3 theme_override_font_sizes/font_size = 8 -text = "3 copper coins" +text = "3 fiorygi" vertical_alignment = 1 [node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"] From 350501f9d86fbff7220e97c64114a38249a4c3e4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:06:23 +0200 Subject: [PATCH 27/43] Script shop UI --- interface/shop_ui.gd | 60 ++++++++++++++++++++++++++++++++++++++++++ interface/shop_ui.tscn | 33 +++++++++++++++++++---- 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/interface/shop_ui.gd b/interface/shop_ui.gd index 1a5bf66..bb948ac 100644 --- a/interface/shop_ui.gd +++ b/interface/shop_ui.gd @@ -1,2 +1,62 @@ extends Panel 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 + +## Emitted when any purchase has started. +signal purchase_begin(what: PurchasableItem) + +## Emitted when any purchase is cancelled. +signal purchase_cancel(what: PurchasableItem) + +## Emitted when any purchase is completed. +## +## Emitted by complete_purchase(). +signal purchase_success(what: PurchasableItem) + +## Array of all PurchasableItems that this ShopUI should control. +@onready var purchasable_items: Array[PurchasableItem] = find_children("*", "PurchasableItem") as Array[PurchasableItem] + + +func _ready(): + for item in purchasable_items: + item.purchase_begin.connect(_on_any_purchase_begin.bind(item)) + item.purchase_cancel.connect(_on_any_purchase_cancel.bind(item)) + item.purchase_success.connect(_on_any_purchase_success.bind(item)) + +func _on_any_purchase_begin(what: PurchasableItem): + purchase_begin.emit(what) + for item in purchasable_items: + if item == what: + continue + item.can_buy = false + +func _on_any_purchase_cancel(what: PurchasableItem): + purchase_cancel.emit(what) + for item in purchasable_items: + if item == what: + continue + item.can_buy = true + +func _on_any_purchase_success(what: PurchasableItem): + purchase_success.emit(what) + for item in purchasable_items: + if item == what: + continue + item.can_buy = true + +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() diff --git a/interface/shop_ui.tscn b/interface/shop_ui.tscn index 23f99ab..7d4078e 100644 --- a/interface/shop_ui.tscn +++ b/interface/shop_ui.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://cklkdygv61bny"] +[gd_scene load_steps=5 format=3 uid="uid://cklkdygv61bny"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_qdf0y"] [ext_resource type="PackedScene" uid="uid://dul1fpyh733t7" path="res://interface/purchasable_item.tscn" id="2_2dtc0"] +[ext_resource type="Script" path="res://interface/shop_ui.gd" id="2_iyr7m"] [ext_resource type="PackedScene" uid="uid://wodgj6rp2ewm" path="res://interface/purchasable_item_padding.tscn" id="3_4feaj"] [node name="ShopUI" type="Panel"] @@ -11,6 +12,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_qdf0y") +script = ExtResource("2_iyr7m") [node name="Rows" type="VBoxContainer" parent="."] layout_mode = 1 @@ -24,19 +26,29 @@ grow_vertical = 2 custom_minimum_size = Vector2(0, 54) layout_mode = 2 -[node name="MoneyButton" type="Button" parent="Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) +[node name="ScoreButton" type="Button" parent="Rows/UpperButtons"] +custom_minimum_size = Vector2(72, 0) layout_mode = 2 size_flags_horizontal = 0 text = "$0" alignment = 0 -[node name="UpperButtonsSpacer" type="PanelContainer" parent="Rows/UpperButtons"] +[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="DeleteButton" type="Button" parent="Rows/UpperButtons"] +custom_minimum_size = Vector2(72, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "Del" + +[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="Rows/UpperButtons"] layout_mode = 2 size_flags_horizontal = 3 [node name="BackButton" type="Button" parent="Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) +custom_minimum_size = Vector2(72, 0) layout_mode = 2 size_flags_horizontal = 8 text = "Back" @@ -61,3 +73,14 @@ layout_mode = 2 [node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] layout_mode = 2 + +[node name="PurchasableItemPadding2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem3" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +layout_mode = 2 +has_unlocked = false + +[connection signal="pressed" from="Rows/UpperButtons/ScoreButton" to="." method="_on_score_button_pressed"] +[connection signal="pressed" from="Rows/UpperButtons/DeleteButton" to="." method="_on_delete_button_pressed"] +[connection signal="pressed" from="Rows/UpperButtons/BackButton" to="." method="_on_back_button_pressed"] From 8450c1a3f4dcff402a45d82183d99ab3005e9a0a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:06:32 +0200 Subject: [PATCH 28/43] Rename MoneyButton to ScoreButton --- interface/game_ui.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index 468f291..8b28f6a 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -2,7 +2,7 @@ [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_ppf8y"] -[node name="Rows" type="VBoxContainer"] +[node name="GameUI" type="VBoxContainer"] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -16,7 +16,7 @@ layout_mode = 2 size_flags_vertical = 8 alignment = 1 -[node name="MoneyButton" type="Button" parent="UpperButtons"] +[node name="ScoreButton" type="Button" parent="UpperButtons"] custom_minimum_size = Vector2(72, 0) layout_mode = 2 size_flags_horizontal = 0 From e554eab63a11a19888c8f4037b272f002dda76ca Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:11:21 +0200 Subject: [PATCH 29/43] Use control for padding in GameUI --- interface/game_ui.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index 8b28f6a..6fd44b8 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -23,7 +23,7 @@ size_flags_horizontal = 0 text = "$0" alignment = 0 -[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UpperButtons"] +[node name="UpperButtonsSpacerLeft" type="Control" parent="UpperButtons"] layout_mode = 2 size_flags_horizontal = 3 @@ -33,7 +33,7 @@ layout_mode = 2 size_flags_horizontal = 4 text = "Drop" -[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UpperButtons"] +[node name="UpperButtonsSpacerRight" type="Control" parent="UpperButtons"] layout_mode = 2 size_flags_horizontal = 3 From b1a8752c9f7e3984c709b7b80f14ecb805fb79e5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:11:43 +0200 Subject: [PATCH 30/43] Make assertions over node type on _on_any_purchase handlers --- interface/shop_ui.gd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/interface/shop_ui.gd b/interface/shop_ui.gd index bb948ac..b17c66c 100644 --- a/interface/shop_ui.gd +++ b/interface/shop_ui.gd @@ -22,7 +22,7 @@ signal purchase_cancel(what: PurchasableItem) signal purchase_success(what: PurchasableItem) ## Array of all PurchasableItems that this ShopUI should control. -@onready var purchasable_items: Array[PurchasableItem] = find_children("*", "PurchasableItem") as Array[PurchasableItem] +@onready var purchasable_items: Array[Node] = find_children("*", "PurchasableItem") as Array[Node] func _ready(): @@ -31,21 +31,30 @@ func _ready(): item.purchase_cancel.connect(_on_any_purchase_cancel.bind(item)) item.purchase_success.connect(_on_any_purchase_success.bind(item)) -func _on_any_purchase_begin(what: PurchasableItem): +func _on_any_purchase_begin(what: Node): + if not what is PurchasableItem: + push_error("Purchase began outside a PurchasableItem") + return purchase_begin.emit(what) for item in purchasable_items: if item == what: continue item.can_buy = false -func _on_any_purchase_cancel(what: PurchasableItem): +func _on_any_purchase_cancel(what: Node): + if not what is PurchasableItem: + push_error("Purchase cancelled outside a PurchasableItem") + return purchase_cancel.emit(what) for item in purchasable_items: if item == what: continue item.can_buy = true -func _on_any_purchase_success(what: PurchasableItem): +func _on_any_purchase_success(what: Node): + if not what is PurchasableItem: + push_error("Purchase succeeded outside a PurchasableItem") + return purchase_success.emit(what) for item in purchasable_items: if item == what: From c1ac869d1bb333f7f5b515270bb98b6155a5f029 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:12:00 +0200 Subject: [PATCH 31/43] Script root node --- root.gd | 2 ++ root.tscn | 1 + 2 files changed, 3 insertions(+) create mode 100644 root.gd diff --git a/root.gd b/root.gd new file mode 100644 index 0000000..7b2d3f7 --- /dev/null +++ b/root.gd @@ -0,0 +1,2 @@ +extends Node +class_name Root diff --git a/root.tscn b/root.tscn index 0b7c961..11054fb 100644 --- a/root.tscn +++ b/root.tscn @@ -25,4 +25,5 @@ layout_mode = 1 layout_mode = 1 [node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] +visible = false layout_mode = 1 From 4cd407dd1ea641340a89b7a1e5299c8d54c669b5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:15:16 +0200 Subject: [PATCH 32/43] Give a class_name to GameUI --- interface/game_ui.gd | 2 ++ interface/game_ui.tscn | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 interface/game_ui.gd diff --git a/interface/game_ui.gd b/interface/game_ui.gd new file mode 100644 index 0000000..26f93c8 --- /dev/null +++ b/interface/game_ui.gd @@ -0,0 +1,2 @@ +extends VBoxContainer +class_name GameUI diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index 6fd44b8..0ae256a 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=3 uid="uid://bo5unrhqpoyim"] +[gd_scene load_steps=3 format=3 uid="uid://bo5unrhqpoyim"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_ppf8y"] +[ext_resource type="Script" path="res://interface/game_ui.gd" id="2_33nqa"] [node name="GameUI" type="VBoxContainer"] anchors_preset = 15 @@ -9,6 +10,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_ppf8y") +script = ExtResource("2_33nqa") [node name="UpperButtons" type="HBoxContainer" parent="."] custom_minimum_size = Vector2(0, 54) From 39a0310a53a0654cbca9eb9e2d1d011752a8c27c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:31:49 +0200 Subject: [PATCH 33/43] Implement UI state switching and pausing --- interface/game_ui.gd | 19 +++++++++++++++++ interface/game_ui.tscn | 4 ++++ root.gd | 47 ++++++++++++++++++++++++++++++++++++++++++ root.tscn | 15 ++++++++++++-- 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/interface/game_ui.gd b/interface/game_ui.gd index 26f93c8..5717b98 100644 --- a/interface/game_ui.gd +++ b/interface/game_ui.gd @@ -1,2 +1,21 @@ extends VBoxContainer class_name GameUI + +## Emitted when the Score button is pressed. +signal score_button_pressed + +## Emitted when the Spawn button is pressed. +signal spawn_button_pressed + +## Emitted when the Shop button is presesd. +signal shop_button_pressed + + +func _on_score_button_pressed(): + score_button_pressed.emit() + +func _on_spawn_button_pressed(): + spawn_button_pressed.emit() + +func _on_shop_button_pressed(): + shop_button_pressed.emit() diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index 0ae256a..13b44fb 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -45,3 +45,7 @@ layout_mode = 2 size_flags_horizontal = 8 text = "Shop" alignment = 2 + +[connection signal="pressed" from="UpperButtons/ScoreButton" to="." method="_on_score_button_pressed"] +[connection signal="pressed" from="UpperButtons/SpawnButton" to="." method="_on_spawn_button_pressed"] +[connection signal="pressed" from="UpperButtons/ShopButton" to="." method="_on_shop_button_pressed"] diff --git a/root.gd b/root.gd index 7b2d3f7..d48e6e9 100644 --- a/root.gd +++ b/root.gd @@ -1,2 +1,49 @@ extends Node class_name Root + + +@onready var tree: SceneTree = get_tree() +@onready var game_ui: GameUI = $UI/GameUI +@onready var shop_ui: ShopUI = $UI/ShopUI + + +enum UIState { + GAME, + SHOP, + SCORE, +} + +@export var ui_state: UIState: + get: + return ui_state + set(value): + match value: + UIState.GAME: + tree.paused = false + game_ui.show() + shop_ui.hide() + UIState.SHOP: + tree.paused = true + game_ui.hide() + shop_ui.show() + UIState.SCORE: + pass + + +func _on_game_ui_score_button_pressed(): + ui_state = UIState.SCORE + +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 + +func _on_game_ui_shop_button_pressed(): + ui_state = UIState.SHOP + +func _on_game_ui_spawn_button_pressed(): + pass # Replace with function body. diff --git a/root.tscn b/root.tscn index 11054fb..e2b50af 100644 --- a/root.tscn +++ b/root.tscn @@ -1,11 +1,13 @@ -[gd_scene load_steps=5 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="PackedScene" uid="uid://mfa1v4fsnupp" path="res://interface/game_container.tscn" id="1_xjgvu"] [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") [node name="UI" type="Control" parent="."] texture_filter = 1 @@ -19,11 +21,20 @@ size_flags_vertical = 8 theme = ExtResource("1_h26ax") [node name="GameContainer" parent="UI" instance=ExtResource("1_xjgvu")] +process_mode = 1 layout_mode = 1 [node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")] +process_mode = 3 layout_mode = 1 [node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] -visible = false +process_mode = 3 layout_mode = 1 + +[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="score_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"] From 07eb7f330b41c2a29df630a51539d7c5833629a3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 15:40:42 +0200 Subject: [PATCH 34/43] Reconnect button spawner --- game/game.gd | 9 +++++++++ game/game.tscn | 6 +++--- interface/game_container.tscn | 2 +- root.gd | 3 ++- root.tscn | 14 ++++++++++++-- 5 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 game/game.gd 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 From cd6a051e27cca806d71018c0e93fc3e14e2542de Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 11:37:38 +0200 Subject: [PATCH 35/43] new branch with experimental valuable e evaluator --- Convertitore.gd | 19 ------------------- convertitore.tscn | 2 +- value/evaluator.gd | 30 ++++++++++++++++++++++++++++++ value/evaluator.tscn | 10 ++++++++++ value/valuable.gd | 10 ++++++++++ value/valuable.tscn | 6 ++++++ 6 files changed, 57 insertions(+), 20 deletions(-) delete mode 100644 Convertitore.gd create mode 100644 value/evaluator.gd create mode 100644 value/evaluator.tscn create mode 100644 value/valuable.gd create mode 100644 value/valuable.tscn diff --git a/Convertitore.gd b/Convertitore.gd deleted file mode 100644 index fd728c5..0000000 --- a/Convertitore.gd +++ /dev/null @@ -1,19 +0,0 @@ -extends Node2D -var conta_soldi: int = 0 - -# 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 - - -func _on_ingresso_body_shape_entered(body_rid, body, body_shape_index, local_shape_index): - body.queue_free() - conta_soldi+=1 - if conta_soldi>=10: - conta_soldi=0 - diff --git a/convertitore.tscn b/convertitore.tscn index 95f36ae..a4b80f1 100644 --- a/convertitore.tscn +++ b/convertitore.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3 uid="uid://d34gt53jcq1uw"] +[gd_scene load_steps=3 format=3 uid="uid://ei1b0ity3nwg"] [ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"] [ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"] diff --git a/value/evaluator.gd b/value/evaluator.gd new file mode 100644 index 0000000..a16124f --- /dev/null +++ b/value/evaluator.gd @@ -0,0 +1,30 @@ +extends Area2D +class_name Evaluator +## aggiunge al totale i valori dei Valuable che ci body_enterano e sottrae quelli che ci body_exitano + + +## The current amount of value evaluated. +var total_value: int = 0 + +## The types of [Collectible]s to value. +## +## The strings will match only if exactly the same. +@export var collecting_types: Array[StringName] + +## The collision mask to check colliding body against. +@export_flags_2d_physics var collecting_collision_mask: int + + +## The evaluator has added the value of an object. +signal added(what: PhysicsBody2D) + +## The evaluator has removed the value of an object. +signal removed(what: PhysicsBody2D) + + +func _on_body_entered(body: Node2D): + pass + + + + diff --git a/value/evaluator.tscn b/value/evaluator.tscn new file mode 100644 index 0000000..5016a5e --- /dev/null +++ b/value/evaluator.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://beg758fa6o0cs"] + +[ext_resource type="Script" path="res://value/evaluator.gd" id="1_sjx78"] + +[node name="Evaluator" type="Node2D"] +script = ExtResource("1_sjx78") + +[node name="Area2D" type="Area2D" parent="."] + +[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/value/valuable.gd b/value/valuable.gd new file mode 100644 index 0000000..a5e8162 --- /dev/null +++ b/value/valuable.gd @@ -0,0 +1,10 @@ +extends Node +class_name Valuable + +@export var value: int + +#signal object_value +# +# +#func collect(): +# emit_signal("collected") diff --git a/value/valuable.tscn b/value/valuable.tscn new file mode 100644 index 0000000..6a66261 --- /dev/null +++ b/value/valuable.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://ujpra0s1kpqi"] + +[ext_resource type="Script" path="res://value/valuable.gd" id="1_mr62g"] + +[node name="Valuable" type="Node2D"] +script = ExtResource("1_mr62g") From bd3a764a807f9ea44981047ed939d5a35b1cc876 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 11:56:18 +0200 Subject: [PATCH 36/43] made randomizer (still empty) --- random/randomizer.gd | 11 +++++++++++ random/randomizer.tscn | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 random/randomizer.gd create mode 100644 random/randomizer.tscn diff --git a/random/randomizer.gd b/random/randomizer.gd new file mode 100644 index 0000000..58577cf --- /dev/null +++ b/random/randomizer.gd @@ -0,0 +1,11 @@ +extends Node2D + + +# 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/random/randomizer.tscn b/random/randomizer.tscn new file mode 100644 index 0000000..cd30c30 --- /dev/null +++ b/random/randomizer.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cldl3smm1c2pm"] + +[ext_resource type="Script" path="res://random/randomizer.gd" id="1_nvy1v"] + +[node name="Randomizer" type="Node2D"] +script = ExtResource("1_nvy1v") From abc6b0665489ebd9cb67c9374987634acd1f0b9e Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 11:56:54 +0200 Subject: [PATCH 37/43] trying to test collector and collectible --- collector/collectible.tscn | 5 ++++- collector/collector.gd | 2 ++ collector/collector.tscn | 9 ++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/collector/collectible.tscn b/collector/collectible.tscn index 7f6b2a1..0713a93 100644 --- a/collector/collectible.tscn +++ b/collector/collectible.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://bk1vvq5rug01m"] +[gd_scene load_steps=3 format=3 uid="uid://bk1vvq5rug01m"] [ext_resource type="Script" path="res://collector/collectible.gd" id="1_qilbk"] +[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="2_2nvfu"] [node name="Collectible" type="Node"] script = ExtResource("1_qilbk") + +[node name="Valuable" parent="." instance=ExtResource("2_2nvfu")] diff --git a/collector/collector.gd b/collector/collector.gd index c9a4266..1f80778 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -31,9 +31,11 @@ func _on_body_entered(body: Node2D): if body.collision_layer & collecting_collision_mask: var collectible: Collectible = body.get_node("Collectible") if collectible.type in collecting_types: + print("collezionato") collected_count += 1 collectible.collect() emit_signal("collected", body) if collected_count >= collecting_amount: + print("goal") emit_signal("goal") collected_count = 0 diff --git a/collector/collector.tscn b/collector/collector.tscn index 0273735..85a12d3 100644 --- a/collector/collector.tscn +++ b/collector/collector.tscn @@ -1,8 +1,15 @@ -[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"] +[gd_scene load_steps=3 format=3 uid="uid://c5w3b55aiui6c"] [ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vcox2"] +size = Vector2(113, 65) + [node name="Collector" type="Area2D"] script = ExtResource("1_1xtt5") +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(87.5, 48.5) +shape = SubResource("RectangleShape2D_vcox2") + [connection signal="body_entered" from="." to="." method="_on_body_entered"] From b84c1781c11a48f38de73367d2c23f27b09cb6e0 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 14:43:52 +0200 Subject: [PATCH 38/43] valuable and evaluator works (enough) --- collector/collector.tscn | 9 +-------- entity/coin_copper.tscn | 6 +++++- root.tscn | 2 +- value/evaluator.gd | 33 ++++++++++++++++++++++----------- value/evaluator.tscn | 7 +++---- value/valuable.gd | 13 ++++++++----- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/collector/collector.tscn b/collector/collector.tscn index 85a12d3..0273735 100644 --- a/collector/collector.tscn +++ b/collector/collector.tscn @@ -1,15 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://c5w3b55aiui6c"] +[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"] [ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_vcox2"] -size = Vector2(113, 65) - [node name="Collector" type="Area2D"] script = ExtResource("1_1xtt5") -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(87.5, 48.5) -shape = SubResource("RectangleShape2D_vcox2") - [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/entity/coin_copper.tscn b/entity/coin_copper.tscn index c3538a8..20fb5ea 100644 --- a/entity/coin_copper.tscn +++ b/entity/coin_copper.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://c3kitncwpi42j"] +[gd_scene load_steps=7 format=3 uid="uid://c3kitncwpi42j"] [ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="1_8k46m"] [ext_resource type="Texture2D" uid="uid://dbdkb4vt7dh85" path="res://entity/coin_copper_4.png" id="1_wedw1"] [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"] [ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="4_yefrx"] +[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_jdvvd"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] size = Vector2(16, 5) @@ -32,3 +33,6 @@ texture = ExtResource("2_2ifq3") [node name="Collectible" parent="." instance=ExtResource("4_yefrx")] type = &"Copper" + +[node name="Valuable" parent="." instance=ExtResource("5_jdvvd")] +value = 1 diff --git a/root.tscn b/root.tscn index 139e6aa..4f716d2 100644 --- a/root.tscn +++ b/root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=9 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"] diff --git a/value/evaluator.gd b/value/evaluator.gd index a16124f..3a2cd07 100644 --- a/value/evaluator.gd +++ b/value/evaluator.gd @@ -9,22 +9,33 @@ var total_value: int = 0 ## The types of [Collectible]s to value. ## ## The strings will match only if exactly the same. -@export var collecting_types: Array[StringName] +#@export var collecting_types: Array[StringName] ## The collision mask to check colliding body against. @export_flags_2d_physics var collecting_collision_mask: int - -## The evaluator has added the value of an object. +## The evaluator has added the value of an object to the total. signal added(what: PhysicsBody2D) - -## The evaluator has removed the value of an object. +## The evaluator has removed the value of an object to the total. signal removed(what: PhysicsBody2D) - -func _on_body_entered(body: Node2D): - pass - - - +func _on_body_entered(body): + if body is PhysicsBody2D: + if body.collision_layer & collecting_collision_mask: + var evaluable: Valuable = body.get_node("Valuable") + print("sommato") + total_value += evaluable.value + evaluable.evaluate() + added.emit(body) + print("totale= "+str(total_value)) + +func _on_body_exited(body): + if body is PhysicsBody2D: + if body.collision_layer & collecting_collision_mask: + var evaluable: Valuable = body.get_node("Valuable") + print("sottratto") + total_value -= evaluable.value + evaluable.evaluate() + added.emit(body) + print("totale= "+str(total_value)) diff --git a/value/evaluator.tscn b/value/evaluator.tscn index 5016a5e..e797c93 100644 --- a/value/evaluator.tscn +++ b/value/evaluator.tscn @@ -2,9 +2,8 @@ [ext_resource type="Script" path="res://value/evaluator.gd" id="1_sjx78"] -[node name="Evaluator" type="Node2D"] +[node name="Evaluator" type="Area2D"] script = ExtResource("1_sjx78") -[node name="Area2D" type="Area2D" parent="."] - -[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] +[connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="body_exited" from="." to="." method="_on_body_exited"] diff --git a/value/valuable.gd b/value/valuable.gd index a5e8162..ef50710 100644 --- a/value/valuable.gd +++ b/value/valuable.gd @@ -3,8 +3,11 @@ class_name Valuable @export var value: int -#signal object_value -# -# -#func collect(): -# emit_signal("collected") +## Emitted when this entity has been counted. +signal evaluated + +## Mark this entity as evaluated. +## +func evaluate(): + emit_signal("evaluated") + From aa2cf6612b6bdc76f986cd8dcb5f303654d963ec Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 15:32:23 +0200 Subject: [PATCH 39/43] adddded debug scoreboard and changes collector.gd --- Game.gd | 6 ++ roo767B.tmp | 129 ++++++++++++++++++++++++++++++++++++++++++ roo84C2.tmp | 129 ++++++++++++++++++++++++++++++++++++++++++ root.tscn | 2 +- score/scoreboard.gd | 14 +++++ score/scoreboard.tscn | 23 ++++++++ value/evaluator.gd | 8 ++- 7 files changed, 307 insertions(+), 4 deletions(-) create mode 100644 Game.gd create mode 100644 roo767B.tmp create mode 100644 roo84C2.tmp create mode 100644 score/scoreboard.gd create mode 100644 score/scoreboard.tscn diff --git a/Game.gd b/Game.gd new file mode 100644 index 0000000..19d7435 --- /dev/null +++ b/Game.gd @@ -0,0 +1,6 @@ +extends Node2D + + +func _process(delta): + print($Evaluator.total_value) + diff --git a/roo767B.tmp b/roo767B.tmp new file mode 100644 index 0000000..84f07d4 --- /dev/null +++ b/roo767B.tmp @@ -0,0 +1,129 @@ +[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"] + +[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] +[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"] +[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] +[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] +[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] +[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"] +[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"] +size = Vector2(72, 38) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"] +size = Vector2(222, 43) + +[node name="Root" type="Node"] + +[node name="UI" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 8 + +[node name="GameContainer" type="Control" parent="UI"] +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" type="Node2D" parent="UI/GameContainer"] +texture_filter = 1 +script = ExtResource("1_sabvy") + +[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] + +[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] + +[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 1 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] +wait_time = 0.03 +autostart = true + +[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 50 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")] +position = Vector2(-92, -257) +collecting_types = Array[StringName]([&"Copper"]) + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"] +position = Vector2(26, 9) +shape = SubResource("RectangleShape2D_5xpy2") + +[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")] +collecting_collision_mask = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"] +position = Vector2(0, -38.5) +shape = SubResource("RectangleShape2D_5mxpe") + +[node name="Rows" type="VBoxContainer" parent="UI"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"] +custom_minimum_size = Vector2(0, 54) +layout_mode = 2 +size_flags_vertical = 8 + +[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "$0" +alignment = 0 + +[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Drop" + +[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Shop" +alignment = 2 + +[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] diff --git a/roo84C2.tmp b/roo84C2.tmp new file mode 100644 index 0000000..84f07d4 --- /dev/null +++ b/roo84C2.tmp @@ -0,0 +1,129 @@ +[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"] + +[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] +[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"] +[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] +[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] +[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] +[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"] +[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"] +size = Vector2(72, 38) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"] +size = Vector2(222, 43) + +[node name="Root" type="Node"] + +[node name="UI" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 8 + +[node name="GameContainer" type="Control" parent="UI"] +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" type="Node2D" parent="UI/GameContainer"] +texture_filter = 1 +script = ExtResource("1_sabvy") + +[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] + +[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] + +[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 1 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] +wait_time = 0.03 +autostart = true + +[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] +position = Vector2(0, -480) +scene = ExtResource("2_dv01l") +buffer_cap = 50 +spawn_position_range_x = 32.0 +spawn_rotation_range = 15.0 +overlapping_bodies_collision_mask = 4 +overlapping_body_count_limit = 4 + +[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")] +position = Vector2(-92, -257) +collecting_types = Array[StringName]([&"Copper"]) + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"] +position = Vector2(26, 9) +shape = SubResource("RectangleShape2D_5xpy2") + +[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")] +collecting_collision_mask = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"] +position = Vector2(0, -38.5) +shape = SubResource("RectangleShape2D_5mxpe") + +[node name="Rows" type="VBoxContainer" parent="UI"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"] +custom_minimum_size = Vector2(0, 54) +layout_mode = 2 +size_flags_vertical = 8 + +[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "$0" +alignment = 0 + +[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Drop" + +[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"] +custom_minimum_size = Vector2(54, 0) +layout_mode = 2 +size_flags_horizontal = 8 +text = "Shop" +alignment = 2 + +[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] +[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] diff --git a/root.tscn b/root.tscn index 4f716d2..eb5ba6d 100644 --- a/root.tscn +++ b/root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=11 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"] diff --git a/score/scoreboard.gd b/score/scoreboard.gd new file mode 100644 index 0000000..d822fd5 --- /dev/null +++ b/score/scoreboard.gd @@ -0,0 +1,14 @@ +extends Control + +class_name ScoreBoard + +@export var score: int = 0 + +func _ready(): + $Label.text = "Score: " + str(score) + +func _process(delta): + pass + +func _on_evaluator_score_changed(total_value): + $Label.text = "Score: " + str(total_value) diff --git a/score/scoreboard.tscn b/score/scoreboard.tscn new file mode 100644 index 0000000..659e8e6 --- /dev/null +++ b/score/scoreboard.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=2 format=3 uid="uid://bokcnc0q0qqj3"] + +[ext_resource type="Script" path="res://score/scoreboard.gd" id="1_of77n"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_of77n") + +[node name="Label" type="Label" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 23.0 +text = "SCORE: " + +[node name="VSlider" type="VSlider" parent="."] +layout_mode = 0 +offset_right = 16.0 +offset_bottom = 8.0 diff --git a/value/evaluator.gd b/value/evaluator.gd index 3a2cd07..9492ef4 100644 --- a/value/evaluator.gd +++ b/value/evaluator.gd @@ -15,10 +15,12 @@ var total_value: int = 0 @export_flags_2d_physics var collecting_collision_mask: int ## The evaluator has added the value of an object to the total. -signal added(what: PhysicsBody2D) +signal added(what: PhysicsBody2D, total_value: int) ## The evaluator has removed the value of an object to the total. signal removed(what: PhysicsBody2D) +signal score_changed(total_value: int) + func _on_body_entered(body): if body is PhysicsBody2D: if body.collision_layer & collecting_collision_mask: @@ -26,7 +28,7 @@ func _on_body_entered(body): print("sommato") total_value += evaluable.value evaluable.evaluate() - added.emit(body) + score_changed.emit(total_value) print("totale= "+str(total_value)) func _on_body_exited(body): @@ -36,6 +38,6 @@ func _on_body_exited(body): print("sottratto") total_value -= evaluable.value evaluable.evaluate() - added.emit(body) + score_changed.emit(total_value) print("totale= "+str(total_value)) From b40cc2d6278c82b5b6ec49be716a105da7ee0864 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 16:09:43 +0200 Subject: [PATCH 40/43] add randomizer and roller --- Game.gd | 8 +++++--- bottle/bottle.gd | 11 +++++++++++ collector/collector.gd | 2 -- random/randomizer.gd | 14 +++----------- random/randomizer.tscn | 2 +- random/roller.gd | 14 ++++++++++++++ random/roller.tscn | 6 ++++++ root.tscn | 2 +- value/evaluator.gd | 4 ---- 9 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 bottle/bottle.gd create mode 100644 random/roller.gd create mode 100644 random/roller.tscn diff --git a/Game.gd b/Game.gd index 19d7435..3a8cf79 100644 --- a/Game.gd +++ b/Game.gd @@ -1,6 +1,8 @@ extends Node2D +func _on_roller_failure(): + print("failure") -func _process(delta): - print($Evaluator.total_value) - + +func _on_roller_success(): + print("success") diff --git a/bottle/bottle.gd b/bottle/bottle.gd new file mode 100644 index 0000000..7edbaf4 --- /dev/null +++ b/bottle/bottle.gd @@ -0,0 +1,11 @@ +extends TileMap + + +# 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/collector/collector.gd b/collector/collector.gd index 1f80778..c9a4266 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -31,11 +31,9 @@ func _on_body_entered(body: Node2D): if body.collision_layer & collecting_collision_mask: var collectible: Collectible = body.get_node("Collectible") if collectible.type in collecting_types: - print("collezionato") collected_count += 1 collectible.collect() emit_signal("collected", body) if collected_count >= collecting_amount: - print("goal") emit_signal("goal") collected_count = 0 diff --git a/random/randomizer.gd b/random/randomizer.gd index 58577cf..1446f43 100644 --- a/random/randomizer.gd +++ b/random/randomizer.gd @@ -1,11 +1,3 @@ -extends Node2D - - -# 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 +extends Node +class_name Randomizer +static var rng : RandomNumberGenerator = RandomNumberGenerator.new() diff --git a/random/randomizer.tscn b/random/randomizer.tscn index cd30c30..d199a94 100644 --- a/random/randomizer.tscn +++ b/random/randomizer.tscn @@ -2,5 +2,5 @@ [ext_resource type="Script" path="res://random/randomizer.gd" id="1_nvy1v"] -[node name="Randomizer" type="Node2D"] +[node name="Randomizer" type="Node"] script = ExtResource("1_nvy1v") diff --git a/random/roller.gd b/random/roller.gd new file mode 100644 index 0000000..07587c0 --- /dev/null +++ b/random/roller.gd @@ -0,0 +1,14 @@ +extends Node2D + +@export_range(0,1) var slider : float = 0 + +signal success() + +signal failure() + +func roll(): + if Randomizer.rng.randf() < slider: + success.emit() + else: + failure.emit() + diff --git a/random/roller.tscn b/random/roller.tscn new file mode 100644 index 0000000..7c34586 --- /dev/null +++ b/random/roller.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dvgxb0ichkoe7"] + +[ext_resource type="Script" path="res://random/roller.gd" id="1_vetpi"] + +[node name="Roller" type="Node2D"] +script = ExtResource("1_vetpi") diff --git a/root.tscn b/root.tscn index eb5ba6d..4366dc9 100644 --- a/root.tscn +++ b/root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=12 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"] diff --git a/value/evaluator.gd b/value/evaluator.gd index 9492ef4..62040fb 100644 --- a/value/evaluator.gd +++ b/value/evaluator.gd @@ -25,19 +25,15 @@ func _on_body_entered(body): if body is PhysicsBody2D: if body.collision_layer & collecting_collision_mask: var evaluable: Valuable = body.get_node("Valuable") - print("sommato") total_value += evaluable.value evaluable.evaluate() score_changed.emit(total_value) - print("totale= "+str(total_value)) func _on_body_exited(body): if body is PhysicsBody2D: if body.collision_layer & collecting_collision_mask: var evaluable: Valuable = body.get_node("Valuable") - print("sottratto") total_value -= evaluable.value evaluable.evaluate() score_changed.emit(total_value) - print("totale= "+str(total_value)) From e5f7c773533fd804ab99452a4d5d7f243563c0c4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 16:43:09 +0200 Subject: [PATCH 41/43] Remove weird temporary files --- roo767B.tmp | 129 ---------------------------------------------------- roo84C2.tmp | 129 ---------------------------------------------------- 2 files changed, 258 deletions(-) delete mode 100644 roo767B.tmp delete mode 100644 roo84C2.tmp diff --git a/roo767B.tmp b/roo767B.tmp deleted file mode 100644 index 84f07d4..0000000 --- a/roo767B.tmp +++ /dev/null @@ -1,129 +0,0 @@ -[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"] - -[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] -[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"] -[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] -[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] -[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] -[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"] -[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"] -size = Vector2(72, 38) - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"] -size = Vector2(222, 43) - -[node name="Root" type="Node"] - -[node name="UI" type="Control" parent="."] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -size_flags_vertical = 8 - -[node name="GameContainer" type="Control" parent="UI"] -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" type="Node2D" parent="UI/GameContainer"] -texture_filter = 1 -script = ExtResource("1_sabvy") - -[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] - -[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] - -[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 1 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] -wait_time = 0.03 -autostart = true - -[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 50 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")] -position = Vector2(-92, -257) -collecting_types = Array[StringName]([&"Copper"]) - -[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"] -position = Vector2(26, 9) -shape = SubResource("RectangleShape2D_5xpy2") - -[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")] -collecting_collision_mask = 4 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"] -position = Vector2(0, -38.5) -shape = SubResource("RectangleShape2D_5mxpe") - -[node name="Rows" type="VBoxContainer" parent="UI"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"] -custom_minimum_size = Vector2(0, 54) -layout_mode = 2 -size_flags_vertical = 8 - -[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "$0" -alignment = 0 - -[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Drop" - -[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Shop" -alignment = 2 - -[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] -[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] diff --git a/roo84C2.tmp b/roo84C2.tmp deleted file mode 100644 index 84f07d4..0000000 --- a/roo84C2.tmp +++ /dev/null @@ -1,129 +0,0 @@ -[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"] - -[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] -[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"] -[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] -[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] -[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] -[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"] -[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"] -size = Vector2(72, 38) - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"] -size = Vector2(222, 43) - -[node name="Root" type="Node"] - -[node name="UI" type="Control" parent="."] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -size_flags_vertical = 8 - -[node name="GameContainer" type="Control" parent="UI"] -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" type="Node2D" parent="UI/GameContainer"] -texture_filter = 1 -script = ExtResource("1_sabvy") - -[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")] - -[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")] - -[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 1 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"] -wait_time = 0.03 -autostart = true - -[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")] -position = Vector2(0, -480) -scene = ExtResource("2_dv01l") -buffer_cap = 50 -spawn_position_range_x = 32.0 -spawn_rotation_range = 15.0 -overlapping_bodies_collision_mask = 4 -overlapping_body_count_limit = 4 - -[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")] -position = Vector2(-92, -257) -collecting_types = Array[StringName]([&"Copper"]) - -[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"] -position = Vector2(26, 9) -shape = SubResource("RectangleShape2D_5xpy2") - -[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")] -collecting_collision_mask = 4 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"] -position = Vector2(0, -38.5) -shape = SubResource("RectangleShape2D_5mxpe") - -[node name="Rows" type="VBoxContainer" parent="UI"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"] -custom_minimum_size = Vector2(0, 54) -layout_mode = 2 -size_flags_vertical = 8 - -[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "$0" -alignment = 0 - -[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Drop" - -[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"] -custom_minimum_size = Vector2(54, 0) -layout_mode = 2 -size_flags_horizontal = 8 -text = "Shop" -alignment = 2 - -[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"] -[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"] From 6b96f2ae2c4dfff6dc8768f22d7cf963ae345158 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 16:43:21 +0200 Subject: [PATCH 42/43] Configure initial state --- interface/purchasable_item.tscn | 13 ++-- interface/shop_ui.tscn | 109 ++++++++++++++++++++++++++++++-- root.gd | 3 + root.tscn | 4 +- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/interface/purchasable_item.tscn b/interface/purchasable_item.tscn index b4ab008..e1ef5f6 100644 --- a/interface/purchasable_item.tscn +++ b/interface/purchasable_item.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://dul1fpyh733t7"] +[gd_scene load_steps=4 format=3 uid="uid://dul1fpyh733t7"] [ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="1_drwcj"] [ext_resource type="Script" path="res://interface/purchasable_item.gd" id="1_h8jix"] +[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_r2qbu"] [node name="PurchasableItem" type="Panel"] custom_minimum_size = Vector2(0, 182) @@ -9,6 +10,7 @@ anchors_preset = 10 anchor_right = 1.0 grow_horizontal = 2 size_flags_horizontal = 3 +theme = ExtResource("1_r2qbu") script = ExtResource("1_h8jix") [node name="Contents" type="VBoxContainer" parent="."] @@ -44,7 +46,7 @@ layout_mode = 2 [node name="NameLabel" type="Label" parent="Contents/Header"] layout_mode = 2 size_flags_horizontal = 3 -theme_override_font_sizes/font_size = 20 +theme_override_font_sizes/font_size = 16 text = "ITEMNAME" uppercase = true @@ -68,7 +70,7 @@ layout_mode = 2 [node name="DescriptionLabel" type="Label" parent="Contents/Description"] layout_mode = 2 size_flags_horizontal = 3 -theme_override_font_sizes/font_size = 12 +theme_override_font_sizes/font_size = 16 text = "What does this item do? Nobody knows." autowrap_mode = 2 @@ -99,9 +101,10 @@ layout_mode = 2 [node name="CostLabel" type="Label" parent="Contents/Action"] layout_mode = 2 -size_flags_horizontal = 3 -theme_override_font_sizes/font_size = 8 +size_flags_horizontal = 10 +theme_override_font_sizes/font_size = 16 text = "3 fiorygi" +horizontal_alignment = 2 vertical_alignment = 1 [node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"] diff --git a/interface/shop_ui.tscn b/interface/shop_ui.tscn index 7d4078e..279e6f3 100644 --- a/interface/shop_ui.tscn +++ b/interface/shop_ui.tscn @@ -33,7 +33,7 @@ size_flags_horizontal = 0 text = "$0" alignment = 0 -[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="Rows/UpperButtons"] +[node name="UpperButtonsSpacerLeft" type="Control" parent="Rows/UpperButtons"] layout_mode = 2 size_flags_horizontal = 3 @@ -43,7 +43,7 @@ layout_mode = 2 size_flags_horizontal = 4 text = "Del" -[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="Rows/UpperButtons"] +[node name="UpperButtonsSpacerRight" type="Control" parent="Rows/UpperButtons"] layout_mode = 2 size_flags_horizontal = 3 @@ -65,22 +65,117 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +[node name="ConvertCategory" type="VBoxContainer" parent="Rows/Scrollable/ScrollableItems"] layout_mode = 2 -[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("3_4feaj")] +[node name="PurchasableItemPadding5" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] layout_mode = 2 -[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +[node name="EarnCoinsLabel" type="Label" parent="Rows/Scrollable/ScrollableItems/ConvertCategory"] +layout_mode = 2 +theme_override_font_sizes/font_size = 24 +text = "Convert your coins" +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 +uppercase = true + +[node name="PurchasableItemPadding3" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] layout_mode = 2 -[node name="PurchasableItemPadding2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("3_4feaj")] +[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("2_2dtc0")] layout_mode = 2 -[node name="PurchasableItem3" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")] +[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding2" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem3" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("2_2dtc0")] layout_mode = 2 has_unlocked = false +[node name="PurchasableItemPadding4" parent="Rows/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="ManualCategory" type="VBoxContainer" parent="Rows/Scrollable/ScrollableItems"] +layout_mode = 2 + +[node name="PurchasableItemPadding5" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="EarnCoinsLabel" type="Label" parent="Rows/Scrollable/ScrollableItems/ManualCategory"] +layout_mode = 2 +theme_override_font_sizes/font_size = 24 +text = "Automatic coin dropper" +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 +uppercase = true + +[node name="PurchasableItemPadding3" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding2" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem3" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 +has_unlocked = false + +[node name="PurchasableItemPadding4" parent="Rows/Scrollable/ScrollableItems/ManualCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="AutomaticCategory" type="VBoxContainer" parent="Rows/Scrollable/ScrollableItems"] +layout_mode = 2 + +[node name="PurchasableItemPadding5" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="EarnCoinsLabel" type="Label" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory"] +layout_mode = 2 +theme_override_font_sizes/font_size = 24 +text = "Automatic coin dropper" +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 +uppercase = true + +[node name="PurchasableItemPadding3" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 + +[node name="PurchasableItemPadding2" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + +[node name="PurchasableItem3" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("2_2dtc0")] +layout_mode = 2 +has_unlocked = false + +[node name="PurchasableItemPadding4" parent="Rows/Scrollable/ScrollableItems/AutomaticCategory" instance=ExtResource("3_4feaj")] +layout_mode = 2 + [connection signal="pressed" from="Rows/UpperButtons/ScoreButton" to="." method="_on_score_button_pressed"] [connection signal="pressed" from="Rows/UpperButtons/DeleteButton" to="." method="_on_delete_button_pressed"] [connection signal="pressed" from="Rows/UpperButtons/BackButton" to="." method="_on_back_button_pressed"] diff --git a/root.gd b/root.gd index 9256a51..9ba5ed7 100644 --- a/root.gd +++ b/root.gd @@ -48,3 +48,6 @@ func _on_game_ui_shop_button_pressed(): 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 4366dc9..21da5ee 100644 --- a/root.tscn +++ b/root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 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"] @@ -8,7 +8,6 @@ [node name="Root" type="Node"] script = ExtResource("1_8jrhk") -ui_state = null [node name="UI" type="Control" parent="."] texture_filter = 1 @@ -40,6 +39,7 @@ layout_mode = 1 [node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] process_mode = 3 +visible = false layout_mode = 1 [connection signal="score_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_score_button_pressed"] From 0295a7bf739b11716111e08279dabd5905d5e609 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 1 Oct 2023 16:47:48 +0200 Subject: [PATCH 43/43] Add missing signal connection --- root.tscn | 1 + 1 file changed, 1 insertion(+) diff --git a/root.tscn b/root.tscn index 21da5ee..46ff088 100644 --- a/root.tscn +++ b/root.tscn @@ -47,4 +47,5 @@ layout_mode = 1 [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"]