Add basic enemy behavior and spawning system
The changes introduce enemy mechanics and management - including spawning, movement patterns, shooting timers, and death handling.
This commit is contained in:
parent
85155b1c7d
commit
996a0bb8f7
8 changed files with 300 additions and 7 deletions
164
scenes/enemy.tscn
Normal file
164
scenes/enemy.tscn
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://c4vq2ytntfvoj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bgdjbphv28w25" path="res://scenes/enemy.gd" id="1_55jtl"]
|
||||
[ext_resource type="Texture2D" uid="uid://deyu1prtitqcp" path="res://resources/Mini Pixel Pack 3/Enemies/Bon_Bon (16 x 16).png" id="2_mpr68"]
|
||||
[ext_resource type="Texture2D" uid="uid://h04wm5a27u0" path="res://resources/Mini Pixel Pack 3/Effects/Explosion (16 x 16).png" id="3_4ra3w"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ft8do"]
|
||||
size = Vector2(14, 12)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1vja8"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("2_mpr68")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [2]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_5wwv6"]
|
||||
resource_name = "bounce"
|
||||
loop_mode = 1
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("2_mpr68")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:frame")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0.1, 0.2, 0.3, 0.4, 0.45),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [2, 1, 0, 3, 0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iwav8"]
|
||||
resource_name = "explode"
|
||||
length = 0.4
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("3_4ra3w")]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprite2D:frame")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.042729422, 0.1, 0.15, 0.4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 2, 3, 4, 5]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Sprite2D:hframes")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [6]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1i2q2"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_1vja8"),
|
||||
&"bounce": SubResource("Animation_5wwv6"),
|
||||
&"explode": SubResource("Animation_iwav8")
|
||||
}
|
||||
|
||||
[node name="Enemy" type="Area2D" groups=["enemies"]]
|
||||
script = ExtResource("1_55jtl")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -3)
|
||||
texture = ExtResource("2_mpr68")
|
||||
hframes = 4
|
||||
frame = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -3)
|
||||
shape = SubResource("RectangleShape2D_ft8do")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_1i2q2")
|
||||
}
|
||||
autoplay = "bounce"
|
||||
|
||||
[node name="MoveTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="ShootTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="MoveTimer" to="." method="_on_move_timer_timeout"]
|
||||
[connection signal="timeout" from="ShootTimer" to="." method="_on_shoot_timer_timeout"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue