diff --git a/scenes/apple.gd b/scenes/apple.gd new file mode 100644 index 0000000..20fc21e --- /dev/null +++ b/scenes/apple.gd @@ -0,0 +1,6 @@ +extends DropsBase + + +# Called when the node enters the scene tree for the first time. + +# Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/scenes/apple.gd.uid b/scenes/apple.gd.uid new file mode 100644 index 0000000..36c83c6 --- /dev/null +++ b/scenes/apple.gd.uid @@ -0,0 +1 @@ +uid://bewhtchahb2sy diff --git a/scenes/apple.tscn b/scenes/apple.tscn index c66bc5e..6c73f68 100644 --- a/scenes/apple.tscn +++ b/scenes/apple.tscn @@ -1,5 +1,6 @@ [gd_scene format=3 uid="uid://dm6d2jg52vi41"] +[ext_resource type="Script" uid="uid://bewhtchahb2sy" path="res://scenes/apple.gd" id="1_7vr8k"] [ext_resource type="Texture2D" uid="uid://d2pinnrigixnp" path="res://assets/16x16 Pixelart Food Icons/Pixel_Foods(ARTLİNE).png" id="1_h071m"] [sub_resource type="AtlasTexture" id="AtlasTexture_7vr8k"] @@ -11,6 +12,7 @@ radius = 9.0 height = 18.0 [node name="Apple" type="Area2D" unique_id=1121088527] +script = ExtResource("1_7vr8k") [node name="Sprite2D" type="Sprite2D" parent="." unique_id=1596918550] texture_filter = 1 diff --git a/scenes/slime.tscn b/scenes/slime.tscn index bc63989..56895cc 100644 --- a/scenes/slime.tscn +++ b/scenes/slime.tscn @@ -10,7 +10,7 @@ [sub_resource type="Resource" id="Resource_gstla"] script = ExtResource("2_2npkn") drop = ExtResource("3_fd6lc") -chance = 0.3 +chance = 1.0 metadata/_custom_type_script = "uid://cjkaw7wqw4e30" [sub_resource type="AtlasTexture" id="AtlasTexture_v5wyi"] diff --git a/scripts/DropsBase.gd b/scripts/DropsBase.gd new file mode 100644 index 0000000..1eb7aa2 --- /dev/null +++ b/scripts/DropsBase.gd @@ -0,0 +1,32 @@ +extends Area2D +class_name DropsBase + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + _animate_spawn() + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func _get_random_landing_position() -> Vector2: + var offset_x = randf_range(-20,20) + var offset_y = randf_range(-20,20) + offset_x += global_position.x + offset_y += global_position.y + return Vector2(offset_x,offset_y) + +func _animate_spawn() -> void: + scale = Vector2.ZERO + var size_scling = create_tween() + size_scling.tween_property(self, "scale", Vector2(1,1),0.4) + var jump = create_tween() + var landing = _get_random_landing_position() + jump.tween_property(self, "global_position:x", landing.x, 0.2).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD) + jump.parallel() + jump.tween_property(self, "global_position:y", global_position.y - 5, 0.2).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD) + jump.tween_property(self, "global_position:y", landing.y, 0.2).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD) + + diff --git a/scripts/DropsBase.gd.uid b/scripts/DropsBase.gd.uid new file mode 100644 index 0000000..4eedba0 --- /dev/null +++ b/scripts/DropsBase.gd.uid @@ -0,0 +1 @@ +uid://cwp7q24t3nxly diff --git a/scripts/enemy_base.gd b/scripts/enemy_base.gd index 0c0a86c..eb9fbd5 100644 --- a/scripts/enemy_base.gd +++ b/scripts/enemy_base.gd @@ -26,8 +26,8 @@ func _die(): player.stream = death_sound player.bus = "SFX" player.play() - await animated_sprite_2d.animation_finished died.emit(self) + await animated_sprite_2d.animation_finished queue_free()