diff --git a/collectables/crystal/collect_crystal.gd b/collectables/crystal/collect_crystal.gd index c1cca9a..dcc54ef 100644 --- a/collectables/crystal/collect_crystal.gd +++ b/collectables/crystal/collect_crystal.gd @@ -11,4 +11,8 @@ func _on_body_entered(body: Node2D) -> void: queue_free() else: print("Whoops, something went wrong") - + +func _on_mouse_collision_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void: + if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): + var destination = get_global_mouse_position() + global_position = global_position.move_toward(destination, 1.0) diff --git a/collectables/crystal/collectableCrystal.tscn b/collectables/crystal/collectableCrystal.tscn index 17f7986..6506628 100644 --- a/collectables/crystal/collectableCrystal.tscn +++ b/collectables/crystal/collectableCrystal.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://darxbklsgh23m"] +[gd_scene load_steps=9 format=3 uid="uid://darxbklsgh23m"] [ext_resource type="Script" uid="uid://dmyoo12ntx27" path="res://collectables/crystal/collect_crystal.gd" id="1_ttvq1"] [ext_resource type="Texture2D" uid="uid://igfk66vn3kwf" path="res://collectables/crystal/Sprites/Crystal_0001.png" id="2_s8vun"] @@ -29,8 +29,12 @@ animations = [{ [sub_resource type="CircleShape2D" id="CircleShape2D_lmbvg"] radius = 17.0 +[sub_resource type="CircleShape2D" id="CircleShape2D_m1y8f"] +radius = 114.07 + [node name="crystal" type="Area2D"] -collision_layer = 0 +collision_layer = 3 +collision_mask = 3 script = ExtResource("1_ttvq1") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] @@ -43,4 +47,11 @@ autoplay = "default" position = Vector2(0, -1) shape = SubResource("CircleShape2D_lmbvg") +[node name="mouseCollision" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="mouseCollision"] +shape = SubResource("CircleShape2D_m1y8f") +debug_color = Color(0.99368, 0, 0.23394, 0.42) + [connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="input_event" from="mouseCollision" to="." method="_on_mouse_collision_input_event"] diff --git a/rock/Rock.tscn b/rock/Rock.tscn deleted file mode 100644 index 0084cbd..0000000 --- a/rock/Rock.tscn +++ /dev/null @@ -1,24 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://chpqjpcexhd3t"] - -[ext_resource type="Texture2D" uid="uid://8uv7dd4m5ne" path="res://rock/rocks.png" id="1_6r1ml"] -[ext_resource type="Script" uid="uid://caa0o3l446c85" path="res://rock/rock.gd" id="1_55vvm"] - -[sub_resource type="AtlasTexture" id="AtlasTexture_55vvm"] -atlas = ExtResource("1_6r1ml") -region = Rect2(16.535, 15.865, 15.895, 17.055) - -[sub_resource type="CircleShape2D" id="CircleShape2D_55vvm"] -radius = 31.0 - -[node name="Node2D" type="Node2D"] -script = ExtResource("1_55vvm") - -[node name="Sprite2D" type="Sprite2D" parent="."] -texture = SubResource("AtlasTexture_55vvm") - -[node name="Area2D" type="Area2D" parent="."] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -shape = SubResource("CircleShape2D_55vvm") - -[connection signal="input_event" from="Area2D" to="." method="_on_area_2d_input_event"] diff --git a/rock/rock.gd b/rock/rock.gd deleted file mode 100644 index 7b25663..0000000 --- a/rock/rock.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Node2D - -func _on_area_2d_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void: - if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): - var destination = get_global_mouse_position() - position = position.move_toward(destination, 100) diff --git a/rock/rock.gd.uid b/rock/rock.gd.uid deleted file mode 100644 index 7e8667c..0000000 --- a/rock/rock.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://caa0o3l446c85 diff --git a/rock/rocks.png b/rock/rocks.png deleted file mode 100644 index 7af459f..0000000 Binary files a/rock/rocks.png and /dev/null differ diff --git a/rock/rocks.png.import b/rock/rocks.png.import deleted file mode 100644 index 33265f1..0000000 --- a/rock/rocks.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://8uv7dd4m5ne" -path="res://.godot/imported/rocks.png-31e9fdd0c761c959532605b940b863f9.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://rock/rocks.png" -dest_files=["res://.godot/imported/rocks.png-31e9fdd0c761c959532605b940b863f9.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