added grapes

pull/1/head
Artur David 2026-04-14 14:53:58 +02:00
parent 515aab1a70
commit 99b1e8069d
3 changed files with 51 additions and 33 deletions

View File

@ -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"

18
scenes/grape.tscn 100644
View File

@ -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")

View File

@ -4,37 +4,37 @@ 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