From 349d49a641f4ba9fc6923bae045c4a983ca0026e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 2 May 2024 02:32:14 +0200 Subject: [PATCH] Make cursor indicate the possible interaction --- behaviours/draggable.tscn | 4 +- behaviours/tracker.tscn | 2 +- entities/barn.gd | 3 +- entities/barn.tscn | 252 ++++++++++++++++++------------------- entities/chupacabra.gd | 4 +- entities/chupacabra.tscn | 4 +- entities/cthulhu.gd | 4 +- entities/cthulhu.tscn | 4 +- entities/gold.tscn | 2 - entities/imp.gd | 4 +- entities/imp.tscn | 4 +- entities/monocle.gd | 4 +- entities/monocle.tscn | 4 +- entities/sheep.gd | 4 +- entities/sheep.tscn | 5 +- entities/skull.gd | 4 +- entities/skull.tscn | 4 +- entities/top_hat.gd | 4 +- entities/top_hat.tscn | 5 +- entities/tree.tscn | 2 +- entities/watcher.tscn | 6 +- main.tscn | 1 + project.godot | 9 +- scenes/game/cursor.gd | 23 ++-- scenes/game/cursor.tscn | 4 +- scenes/game/main_game.tscn | 8 +- 26 files changed, 190 insertions(+), 184 deletions(-) diff --git a/behaviours/draggable.tscn b/behaviours/draggable.tscn index 659366f..3fe3100 100644 --- a/behaviours/draggable.tscn +++ b/behaviours/draggable.tscn @@ -3,8 +3,8 @@ [ext_resource type="Script" path="res://behaviours/draggable.gd" id="1_hdedq"] [node name="Draggable" type="Area2D"] -collision_layer = 8 -collision_mask = 0 +collision_layer = 0 +collision_mask = 128 input_pickable = false monitoring = false script = ExtResource("1_hdedq") diff --git a/behaviours/tracker.tscn b/behaviours/tracker.tscn index a2c6eec..650a383 100644 --- a/behaviours/tracker.tscn +++ b/behaviours/tracker.tscn @@ -4,7 +4,7 @@ [node name="Tracker" type="Area2D"] collision_layer = 0 -collision_mask = 56 +collision_mask = 24 input_pickable = false monitorable = false script = ExtResource("1_4joji") diff --git a/entities/barn.gd b/entities/barn.gd index 7875166..916edcf 100644 --- a/entities/barn.gd +++ b/entities/barn.gd @@ -9,6 +9,7 @@ signal coin_inserted @onready var blocked_tracker: Tracker = %"BlockedTracker" @onready var animator: AnimationPlayer = %"Animator" @onready var game := MainGame.get_via_group(self) +@onready var viewport := get_viewport() func _on_roof_input(_viewport: Node, event: InputEvent, _shape_idx: int) -> void: @@ -37,4 +38,4 @@ func _on_sheep_spawned(entity: Node2D) -> void: if Random.rng.randi_range(0, 20) == 0: entity.get_node("Sprite/TopHatter").plus_one() if Random.rng.randi_range(0, 20) == 0: - entity.get_node("Sprite/Monocler").plus_one() \ No newline at end of file + entity.get_node("Sprite/Monocler").plus_one() diff --git a/entities/barn.tscn b/entities/barn.tscn index f348495..78128c2 100644 --- a/entities/barn.tscn +++ b/entities/barn.tscn @@ -12,6 +12,129 @@ [ext_resource type="AudioStream" uid="uid://dbj3ctst1tbuo" path="res://entities/barn_coin_drop.ogg" id="8_smljs"] [ext_resource type="Texture2D" uid="uid://bfl0tkg85cvb8" path="res://entities/gold.png" id="9_4flhr"] +[sub_resource type="Animation" id="Animation_ofgwt"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Coins/Coin1:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [false] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Coins/Coin1:position") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Coins/Coin2:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [false] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Coins/Coin2:position") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Coins/Coin3:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [false] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Coins/Coin3:position") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Coins/Coin4:visible") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [false] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Coins/Coin4:position") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/8/type = "value" +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/path = NodePath("Coins/Coin5:visible") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [false] +} +tracks/9/type = "value" +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/path = NodePath("Coins/Coin5:position") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} + [sub_resource type="Animation" id="Animation_p5d5r"] resource_name = "coin" length = 2.0 @@ -216,129 +339,6 @@ tracks/14/keys = { } tracks/14/use_blend = true -[sub_resource type="Animation" id="Animation_ofgwt"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Coins/Coin1:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Coins/Coin1:position") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Coins/Coin2:visible") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Coins/Coin2:position") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} -tracks/4/type = "value" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath("Coins/Coin3:visible") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/5/type = "value" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("Coins/Coin3:position") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} -tracks/6/type = "value" -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/path = NodePath("Coins/Coin4:visible") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/7/type = "value" -tracks/7/imported = false -tracks/7/enabled = true -tracks/7/path = NodePath("Coins/Coin4:position") -tracks/7/interp = 1 -tracks/7/loop_wrap = true -tracks/7/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} -tracks/8/type = "value" -tracks/8/imported = false -tracks/8/enabled = true -tracks/8/path = NodePath("Coins/Coin5:visible") -tracks/8/interp = 1 -tracks/8/loop_wrap = true -tracks/8/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/9/type = "value" -tracks/9/imported = false -tracks/9/enabled = true -tracks/9/path = NodePath("Coins/Coin5:position") -tracks/9/interp = 1 -tracks/9/loop_wrap = true -tracks/9/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_vvq7g"] _data = { "RESET": SubResource("Animation_ofgwt"), @@ -361,8 +361,8 @@ size = Vector2(140, 38) size = Vector2(73, 62) [node name="Barn" type="StaticBody2D"] -collision_layer = 88 -collision_mask = 4 +collision_layer = 8 +collision_mask = 24 script = ExtResource("1_ny8oq") [node name="BarnWallFront" type="Sprite2D" parent="."] @@ -465,7 +465,7 @@ shape = SubResource("RectangleShape2D_cpwqc") [node name="ClickableArea" type="Area2D" parent="."] collision_layer = 128 collision_mask = 128 -monitorable = false +monitoring = false [node name="Shape" type="CollisionShape2D" parent="ClickableArea"] position = Vector2(32, -83) diff --git a/entities/chupacabra.gd b/entities/chupacabra.gd index 944c077..1babaa0 100644 --- a/entities/chupacabra.gd +++ b/entities/chupacabra.gd @@ -23,7 +23,7 @@ func _on_eater_eaten(edible:Edible) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 tophatter.collision_mask = 16 monocler.collision_mask = 16 z_index = Enums.ZIndex.EntityAir @@ -33,7 +33,7 @@ func _on_dragged(_cursor: Cursor) -> void: func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 tophatter.collision_mask = 8 monocler.collision_mask = 8 z_index = Enums.ZIndex.EntityGround diff --git a/entities/chupacabra.tscn b/entities/chupacabra.tscn index 0a79428..b2a3fa4 100644 --- a/entities/chupacabra.tscn +++ b/entities/chupacabra.tscn @@ -366,8 +366,8 @@ radius = 32.0 [node name="Chupacabra" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_s4qg1") skitter_directions = Array[Vector2]([Vector2(-1, 0), Vector2(1, 0)]) diff --git a/entities/cthulhu.gd b/entities/cthulhu.gd index 8d4be9c..2fcc1fd 100644 --- a/entities/cthulhu.gd +++ b/entities/cthulhu.gd @@ -17,7 +17,7 @@ func _on_move(movement: Vector2): func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 tophatter.collision_mask = 16 monocler.collision_mask = 16 z_index = Enums.ZIndex.EntityAir @@ -26,7 +26,7 @@ func _on_dragged(_cursor: Cursor) -> void: func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 tophatter.collision_mask = 8 monocler.collision_mask = 8 z_index = Enums.ZIndex.EntityGround diff --git a/entities/cthulhu.tscn b/entities/cthulhu.tscn index 61febeb..5d32e7a 100644 --- a/entities/cthulhu.tscn +++ b/entities/cthulhu.tscn @@ -195,8 +195,8 @@ radius = 50.0 [node name="Cthulhu" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 script = ExtResource("1_b55wc") [node name="SpriteFocus" type="Node2D" parent="."] diff --git a/entities/gold.tscn b/entities/gold.tscn index 542204a..85e85a2 100644 --- a/entities/gold.tscn +++ b/entities/gold.tscn @@ -28,14 +28,12 @@ scale = Vector2(2, 2) texture = ExtResource("2_tt3v6") [node name="MagnetizeArea" parent="." instance=ExtResource("3_ne3sj")] -collision_mask = 128 [node name="Shape" type="CollisionShape2D" parent="MagnetizeArea"] shape = SubResource("CircleShape2D_w1h35") debug_color = Color(0.337255, 0.611765, 1, 0) [node name="CollectArea" parent="." instance=ExtResource("3_ne3sj")] -collision_mask = 128 [node name="Shape" type="CollisionShape2D" parent="CollectArea"] shape = SubResource("CircleShape2D_jm7yp") diff --git a/entities/imp.gd b/entities/imp.gd index 8f54bf9..b998d7f 100644 --- a/entities/imp.gd +++ b/entities/imp.gd @@ -22,7 +22,7 @@ func _on_eater_eaten(edible: Edible) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 tophatter.collision_mask = 16 monocler.collision_mask = 16 z_index = Enums.ZIndex.EntityAir @@ -32,7 +32,7 @@ func _on_dragged(_cursor: Cursor) -> void: func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 tophatter.collision_mask = 8 monocler.collision_mask = 8 z_index = Enums.ZIndex.EntityGround diff --git a/entities/imp.tscn b/entities/imp.tscn index 2081ed5..0ea3033 100644 --- a/entities/imp.tscn +++ b/entities/imp.tscn @@ -234,8 +234,8 @@ radius = 40.0 [node name="Imp" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_dixpc") diff --git a/entities/monocle.gd b/entities/monocle.gd index 9a22d8c..ff5d87b 100644 --- a/entities/monocle.gd +++ b/entities/monocle.gd @@ -10,14 +10,14 @@ func _on_move(movement: Vector2) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 z_index = Enums.ZIndex.EntityAir y_sort_enabled = false animator.play(&"drag_start") func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 z_index = Enums.ZIndex.EntityGround y_sort_enabled = true animator.play(&"RESET") diff --git a/entities/monocle.tscn b/entities/monocle.tscn index 44c7a4d..2af70e5 100644 --- a/entities/monocle.tscn +++ b/entities/monocle.tscn @@ -107,8 +107,8 @@ radius = 12.0 [node name="Monocle" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_ehpfj") diff --git a/entities/sheep.gd b/entities/sheep.gd index 468a8d3..6063489 100644 --- a/entities/sheep.gd +++ b/entities/sheep.gd @@ -18,7 +18,7 @@ func _on_move(movement: Vector2) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 tophatter.collision_mask = 16 monocler.collision_mask = 16 z_index = Enums.ZIndex.EntityAir @@ -27,7 +27,7 @@ func _on_dragged(_cursor: Cursor) -> void: func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 tophatter.collision_mask = 8 monocler.collision_mask = 8 z_index = Enums.ZIndex.EntityGround diff --git a/entities/sheep.tscn b/entities/sheep.tscn index f6a9cbc..5745344 100644 --- a/entities/sheep.tscn +++ b/entities/sheep.tscn @@ -211,8 +211,8 @@ radius = 8.65 [node name="Sheep" type="CharacterBody2D"] z_index = 1 y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_4dmll") @@ -388,6 +388,7 @@ enabled = false alternative_priority = 50 [node name="Draggable" parent="MovementDrag" instance=ExtResource("14_0b1hs")] +collision_layer = 128 [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] scale = Vector2(3, 3) diff --git a/entities/skull.gd b/entities/skull.gd index 6898425..5f8c9c5 100644 --- a/entities/skull.gd +++ b/entities/skull.gd @@ -10,14 +10,14 @@ func _on_move(movement: Vector2) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 z_index = Enums.ZIndex.EntityAir y_sort_enabled = false animator.play(&"drag_start") func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 z_index = Enums.ZIndex.EntityGround y_sort_enabled = true animator.play(&"RESET") diff --git a/entities/skull.tscn b/entities/skull.tscn index 5cd5dd7..b78e8ec 100644 --- a/entities/skull.tscn +++ b/entities/skull.tscn @@ -115,8 +115,8 @@ radius = 32.0 [node name="Skull" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_7g8bu") diff --git a/entities/top_hat.gd b/entities/top_hat.gd index 960918c..969dbeb 100644 --- a/entities/top_hat.gd +++ b/entities/top_hat.gd @@ -10,14 +10,14 @@ func _on_move(movement: Vector2) -> void: func _on_dragged(_cursor: Cursor) -> void: collision_layer = 16 - collision_mask = 18 + collision_mask = 16 z_index = Enums.ZIndex.EntityAir y_sort_enabled = false animator.play(&"drag_start") func _on_fallen() -> void: collision_layer = 8 - collision_mask = 14 + collision_mask = 8 z_index = Enums.ZIndex.EntityGround y_sort_enabled = true animator.play(&"RESET") diff --git a/entities/top_hat.tscn b/entities/top_hat.tscn index 3c8761e..9e98840 100644 --- a/entities/top_hat.tscn +++ b/entities/top_hat.tscn @@ -106,8 +106,8 @@ radius = 12.0 [node name="TopHat" type="CharacterBody2D"] y_sort_enabled = true -collision_layer = 72 -collision_mask = 14 +collision_layer = 8 +collision_mask = 8 motion_mode = 1 script = ExtResource("1_0eh11") @@ -133,7 +133,6 @@ diet = &"TopHat" [node name="MovementDrag" parent="." instance=ExtResource("3_gy414")] [node name="Draggable" parent="MovementDrag" instance=ExtResource("4_fcvjo")] -collision_layer = 32 [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] shape = SubResource("CircleShape2D_juisb") diff --git a/entities/tree.tscn b/entities/tree.tscn index 6427e58..d82fd81 100644 --- a/entities/tree.tscn +++ b/entities/tree.tscn @@ -16,7 +16,7 @@ scale = Vector2(2, 2) texture = ExtResource("1_yk0t0") [node name="Upper" type="StaticBody2D" parent="."] -collision_layer = 80 +collision_layer = 16 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Upper"] diff --git a/entities/watcher.tscn b/entities/watcher.tscn index 8161cc9..2adcb17 100644 --- a/entities/watcher.tscn +++ b/entities/watcher.tscn @@ -241,8 +241,8 @@ radius = 40.0 [node name="Watcher" type="CharacterBody2D"] z_index = 10 -collision_layer = 80 -collision_mask = 18 +collision_layer = 16 +collision_mask = 16 script = ExtResource("1_brahc") [node name="Sprite" parent="." instance=ExtResource("1_thu73")] @@ -430,8 +430,8 @@ bus = &"KillSounds" [connection signal="timeout" from="GoldSpawner/SpawnTimer" to="GoldSpawner" method="spawn"] [connection signal="move" from="MovementTilt" to="." method="_on_move"] [connection signal="move_enabled" from="MovementTilt" to="Animator" method="play" binds= [&"fly"]] -[connection signal="ready" from="MovementTilt" to="MovementTilt" method="randomize_direction"] [connection signal="ready" from="MovementTilt" to="MovementTilt" method="randomize_rotation_speed"] +[connection signal="ready" from="MovementTilt" to="MovementTilt" method="randomize_direction"] [connection signal="timeout" from="MovementTilt/TimerStddev" to="MovementTilt" method="randomize_rotation_speed"] [connection signal="changed_target" from="MovementTrap" to="MovementTrap/TrapPriority" method="priority_conditional"] [connection signal="move" from="MovementTrap" to="." method="_on_move"] diff --git a/main.tscn b/main.tscn index 59467f2..dccc84f 100644 --- a/main.tscn +++ b/main.tscn @@ -12,6 +12,7 @@ starting_stage = 1 [node name="SafeMarginContainer" parent="InterfaceCanvas" instance=ExtResource("2_ah6n8")] unique_name_in_owner = true +mouse_filter = 2 min_margin_left = 16 min_margin_right = 16 min_margin_top = 16 diff --git a/project.godot b/project.godot index 5b2dec8..62407a0 100644 --- a/project.godot +++ b/project.godot @@ -51,12 +51,9 @@ cheat_gold={ [layer_names] 2d_physics/layer_1="Unset" -2d_physics/layer_2="Tiles" -2d_physics/layer_3="Trees" -2d_physics/layer_4="Entities (grounded)" -2d_physics/layer_5="Entities (air)" -2d_physics/layer_6="Pickups" -2d_physics/layer_7="System" +2d_physics/layer_4="Ground" +2d_physics/layer_5="Air" +2d_physics/layer_8="Draggables" [physics] diff --git a/scenes/game/cursor.gd b/scenes/game/cursor.gd index 5b7d32a..1bc220e 100644 --- a/scenes/game/cursor.gd +++ b/scenes/game/cursor.gd @@ -23,15 +23,16 @@ static func get_via_group(node: Node) -> Cursor: func find_closest_target() -> Draggable: - var bodies = get_overlapping_bodies() + var areas = get_overlapping_areas() var min_distance: float = INF var to_drag: Node = null - for body in bodies: - for target in body.find_children("*", "Draggable", true, false): - var distance = position.distance_to(target.position) - if distance < min_distance: - min_distance = distance - to_drag = target + for area in areas: + if not area is Draggable: + continue + var distance = position.distance_to(area.position) + if distance < min_distance: + min_distance = distance + to_drag = area return to_drag func drag(): @@ -63,6 +64,14 @@ func _input(event: InputEvent) -> void: else: drop() +func _process(_delta: float) -> void: + # Determine mouse cursor shape + if dragging: + Input.set_default_cursor_shape(Input.CURSOR_DRAG) + elif has_overlapping_areas(): + Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND) + else: + Input.set_default_cursor_shape(Input.CURSOR_ARROW) func _physics_process(_delta: float) -> void: position += (game.camera.get_global_mouse_position() - global_position) diff --git a/scenes/game/cursor.tscn b/scenes/game/cursor.tscn index 67643f2..93a90ea 100644 --- a/scenes/game/cursor.tscn +++ b/scenes/game/cursor.tscn @@ -10,8 +10,8 @@ radius = 8.0 [node name="Cursor" type="Area2D" groups=["cursor"]] z_index = 100 -collision_layer = 192 -collision_mask = 56 +collision_layer = 64 +collision_mask = 128 script = ExtResource("1_1og6v") [node name="Shape" type="CollisionShape2D" parent="."] diff --git a/scenes/game/main_game.tscn b/scenes/game/main_game.tscn index 8787008..2a88ecd 100644 --- a/scenes/game/main_game.tscn +++ b/scenes/game/main_game.tscn @@ -882,7 +882,7 @@ unique_name_in_owner = true [node name="BottomBoundary" type="StaticBody2D" parent="Walls"] position = Vector2(0, 360) -collision_layer = 2 +collision_layer = 24 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/BottomBoundary"] @@ -891,7 +891,7 @@ shape = SubResource("WorldBoundaryShape2D_htttx") [node name="TopBoundary" type="StaticBody2D" parent="Walls"] position = Vector2(0, -360) rotation = 3.14159 -collision_layer = 2 +collision_layer = 24 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/TopBoundary"] @@ -900,7 +900,7 @@ shape = SubResource("WorldBoundaryShape2D_htttx") [node name="RightBoundary" type="StaticBody2D" parent="Walls"] position = Vector2(640, 0) rotation = 4.71239 -collision_layer = 2 +collision_layer = 24 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/RightBoundary"] @@ -909,7 +909,7 @@ shape = SubResource("WorldBoundaryShape2D_htttx") [node name="LeftBoundary" type="StaticBody2D" parent="Walls"] position = Vector2(-640, 0) rotation = 1.5708 -collision_layer = 2 +collision_layer = 24 collision_mask = 0 [node name="Shape" type="CollisionShape2D" parent="Walls/LeftBoundary"]