bug fix && plants
This commit is contained in:
@@ -38,7 +38,7 @@ animations = [{
|
|||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ti4si"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_8406q"]
|
||||||
radius = 7.0
|
radius = 7.0
|
||||||
height = 24.0
|
height = 24.0
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ autoplay = "default"
|
|||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(8, -12)
|
position = Vector2(8, -12)
|
||||||
shape = SubResource("CapsuleShape2D_ti4si")
|
shape = SubResource("CapsuleShape2D_8406q")
|
||||||
|
|
||||||
[node name="RayCastLeft" type="RayCast2D" parent="."]
|
[node name="RayCastLeft" type="RayCast2D" parent="."]
|
||||||
position = Vector2(8, -8)
|
position = Vector2(8, -8)
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
[gd_scene load_steps=10 format=3 uid="uid://dn2sy74ad2qfh"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/enemies/plant.gd" id="1_7t6jh"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ddl5f3lldrp2n" path="res://assets/enemies.png" id="1_jnxrw"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_cyktl"]
|
||||||
|
atlas = ExtResource("1_jnxrw")
|
||||||
|
region = Rect2(390, 30, 16, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dylf8"]
|
||||||
|
atlas = ExtResource("1_jnxrw")
|
||||||
|
region = Rect2(420, 30, 16, 24)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_th7fo"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_cyktl")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_dylf8")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mdpkr"]
|
||||||
|
size = Vector2(16, 24)
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_g0wcr"]
|
||||||
|
resource_name = "default"
|
||||||
|
length = 8.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "method"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(4, 8),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"values": [{
|
||||||
|
"args": [],
|
||||||
|
"method": &"move_up"
|
||||||
|
}, {
|
||||||
|
"args": [],
|
||||||
|
"method": &"move_down"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_axvvr"]
|
||||||
|
length = 0.001
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_x0mu6"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_axvvr"),
|
||||||
|
"default": SubResource("Animation_g0wcr")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Plant" type="Area2D"]
|
||||||
|
collision_layer = 128
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_7t6jh")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
position = Vector2(0, 13)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_th7fo")
|
||||||
|
autoplay = "default"
|
||||||
|
frame_progress = 0.459679
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2(0, 13)
|
||||||
|
shape = SubResource("RectangleShape2D_mdpkr")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_x0mu6")
|
||||||
|
}
|
||||||
|
autoplay = "default"
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
+15
-15
@@ -6,6 +6,21 @@
|
|||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ihwdr"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ihwdr"]
|
||||||
size = Vector2(6, 201)
|
size = Vector2(6, 201)
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_ufkda"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("AudioStreamPlayer:playing")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ivwqs"]
|
[sub_resource type="Animation" id="Animation_ivwqs"]
|
||||||
resource_name = "change_scene"
|
resource_name = "change_scene"
|
||||||
length = 6.0
|
length = 6.0
|
||||||
@@ -36,21 +51,6 @@ tracks/1/keys = {
|
|||||||
"values": [true]
|
"values": [true]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ufkda"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("AudioStreamPlayer:playing")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [false]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_adywb"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_adywb"]
|
||||||
_data = {
|
_data = {
|
||||||
"RESET": SubResource("Animation_ufkda"),
|
"RESET": SubResource("Animation_ufkda"),
|
||||||
|
|||||||
@@ -64,4 +64,5 @@ stream = ExtResource("3_270oi")
|
|||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
[connection signal="body_entered" from="CollCount" to="." method="_on_area_2d_body_entered"]
|
[connection signal="body_entered" from="CollCount" to="." method="_on_area_2d_body_entered"]
|
||||||
|
[connection signal="area_entered" from="EnemieDie" to="." method="_on_enemie_die_area_entered"]
|
||||||
[connection signal="body_entered" from="EnemieDie" to="." method="_on_enemie_die_body_entered"]
|
[connection signal="body_entered" from="EnemieDie" to="." method="_on_enemie_die_body_entered"]
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -87,6 +87,8 @@ func f_shrink(body):
|
|||||||
die.position.y += 2
|
die.position.y += 2
|
||||||
animated_sprite_2d.play("shrink")
|
animated_sprite_2d.play("shrink")
|
||||||
is_down = true
|
is_down = true
|
||||||
|
ray_cast_left_2.scale.x = 2
|
||||||
|
ray_cast_right_2.scale.x = 2
|
||||||
elif speed == 0:
|
elif speed == 0:
|
||||||
speed = 160 if body.position.x < position.x else -160
|
speed = 160 if body.position.x < position.x else -160
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
extends Area2D
|
||||||
|
|
||||||
|
var innocent = false
|
||||||
|
@onready var timer = $Timer
|
||||||
|
@onready var animated_sprite_2d = $AnimatedSprite2D
|
||||||
|
@onready var collision_shape_2d = $CollisionShape2D
|
||||||
|
|
||||||
|
var mover = 25
|
||||||
|
var up = false
|
||||||
|
|
||||||
|
func _on_body_entered(body):
|
||||||
|
if not innocent:
|
||||||
|
body.shrink()
|
||||||
|
innocent = true
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if mover < 25:
|
||||||
|
collision_shape_2d.position.y += -1 if up else 1
|
||||||
|
animated_sprite_2d.position.y += -1 if up else 1
|
||||||
|
mover += 1
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
innocent = false
|
||||||
|
|
||||||
|
func move_up():
|
||||||
|
mover = 0
|
||||||
|
up = true
|
||||||
|
|
||||||
|
func move_down():
|
||||||
|
mover = 0
|
||||||
|
up = false
|
||||||
|
|
||||||
|
func f_die():
|
||||||
|
queue_free()
|
||||||
@@ -23,3 +23,7 @@ func _on_area_2d_body_entered(body):
|
|||||||
func _on_enemie_die_body_entered(body):
|
func _on_enemie_die_body_entered(body):
|
||||||
body.f_die()
|
body.f_die()
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_enemie_die_area_entered(area):
|
||||||
|
_on_enemie_die_body_entered(area)
|
||||||
|
|||||||
Reference in New Issue
Block a user