add boss enemy and refactor

This commit is contained in:
2025-10-22 16:42:26 +01:00
parent bfefcffb1f
commit c7933ca7b8
11 changed files with 501 additions and 24 deletions

354
scenes/boss.tscn Normal file
View File

@@ -0,0 +1,354 @@
[gd_scene load_steps=23 format=3 uid="uid://yawu757h8byd"]
[ext_resource type="Texture2D" uid="uid://olo0olybw7k2" path="res://assets/sprites/slime_purple.png" id="1_jncid"]
[ext_resource type="Script" uid="uid://bamgalx75xtf2" path="res://scripts/boss.gd" id="1_qnbj4"]
[ext_resource type="PackedScene" uid="uid://jnqii6cg0cy" path="res://scenes/hit_box.tscn" id="2_qnbj4"]
[ext_resource type="PackedScene" uid="uid://dpox5fa2pojpo" path="res://scenes/killzone.tscn" id="3_r3bxh"]
[ext_resource type="AudioStream" uid="uid://bhayvfhydadqy" path="res://assets/sounds/tap.wav" id="5_r3bxh"]
[ext_resource type="AudioStream" uid="uid://cm3cxtbk134ux" path="res://assets/sounds/explosion.wav" id="6_wqpjq"]
[sub_resource type="AtlasTexture" id="AtlasTexture_wqpjq"]
atlas = ExtResource("1_jncid")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_2cdgk"]
atlas = ExtResource("1_jncid")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_qsl3t"]
atlas = ExtResource("1_jncid")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_2avx2"]
atlas = ExtResource("1_jncid")
region = Rect2(72, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_qnbj4"]
atlas = ExtResource("1_jncid")
region = Rect2(72, 0, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_r3bxh"]
atlas = ExtResource("1_jncid")
region = Rect2(48, 0, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_5f346"]
atlas = ExtResource("1_jncid")
region = Rect2(24, 0, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_0onds"]
atlas = ExtResource("1_jncid")
region = Rect2(0, 0, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_lfs1x"]
atlas = ExtResource("1_jncid")
region = Rect2(48, 48, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_8eiau"]
atlas = ExtResource("1_jncid")
region = Rect2(72, 48, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_5f346"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_wqpjq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2cdgk")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qsl3t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2avx2")
}],
"loop": true,
"name": &"default",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qnbj4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r3bxh")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5f346")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0onds")
}],
"loop": false,
"name": &"die",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_lfs1x")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8eiau")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lfs1x")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8eiau")
}],
"loop": false,
"name": &"hurt",
"speed": 10.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_0onds"]
radius = 7.071068
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lfs1x"]
size = Vector2(15, 2)
[sub_resource type="Animation" id="Animation_qnbj4"]
resource_name = "die"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CollisionShape2D:disabled")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("HitBox/CollisionShape2D:disabled")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Killzone/CollisionPolygon2D:disabled")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("RayCastRight:enabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("RayCastLeft:enabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/5/type = "bezier"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("AnimatedSprite2D:rotation")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"handle_modes": PackedInt32Array(0, 2),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, -1.0192723, -0.083333336, 0.16987872, 0, 0),
"times": PackedFloat32Array(0, 0.5)
}
tracks/6/type = "method"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath(".")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0.96666664),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [],
"method": &"queue_free"
}]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("Death:playing")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_r3bxh"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CollisionShape2D:disabled")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("HitBox/CollisionShape2D:disabled")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Killzone/CollisionPolygon2D:disabled")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("RayCastRight:enabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("RayCastLeft:enabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/5/type = "bezier"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("AnimatedSprite2D:rotation")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("Death:playing")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_wqpjq"]
_data = {
&"RESET": SubResource("Animation_r3bxh"),
&"die": SubResource("Animation_qnbj4")
}
[node name="Boss" type="CharacterBody2D"]
script = ExtResource("1_qnbj4")
speed = 100
hp = 4
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(0, -8.258226)
scale = Vector2(1.4583334, 1.4080526)
sprite_frames = SubResource("SpriteFrames_5f346")
autoplay = "default"
offset = Vector2(0, -6.135)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -7)
shape = SubResource("CircleShape2D_0onds")
[node name="HitBox" parent="." instance=ExtResource("2_qnbj4")]
collision_mask = 2
player_bounce = -200
[node name="CollisionShape2D" type="CollisionShape2D" parent="HitBox"]
position = Vector2(0, -18)
shape = SubResource("RectangleShape2D_lfs1x")
[node name="Killzone" parent="." instance=ExtResource("3_r3bxh")]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Killzone"]
position = Vector2(0, -10)
polygon = PackedVector2Array(-10, 10, 10, 10, 10, 4, 7, -3, -7, -3, -10, 5)
[node name="RayCastRight" type="RayCast2D" parent="."]
position = Vector2(0, -7)
target_position = Vector2(12, 0)
[node name="RayCastLeft" type="RayCast2D" parent="."]
position = Vector2(0, -7)
target_position = Vector2(-12, 0)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_wqpjq")
}
[node name="Hurt" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("5_r3bxh")
bus = &"SFX"
[node name="Death" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("6_wqpjq")
bus = &"SFX"
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="hit" from="HitBox" to="." method="_on_hit_box_hit"]