diff --git a/Game.gd b/Game.gd deleted file mode 100644 index 3a8cf79..0000000 --- a/Game.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Node2D - -func _on_roller_failure(): - print("failure") - - -func _on_roller_success(): - print("success") diff --git a/entity/coin_copper/coin_copper.gd b/entity/coin_copper/coin_copper.gd index 5a4a116..594d523 100644 --- a/entity/coin_copper/coin_copper.gd +++ b/entity/coin_copper/coin_copper.gd @@ -23,11 +23,8 @@ func _on_sleeping_state_changed(): was_sleeping = true func _on_body_entered(body): - - print("touch") if not was_sleeping: if touched==false and $Timer.is_stopped(): - print(str(self)+" hits "+str(body)) #$sound_touch.play() $Timer.start() var other_node=body diff --git a/entity/gem/diamond_white.png b/entity/gem/diamond_white.png new file mode 100644 index 0000000..c0f893e --- /dev/null +++ b/entity/gem/diamond_white.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:937d739b1e72393dc14bf96eb627660f4f9f63f3a2200437210910527e6374bf +size 4456 diff --git a/entity/gem/diamond_white.png.import b/entity/gem/diamond_white.png.import new file mode 100644 index 0000000..937ac9d --- /dev/null +++ b/entity/gem/diamond_white.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgq5afrrpc4a3" +path="res://.godot/imported/diamond_white.png-ea17eba66708a2de5eae13c889056729.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gem/diamond_white.png" +dest_files=["res://.godot/imported/diamond_white.png-ea17eba66708a2de5eae13c889056729.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_back.png.import b/entity/gold_converter_back.png.import new file mode 100644 index 0000000..dc5bd0d --- /dev/null +++ b/entity/gold_converter_back.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://chc8wqc1pclbk" +path="res://.godot/imported/gold_converter_back.png-542530d6d643b64e20755f9b54d1da49.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_back.png" +dest_files=["res://.godot/imported/gold_converter_back.png-542530d6d643b64e20755f9b54d1da49.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_front_1.png.import b/entity/gold_converter_front_1.png.import new file mode 100644 index 0000000..4d62cdc --- /dev/null +++ b/entity/gold_converter_front_1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dgw5ip5qf5k7a" +path="res://.godot/imported/gold_converter_front_1.png-20d40342907ebeaf5453b3fbc06f6b04.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_front_1.png" +dest_files=["res://.godot/imported/gold_converter_front_1.png-20d40342907ebeaf5453b3fbc06f6b04.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_front_2.png.import b/entity/gold_converter_front_2.png.import new file mode 100644 index 0000000..c9ca2b5 --- /dev/null +++ b/entity/gold_converter_front_2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://h7hu4paxjq84" +path="res://.godot/imported/gold_converter_front_2.png-6b48a8121d01d35430dedd6a7ebaaed7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_front_2.png" +dest_files=["res://.godot/imported/gold_converter_front_2.png-6b48a8121d01d35430dedd6a7ebaaed7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_front_3.png.import b/entity/gold_converter_front_3.png.import new file mode 100644 index 0000000..1004753 --- /dev/null +++ b/entity/gold_converter_front_3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dlog0f5nk4b3c" +path="res://.godot/imported/gold_converter_front_3.png-4b8a07d186c945c584be92c7bbbf79b8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_front_3.png" +dest_files=["res://.godot/imported/gold_converter_front_3.png-4b8a07d186c945c584be92c7bbbf79b8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_front_4.png.import b/entity/gold_converter_front_4.png.import new file mode 100644 index 0000000..ca131bc --- /dev/null +++ b/entity/gold_converter_front_4.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cj5m5k0hr3wmw" +path="res://.godot/imported/gold_converter_front_4.png-1dd90efaf325965268d803bbed7fda3b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_front_4.png" +dest_files=["res://.godot/imported/gold_converter_front_4.png-1dd90efaf325965268d803bbed7fda3b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/gold_converter_front_5.png.import b/entity/gold_converter_front_5.png.import new file mode 100644 index 0000000..e30df37 --- /dev/null +++ b/entity/gold_converter_front_5.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b5uershakuq20" +path="res://.godot/imported/gold_converter_front_5.png-a825d75eb13b041b1a6213049c3d7637.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/gold_converter_front_5.png" +dest_files=["res://.godot/imported/gold_converter_front_5.png-a825d75eb13b041b1a6213049c3d7637.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_chalice.png.import b/entity/item_chalice.png.import new file mode 100644 index 0000000..38ad128 --- /dev/null +++ b/entity/item_chalice.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://wpen8vmuyvqv" +path="res://.godot/imported/item_chalice.png-7c6bf5aba6af81724e4a9b47b0fa9097.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_chalice.png" +dest_files=["res://.godot/imported/item_chalice.png-7c6bf5aba6af81724e4a9b47b0fa9097.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_chalice_gems.png.import b/entity/item_chalice_gems.png.import new file mode 100644 index 0000000..4fe9136 --- /dev/null +++ b/entity/item_chalice_gems.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dvthocklcjh15" +path="res://.godot/imported/item_chalice_gems.png-182c84a35d2925a897cade98742ac714.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_chalice_gems.png" +dest_files=["res://.godot/imported/item_chalice_gems.png-182c84a35d2925a897cade98742ac714.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_crown.png.import b/entity/item_crown.png.import new file mode 100644 index 0000000..bae9b5b --- /dev/null +++ b/entity/item_crown.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://brlo5pqo0x86l" +path="res://.godot/imported/item_crown.png-b1fdb9663d17347d4fbd39044017f645.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_crown.png" +dest_files=["res://.godot/imported/item_crown.png-b1fdb9663d17347d4fbd39044017f645.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_crown_gems.png.import b/entity/item_crown_gems.png.import new file mode 100644 index 0000000..4e8af5f --- /dev/null +++ b/entity/item_crown_gems.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://l7kr24oe0fc8" +path="res://.godot/imported/item_crown_gems.png-57e99547b8bc3470cb75cd17193c0abd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_crown_gems.png" +dest_files=["res://.godot/imported/item_crown_gems.png-57e99547b8bc3470cb75cd17193c0abd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_ring.png.import b/entity/item_ring.png.import new file mode 100644 index 0000000..7b32cbf --- /dev/null +++ b/entity/item_ring.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcw3cq3ni253t" +path="res://.godot/imported/item_ring.png-a4f5983b41259568642782622b1a92ac.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_ring.png" +dest_files=["res://.godot/imported/item_ring.png-a4f5983b41259568642782622b1a92ac.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/entity/item_ring_gems.png.import b/entity/item_ring_gems.png.import new file mode 100644 index 0000000..148080e --- /dev/null +++ b/entity/item_ring_gems.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dnfkvj0usdb6n" +path="res://.godot/imported/item_ring_gems.png-15fb2caf015b721a6fe6cd5c86878289.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://entity/item_ring_gems.png" +dest_files=["res://.godot/imported/item_ring_gems.png-15fb2caf015b721a6fe6cd5c86878289.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/game.gd b/game/game.gd index 3b80e00..50144c4 100644 --- a/game/game.gd +++ b/game/game.gd @@ -55,7 +55,6 @@ func _on_purchase_success(what: PurchasableItem): store_collector_panel.hide() func _on_store_collector_collected(_body: RigidBody2D): - print("collected") update_counter_text() func update_counter_text(): @@ -76,4 +75,3 @@ func update_counter_icon(): store_collector_texturerect.texture = upgrade_gold_texture else: store_collector_texturerect.texture = null - diff --git a/game/game.tscn b/game/game.tscn index 1a1d92f..2d8c926 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -11,11 +11,12 @@ [ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="7_hh80i"] [ext_resource type="PackedScene" uid="uid://ratkps4plkhl" path="res://converters/copper_to_silver/copper_converter.tscn" id="7_ipeok"] [ext_resource type="PackedScene" uid="uid://but1bdslxp5jl" path="res://converters/silver_to_gold/silver_converter.tscn" id="8_0bbpi"] +[ext_resource type="PackedScene" path="res://entity/gem/gem.tscn" id="8_a3sk0"] [ext_resource type="PackedScene" uid="uid://c2rlx7egl7xiv" path="res://collector/universal_collector.tscn" id="9_7op48"] [ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="9_evdhb"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="10_sayqn"] [ext_resource type="Texture2D" uid="uid://c8pvjgtr2ufjl" path="res://interface/upgrade_copper.png" id="11_lt33g"] -[ext_resource type="PackedScene" uid="uid://c4ew8x4gch275" path="res://converters/gold_to_gem/gem_converter.tscn" id="16_e62br"] +[ext_resource type="PackedScene" uid="uid://qtk4tm6l367w" path="res://interface/ghost.tscn" id="16_8vhx6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_4uksi"] size = Vector2(80, 80) @@ -39,11 +40,16 @@ upgrade_copper_texture = ExtResource("11_lt33g") upgrade_silver_texture = ExtResource("3_8wvr1") upgrade_gold_texture = ExtResource("4_i557v") +[node name="Ghost" parent="." instance=ExtResource("16_8vhx6")] +position = Vector2(90, 306) +collision_layer = 8 +collision_mask = 6 + [node name="Bottle" parent="." instance=ExtResource("1_y7o2l")] [node name="TimeSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(136, 0) -scene = ExtResource("7_hh80i") +scene = ExtResource("8_a3sk0") target = NodePath("..") buffer_cap = 1 spawn_rect = Rect2(-20, 0, 40, 0) @@ -81,7 +87,7 @@ shape = SubResource("RectangleShape2D_rh35r") debug_color = Color(0, 0.6, 0.701961, 0) [node name="CopperConverter" parent="." instance=ExtResource("7_ipeok")] -position = Vector2(53, 156) +position = Vector2(62, 176) metadata/_edit_group_ = true [node name="Spawner" parent="CopperConverter" index="6" node_paths=PackedStringArray("target")] @@ -91,12 +97,8 @@ target = NodePath("../..") position = Vector2(0, 4.08333) [node name="SilverConverter" parent="." instance=ExtResource("8_0bbpi")] -position = Vector2(53, 273) -rotation = -6.28319 -metadata/_edit_group_ = true - -[node name="CollectShape" parent="SilverConverter/Collector" index="1"] -metadata/_edit_group_ = true +position = Vector2(205, 337) +rotation = -3.14159 [node name="Spawner" parent="SilverConverter" index="6" node_paths=PackedStringArray("target")] target = NodePath("../..") @@ -178,10 +180,6 @@ position = Vector2(405, 540) shape = SubResource("RectangleShape2D_jed57") debug_color = Color(0, 0, 0, 0.419608) -[node name="GemConverter" parent="." instance=ExtResource("16_e62br")] -position = Vector2(144, 184) -metadata/_edit_group_ = true - [connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"] [connection signal="changed" from="Evaluator" to="." method="_on_score_changed"] [connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"] diff --git a/game_camera.gd b/game_camera.gd new file mode 100644 index 0000000..db9a853 --- /dev/null +++ b/game_camera.gd @@ -0,0 +1,20 @@ +extends Camera2D +class_name GameCamera + + +func set_camera_position(scaling_factor: float): + var cutouts: Array[Rect2] = DisplayServer.get_display_cutouts() + + var bottom + + if len(cutouts) == 0: + bottom = 8 + else: + var screen: Vector2i = DisplayServer.screen_get_size() + var rect: Rect2i = DisplayServer.get_display_safe_area() + bottom = max(8, screen.y - rect.end.y) + + print("[GameCamera] Bottom margin is: ", bottom) + + var size = get_window().size.y / scaling_factor + position.y = 480 - (size / 2) diff --git a/interface/custom_ui.gd b/interface/custom_ui.gd index f855da1..56cef5b 100644 --- a/interface/custom_ui.gd +++ b/interface/custom_ui.gd @@ -5,6 +5,10 @@ class_name CustomUI @onready var window: Window = get_window() @onready var viewport: Viewport = window.get_viewport() +@onready var game_safe_ui: MarginContainer = $GameSafeUI +@onready var shop_safe_ui: MarginContainer = $ShopSafeUI +@onready var game_camera: GameCamera = $GameViewport/Viewport/GameCamera + func _ready(): viewport.size_changed.connect(_on_viewport_size_changed) @@ -21,4 +25,6 @@ func _on_viewport_size_changed(): scaling_factor = window_size.y / 480 print("[View] Scaling factor is: ", scaling_factor) get_window().set_content_scale_factor(scaling_factor) - $SafeUI.set_safe_margins(scaling_factor) + game_safe_ui.set_safe_margins(scaling_factor) + shop_safe_ui.set_safe_margins(scaling_factor) + game_camera.set_camera_position(scaling_factor) diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index c8ee779..8eef1bf 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -5,12 +5,11 @@ [ext_resource type="PackedScene" uid="uid://bey5lilvteg32" path="res://interface/score_button.tscn" id="3_vobar"] [node name="GameUI" type="Control" node_paths=PackedStringArray("score_button")] +custom_minimum_size = Vector2(0, 54) layout_mode = 3 -anchors_preset = 15 +anchors_preset = 10 anchor_right = 1.0 -anchor_bottom = 1.0 grow_horizontal = 2 -grow_vertical = 2 theme = ExtResource("1_ppf8y") script = ExtResource("2_33nqa") score_button = NodePath("ScoreButton") @@ -18,7 +17,6 @@ score_button = NodePath("ScoreButton") [node name="ScoreButton" parent="." instance=ExtResource("3_vobar")] custom_minimum_size = Vector2(88, 0) layout_mode = 0 -text = "$0.00" [node name="SpawnButton" type="Button" parent="."] custom_minimum_size = Vector2(88, 0) diff --git a/interface/ghost.gd b/interface/ghost.gd new file mode 100644 index 0000000..36e5ca6 --- /dev/null +++ b/interface/ghost.gd @@ -0,0 +1,25 @@ +extends Area2D +class_name Ghost + +var is_dragging: bool +var previous_position: Vector2 + +func _input(event: InputEvent): + if event is InputEventMouseButton: + is_dragging = event.pressed + previous_position = event.position + elif event is InputEventScreenTouch: + is_dragging = event.pressed + previous_position = event.position + + if is_dragging: + if event is InputEventMouseMotion: + var delta = event.position - previous_position + print(delta) + position += delta + previous_position = event.position + elif event is InputEventScreenDrag: + var delta = event.position - previous_position + print(delta) + position += delta + previous_position = event.position diff --git a/interface/ghost.tscn b/interface/ghost.tscn new file mode 100644 index 0000000..cbf9850 --- /dev/null +++ b/interface/ghost.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=3 uid="uid://qtk4tm6l367w"] + +[ext_resource type="Script" path="res://interface/ghost.gd" id="1_gvls7"] +[ext_resource type="Texture2D" uid="uid://pj3ip6vlatms" path="res://converters/copper_to_silver/copper_converter.png" id="1_lo8gj"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_hmopu"] +size = Vector2(34, 34) + +[node name="Ghost" type="Area2D"] +scale = Vector2(3, 3) +input_pickable = false +script = ExtResource("1_gvls7") + +[node name="Sprite" type="Sprite2D" parent="."] +modulate = Color(1, 1, 1, 0.470588) +z_index = 10 +texture = ExtResource("1_lo8gj") + +[node name="Shape" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_hmopu") diff --git a/interface/safe_ui.gd b/interface/safe_ui.gd index 9ffca1e..2723f92 100644 --- a/interface/safe_ui.gd +++ b/interface/safe_ui.gd @@ -2,6 +2,12 @@ extends MarginContainer class_name SafeUI +@export var apply_margin_left: bool +@export var apply_margin_right: bool +@export var apply_margin_top: bool +@export var apply_margin_bottom: bool + + func set_safe_margins(scaling_factor: float): var cutouts: Array[Rect2] = DisplayServer.get_display_cutouts() @@ -18,16 +24,21 @@ func set_safe_margins(scaling_factor: float): else: var screen: Vector2i = DisplayServer.screen_get_size() var rect: Rect2i = DisplayServer.get_display_safe_area() - left = rect.position.x - right = screen.x - rect.end.x - top = rect.position.y - bottom = screen.y - rect.end.y + left = max(8, rect.position.x) + right = max(8, screen.x - rect.end.x) + top = max(8, rect.position.y) + bottom = max(8, screen.y - rect.end.y) print("[SafeUI] Left margin is: ", left) print("[SafeUI] Right margin is: ", right) print("[SafeUI] Top margin is: ", top) print("[SafeUI] Bottom margin is: ", bottom) - add_theme_constant_override("margin_left", left / scaling_factor) - add_theme_constant_override("margin_right", right / scaling_factor) - add_theme_constant_override("margin_top", top / scaling_factor) - add_theme_constant_override("margin_bottom", bottom / scaling_factor) + + if apply_margin_left: + add_theme_constant_override("margin_left", left / scaling_factor) + if apply_margin_right: + add_theme_constant_override("margin_right", right / scaling_factor) + if apply_margin_top: + add_theme_constant_override("margin_top", top / scaling_factor) + if apply_margin_bottom: + add_theme_constant_override("margin_bottom", bottom / scaling_factor) diff --git a/interface/safe_ui.tscn b/interface/safe_ui.tscn new file mode 100644 index 0000000..0c12da2 --- /dev/null +++ b/interface/safe_ui.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://e4be5wkya7g0"] + +[ext_resource type="Script" path="res://interface/safe_ui.gd" id="1_ceq6m"] + +[node name="SafeUI" type="MarginContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ceq6m") diff --git a/main.gd b/main.gd index 2cafc2b..4dbbc2b 100644 --- a/main.gd +++ b/main.gd @@ -3,8 +3,10 @@ class_name Main @onready var tree: SceneTree = get_tree() -@onready var game_ui: GameUI = $CustomUI/SafeUI/GameUI -@onready var shop_ui: ShopUI = $CustomUI/SafeUI/ShopUI +@onready var game_safe_ui: MarginContainer = $CustomUI/GameSafeUI +@onready var game_ui: GameUI = $CustomUI/GameSafeUI/GameUI +@onready var shop_safe_ui: MarginContainer = $CustomUI/ShopSafeUI +@onready var shop_ui: ShopUI = $CustomUI/ShopSafeUI/ShopUI enum UIState { @@ -20,12 +22,14 @@ enum UIState { match value: UIState.GAME: tree.paused = false - game_ui.show() - shop_ui.hide() + game_safe_ui.show() + shop_safe_ui.hide() + shop_safe_ui.process_mode = Node.PROCESS_MODE_DISABLED UIState.SHOP: tree.paused = true - game_ui.hide() - shop_ui.show() + game_safe_ui.hide() + shop_safe_ui.show() + shop_safe_ui.process_mode = Node.PROCESS_MODE_ALWAYS UIState.SCORE: pass diff --git a/main.tscn b/main.tscn index f2f2b89..2319e5f 100644 --- a/main.tscn +++ b/main.tscn @@ -1,12 +1,17 @@ -[gd_scene load_steps=8 format=3 uid="uid://dqm0h5h0baqcg"] +[gd_scene load_steps=10 format=3 uid="uid://dqm0h5h0baqcg"] [ext_resource type="Script" path="res://main.gd" id="1_fqt34"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_je7w1"] [ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="2_32lou"] [ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="2_qj86l"] [ext_resource type="Script" path="res://interface/custom_ui.gd" id="3_xav0n"] -[ext_resource type="Script" path="res://interface/safe_ui.gd" id="4_nel0n"] [ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="4_siim3"] +[ext_resource type="PackedScene" uid="uid://bpvx3nkkbluip" path="res://safe_ui.tscn" id="5_2uxda"] +[ext_resource type="Script" path="res://game_camera.gd" id="5_xxjtg"] + +[sub_resource type="GDScript" id="GDScript_kyj65"] +script/source = "extends SubViewport +" [node name="Main" type="Node"] script = ExtResource("1_fqt34") @@ -20,65 +25,68 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 size_flags_vertical = 8 +mouse_filter = 1 theme = ExtResource("1_je7w1") script = ExtResource("3_xav0n") -[node name="GameWorld" type="CenterContainer" parent="CustomUI"] -custom_minimum_size = Vector2(270, 480) -layout_mode = 1 -anchors_preset = 7 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -135.0 -offset_top = -480.0 -offset_right = 135.0 -grow_horizontal = 2 -grow_vertical = 0 - -[node name="GameViewport" type="SubViewportContainer" parent="CustomUI/GameWorld"] -layout_mode = 2 - -[node name="Viewport" type="SubViewport" parent="CustomUI/GameWorld/GameViewport"] -disable_3d = true -handle_input_locally = false -size = Vector2i(270, 480) -render_target_update_mode = 4 - -[node name="Game" parent="CustomUI/GameWorld/GameViewport/Viewport" instance=ExtResource("2_32lou")] - -[node name="Camera" type="Camera2D" parent="CustomUI/GameWorld/GameViewport/Viewport"] -anchor_mode = 0 - -[node name="SafeUI" type="MarginContainer" parent="CustomUI"] +[node name="GameViewport" type="SubViewportContainer" parent="CustomUI"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("4_nel0n") +mouse_default_cursor_shape = 5 +stretch = true -[node name="GameUI" parent="CustomUI/SafeUI" instance=ExtResource("4_siim3")] +[node name="Viewport" type="SubViewport" parent="CustomUI/GameViewport"] +disable_3d = true +handle_input_locally = false +physics_object_picking = true +size = Vector2i(270, 480) +render_target_update_mode = 4 +script = SubResource("GDScript_kyj65") + +[node name="Game" parent="CustomUI/GameViewport/Viewport" instance=ExtResource("2_32lou")] + +[node name="GameCamera" type="Camera2D" parent="CustomUI/GameViewport/Viewport"] +position = Vector2(135, 480) +script = ExtResource("5_xxjtg") + +[node name="GameSafeUI" parent="CustomUI" instance=ExtResource("5_2uxda")] +layout_mode = 1 +anchors_preset = 10 +anchor_bottom = 0.0 +grow_vertical = 1 +apply_margin_left = true +apply_margin_right = true +apply_margin_top = true + +[node name="GameUI" parent="CustomUI/GameSafeUI" instance=ExtResource("4_siim3")] layout_mode = 2 -[node name="ShopUI" parent="CustomUI/SafeUI" instance=ExtResource("2_qj86l")] -process_mode = 3 +[node name="ShopSafeUI" parent="CustomUI" instance=ExtResource("5_2uxda")] +process_mode = 4 visible = false +layout_mode = 1 +apply_margin_left = true +apply_margin_right = true +apply_margin_top = true +apply_margin_bottom = true + +[node name="ShopUI" parent="CustomUI/ShopSafeUI" instance=ExtResource("2_qj86l")] layout_mode = 2 -[connection signal="score_changed" from="CustomUI/GameWorld/GameViewport/Viewport/Game" to="CustomUI/SafeUI/GameUI" method="_on_game_score_changed"] -[connection signal="score_changed" from="CustomUI/GameWorld/GameViewport/Viewport/Game" to="CustomUI/SafeUI/ShopUI" method="_on_game_score_changed"] -[connection signal="score_button_pressed" from="CustomUI/SafeUI/GameUI" to="." method="_on_game_ui_score_button_pressed"] -[connection signal="shop_button_pressed" from="CustomUI/SafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] -[connection signal="spawn_button_pressed" from="CustomUI/SafeUI/GameUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="trigger_spawn"] -[connection signal="back_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] -[connection signal="delete_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] -[connection signal="purchase_begin" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"] -[connection signal="purchase_begin" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_begin"] -[connection signal="purchase_cancel" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_cancel"] -[connection signal="purchase_success" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_success"] -[connection signal="score_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"] -[connection signal="upgraded_auto_spawn" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_upgraded_auto_spawn"] -[connection signal="upgraded_manual_spawn" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_upgraded_manual_spawn"] +[connection signal="score_changed" from="CustomUI/GameViewport/Viewport/Game" to="CustomUI/GameSafeUI/GameUI" method="_on_game_score_changed"] +[connection signal="score_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="." method="_on_game_ui_score_button_pressed"] +[connection signal="shop_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] +[connection signal="spawn_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="CustomUI/GameViewport/Viewport/Game" method="trigger_spawn"] +[connection signal="back_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] +[connection signal="delete_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] +[connection signal="purchase_begin" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"] +[connection signal="purchase_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_begin"] +[connection signal="purchase_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_cancel"] +[connection signal="purchase_success" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_success"] +[connection signal="score_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"] +[connection signal="upgraded_auto_spawn" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_upgraded_auto_spawn"] +[connection signal="upgraded_manual_spawn" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_upgraded_manual_spawn"] diff --git a/project.godot b/project.godot index 2497f77..5fdf41d 100644 --- a/project.godot +++ b/project.godot @@ -30,6 +30,7 @@ window/handheld/orientation=1 2d_physics/layer_1="Default" 2d_physics/layer_2="Bottle" 2d_physics/layer_3="Entities" +2d_physics/layer_4="Ghost" [physics] diff --git a/safe_ui.tscn b/safe_ui.tscn new file mode 100644 index 0000000..9c2594e --- /dev/null +++ b/safe_ui.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://bpvx3nkkbluip"] + +[ext_resource type="Script" path="res://interface/safe_ui.gd" id="1_y2ofp"] + +[node name="SafeUI" type="MarginContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_y2ofp")