From 99b1e8069d83f90ad1d563d31ebcaedbd8b53689 Mon Sep 17 00:00:00 2001 From: Artur David Date: Tue, 14 Apr 2026 14:53:58 +0200 Subject: [PATCH] added grapes --- scenes/blue_slime.tscn | 4 +-- scenes/grape.tscn | 18 ++++++++++++ scripts/shuriken.gd | 62 +++++++++++++++++++++--------------------- 3 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 scenes/grape.tscn diff --git a/scenes/blue_slime.tscn b/scenes/blue_slime.tscn index 9075191..02fca8e 100644 --- a/scenes/blue_slime.tscn +++ b/scenes/blue_slime.tscn @@ -3,14 +3,14 @@ [ext_resource type="Script" uid="uid://bm4wewhu4hpte" path="res://scripts/blue_slime.gd" id="1_ds7cs"] [ext_resource type="Texture2D" uid="uid://dx1ipffjtn8we" path="res://assets/Slime2/With_shadow/Slime2_Death_with_shadow.png" id="2_7qf5q"] [ext_resource type="Script" uid="uid://cjkaw7wqw4e30" path="res://scripts/drop_table.gd" id="2_ullxd"] -[ext_resource type="PackedScene" uid="uid://dm6d2jg52vi41" path="res://scenes/apple.tscn" id="3_vx4o0"] +[ext_resource type="PackedScene" uid="uid://cob0yjs7tx2ol" path="res://scenes/grape.tscn" id="3_ullxd"] [ext_resource type="Texture2D" uid="uid://bn44pxk3l7j1c" path="res://assets/Slime2/With_shadow/Slime2_Idle_with_shadow.png" id="3_xfb3o"] [ext_resource type="Texture2D" uid="uid://buquy2xkbq7cj" path="res://assets/Slime2/With_shadow/Slime2_Hurt_with_shadow.png" id="4_7qf5q"] [ext_resource type="Texture2D" uid="uid://b33awo7oiotwo" path="res://assets/Slime2/With_shadow/Slime2_Walk_with_shadow.png" id="4_ullxd"] [sub_resource type="Resource" id="Resource_i8e30"] script = ExtResource("2_ullxd") -drop = ExtResource("3_vx4o0") +drop = ExtResource("3_ullxd") chance = 0.3 metadata/_custom_type_script = "uid://cjkaw7wqw4e30" diff --git a/scenes/grape.tscn b/scenes/grape.tscn new file mode 100644 index 0000000..7ba8f37 --- /dev/null +++ b/scenes/grape.tscn @@ -0,0 +1,18 @@ +[gd_scene format=3 uid="uid://cob0yjs7tx2ol"] + +[ext_resource type="Texture2D" uid="uid://d2pinnrigixnp" path="res://assets/16x16 Pixelart Food Icons/Pixel_Foods(ARTLİNE).png" id="1_8daar"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_0gvam"] +atlas = ExtResource("1_8daar") +region = Rect2(55, 19, 15, 16) + +[sub_resource type="CircleShape2D" id="CircleShape2D_cukkh"] + +[node name="Grape" type="Area2D" unique_id=994786367] + +[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2069064426] +texture_filter = 1 +texture = SubResource("AtlasTexture_0gvam") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1030759335] +shape = SubResource("CircleShape2D_cukkh") diff --git a/scripts/shuriken.gd b/scripts/shuriken.gd index 792e05b..5a58b9b 100644 --- a/scripts/shuriken.gd +++ b/scripts/shuriken.gd @@ -2,39 +2,39 @@ extends ProjectileBase var enemies_hit = 0 - + func _ready() -> void: - speed = 500 - super() - var first = get_nearest_enemy(global_position) - if first == null: - queue_free() - return - launch(first.global_position) + speed = 500 + super() + var first = get_nearest_enemy(global_position) + if first == null: + queue_free() + return + launch(first.global_position) func _on_body_entered(body: Node2D) -> void: - if body.is_in_group("enemies"): - enemies_hit += 1 - body.hit() - if enemies_hit == 20: - queue_free() - else: - var next = get_nearest_enemy(global_position, body) - if next == null: - queue_free() - else: - launch(next.global_position) + if body.is_in_group("enemies"): + enemies_hit += 1 + body.hit() + if enemies_hit == 20: + queue_free() + else: + var next = get_nearest_enemy(global_position, body) + if next == null: + queue_free() + else: + launch(next.global_position) func get_nearest_enemy(from: Vector2, exclude: Node = null) -> Node: - var nearest = null - var min_distance = INF - for enemy in get_tree().get_nodes_in_group("enemies"): - if enemy == exclude or enemy.is_dying: - continue - var dist = from.distance_to(enemy.global_position) - if dist < min_distance: - min_distance = dist - nearest = enemy - return nearest - - + var nearest = null + var min_distance = INF + for enemy in get_tree().get_nodes_in_group("enemies"): + if enemy == exclude or enemy.is_dying: + continue + var dist = from.distance_to(enemy.global_position) + if dist < min_distance: + min_distance = dist + nearest = enemy + return nearest + +