From cff461189c79d4289e8836a3f24049597c3399de Mon Sep 17 00:00:00 2001 From: theskywinds Date: Mon, 19 May 2025 19:10:43 +0200 Subject: [PATCH] Removed rock & adapted its script to the crystals --- collectables/crystal/collect_crystal.gd | 6 +++- collectables/crystal/collectableCrystal.tscn | 15 ++++++-- rock/Rock.tscn | 24 ------------- rock/rock.gd | 6 ---- rock/rock.gd.uid | 1 - rock/rocks.png | Bin 716 -> 0 bytes rock/rocks.png.import | 34 ------------------- 7 files changed, 18 insertions(+), 68 deletions(-) delete mode 100644 rock/Rock.tscn delete mode 100644 rock/rock.gd delete mode 100644 rock/rock.gd.uid delete mode 100644 rock/rocks.png delete mode 100644 rock/rocks.png.import 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 7af459f590e8365181daa3c6d83dce62440eeef0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 716 zcmV;-0yF)IP)Px%hDk(0RA_AZTp?DM#%A*i+{Q-l z3b9Z)@E3Rx2wZiLN(*faXnD#t_ZQYe-gRbn=AD_<=z{aWLb5yW$1@+x^RPfb!28C+ zODAkKd%5oZ-TlRj*8)5VP;;hcTFqXbX1m(hEFFQ1tqSL4VslwKDmBt-_VSI*0oGTS z@%P_AIKsj4VJWUqqtv)612jsrbWX^PjVDvAuP$o|*t`JcAQAwiT&DO2HFLCg zVN6csI^8yebE4JrR9r+=Nj;uSt+A{lquK9t+vs%L()Mzd+*O+=d}x1^{;S*1>d4eH zp*tg@oOXq}dZrxDS^=L|sgHy<`GG1j+$lix3ARG&Sm0?EU5t!~Dn=+EARr*X3$=Z( zx|*8W5imJAlc}i{0h=jG;t1cqZc8L;Lx9|v?&}Vj8}bC#=YI+kUf&1i4U-|_%uuZe y0D42j!Rs5@TR`UrYIz0-svH*y1UVfr2Rr};=6hbMhSl2u0000