added grapes
parent
515aab1a70
commit
99b1e8069d
|
|
@ -3,14 +3,14 @@
|
||||||
[ext_resource type="Script" uid="uid://bm4wewhu4hpte" path="res://scripts/blue_slime.gd" id="1_ds7cs"]
|
[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="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="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://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://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"]
|
[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"]
|
[sub_resource type="Resource" id="Resource_i8e30"]
|
||||||
script = ExtResource("2_ullxd")
|
script = ExtResource("2_ullxd")
|
||||||
drop = ExtResource("3_vx4o0")
|
drop = ExtResource("3_ullxd")
|
||||||
chance = 0.3
|
chance = 0.3
|
||||||
metadata/_custom_type_script = "uid://cjkaw7wqw4e30"
|
metadata/_custom_type_script = "uid://cjkaw7wqw4e30"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
|
|
@ -4,37 +4,37 @@ var enemies_hit = 0
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
speed = 500
|
speed = 500
|
||||||
super()
|
super()
|
||||||
var first = get_nearest_enemy(global_position)
|
var first = get_nearest_enemy(global_position)
|
||||||
if first == null:
|
if first == null:
|
||||||
queue_free()
|
queue_free()
|
||||||
return
|
return
|
||||||
launch(first.global_position)
|
launch(first.global_position)
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
if body.is_in_group("enemies"):
|
if body.is_in_group("enemies"):
|
||||||
enemies_hit += 1
|
enemies_hit += 1
|
||||||
body.hit()
|
body.hit()
|
||||||
if enemies_hit == 20:
|
if enemies_hit == 20:
|
||||||
queue_free()
|
queue_free()
|
||||||
else:
|
else:
|
||||||
var next = get_nearest_enemy(global_position, body)
|
var next = get_nearest_enemy(global_position, body)
|
||||||
if next == null:
|
if next == null:
|
||||||
queue_free()
|
queue_free()
|
||||||
else:
|
else:
|
||||||
launch(next.global_position)
|
launch(next.global_position)
|
||||||
|
|
||||||
func get_nearest_enemy(from: Vector2, exclude: Node = null) -> Node:
|
func get_nearest_enemy(from: Vector2, exclude: Node = null) -> Node:
|
||||||
var nearest = null
|
var nearest = null
|
||||||
var min_distance = INF
|
var min_distance = INF
|
||||||
for enemy in get_tree().get_nodes_in_group("enemies"):
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||||
if enemy == exclude or enemy.is_dying:
|
if enemy == exclude or enemy.is_dying:
|
||||||
continue
|
continue
|
||||||
var dist = from.distance_to(enemy.global_position)
|
var dist = from.distance_to(enemy.global_position)
|
||||||
if dist < min_distance:
|
if dist < min_distance:
|
||||||
min_distance = dist
|
min_distance = dist
|
||||||
nearest = enemy
|
nearest = enemy
|
||||||
return nearest
|
return nearest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue