Added enemies

This commit is contained in:
2026-01-07 22:00:05 +03:00
parent 33cbfeebb9
commit 85f808b733
28 changed files with 729 additions and 26 deletions
+9
View File
@@ -0,0 +1,9 @@
class_name AbstractColorEnemy
extends AbstractEnemy
@onready var collision_switcher : CollisionSwitcher = $CollisionSwitcher
func _ready() -> void:
collision_switcher.material = sprite.material
@@ -0,0 +1 @@
uid://das7ujanefsn0
+26
View File
@@ -0,0 +1,26 @@
[gd_scene load_steps=6 format=3 uid="uid://d37eyum03h83i"]
[ext_resource type="PackedScene" uid="uid://bx0luh4vdob3q" path="res://game/characters/abstract_enemy.tscn" id="1_12hr0"]
[ext_resource type="Script" uid="uid://das7ujanefsn0" path="res://game/characters/abstract_color_enemy.gd" id="2_rd56i"]
[ext_resource type="PackedScene" uid="uid://5qlocc0yu8ug" path="res://game/collision_switcher.tscn" id="3_e5cea"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_r5rx0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ybui5"]
resource_local_to_scene = true
shader = ExtResource("3_r5rx0")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="AbstractColorEnemy" instance=ExtResource("1_12hr0")]
script = ExtResource("2_rd56i")
[node name="AnimatedSprite2D" parent="." index="0"]
material = SubResource("ShaderMaterial_ybui5")
[node name="CollisionSwitcher" parent="." index="2" node_paths=PackedStringArray("object") instance=ExtResource("3_e5cea")]
object = NodePath("..")
+5
View File
@@ -0,0 +1,5 @@
class_name AbstractEnemy
extends CharacterBody2D
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
+1
View File
@@ -0,0 +1 @@
uid://but5aeh7y1s0f
+371
View File
@@ -0,0 +1,371 @@
[gd_scene load_steps=45 format=3 uid="uid://bx0luh4vdob3q"]
[ext_resource type="Script" uid="uid://but5aeh7y1s0f" path="res://game/characters/abstract_enemy.gd" id="1_2wrno"]
[ext_resource type="Texture2D" uid="uid://drk8j57acajrq" path="res://images/characters/cultist.png" id="2_mocsw"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="2_tjvyk"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vecdo"]
shader = ExtResource("2_tjvyk")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[sub_resource type="AtlasTexture" id="AtlasTexture_tjvyk"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vecdo"]
atlas = ExtResource("2_mocsw")
region = Rect2(64, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qly8p"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_klrad"]
atlas = ExtResource("2_mocsw")
region = Rect2(160, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_rjy0i"]
atlas = ExtResource("2_mocsw")
region = Rect2(96, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ps2ar"]
atlas = ExtResource("2_mocsw")
region = Rect2(32, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ijx3p"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_nm8xp"]
atlas = ExtResource("2_mocsw")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_mocsw"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_y256a"]
atlas = ExtResource("2_mocsw")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8wpvf"]
atlas = ExtResource("2_mocsw")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vbirv"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ntvg2"]
atlas = ExtResource("2_mocsw")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ssc8d"]
atlas = ExtResource("2_mocsw")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hrljr"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ng7ok"]
atlas = ExtResource("2_mocsw")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8s45y"]
atlas = ExtResource("2_mocsw")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qbqct"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ga5mk"]
atlas = ExtResource("2_mocsw")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_yu2nn"]
atlas = ExtResource("2_mocsw")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_g4v8m"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_20lqo"]
atlas = ExtResource("2_mocsw")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_l58xb"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_jrclg"]
atlas = ExtResource("2_mocsw")
region = Rect2(32, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwee"]
atlas = ExtResource("2_mocsw")
region = Rect2(64, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_law7y"]
atlas = ExtResource("2_mocsw")
region = Rect2(96, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hme24"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qawtf"]
atlas = ExtResource("2_mocsw")
region = Rect2(160, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_srxh4"]
atlas = ExtResource("2_mocsw")
region = Rect2(192, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_x6npu"]
atlas = ExtResource("2_mocsw")
region = Rect2(224, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xavx3"]
atlas = ExtResource("2_mocsw")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8t4m8"]
atlas = ExtResource("2_mocsw")
region = Rect2(32, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_3seah"]
atlas = ExtResource("2_mocsw")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_koyeg"]
atlas = ExtResource("2_mocsw")
region = Rect2(96, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_uw3v1"]
atlas = ExtResource("2_mocsw")
region = Rect2(128, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_265lf"]
atlas = ExtResource("2_mocsw")
region = Rect2(160, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tav7c"]
atlas = ExtResource("2_mocsw")
region = Rect2(192, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0xs27"]
atlas = ExtResource("2_mocsw")
region = Rect2(224, 32, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_2wrno"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_tjvyk")
}],
"loop": true,
"name": &"fall_down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_vecdo")
}],
"loop": true,
"name": &"fall_down_left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qly8p")
}],
"loop": true,
"name": &"fall_down_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_klrad")
}],
"loop": true,
"name": &"fall_up",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rjy0i")
}],
"loop": true,
"name": &"fall_up_left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ps2ar")
}],
"loop": true,
"name": &"fall_up_right",
"speed": 5.0
}, {
"frames": [{
"duration": 9.0,
"texture": SubResource("AtlasTexture_ijx3p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nm8xp")
}],
"loop": true,
"name": &"idle_front",
"speed": 5.0
}, {
"frames": [{
"duration": 9.0,
"texture": SubResource("AtlasTexture_mocsw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y256a")
}],
"loop": true,
"name": &"idle_rear",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_8wpvf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vbirv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ntvg2")
}],
"loop": false,
"name": &"look_around_front_1",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ssc8d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hrljr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ng7ok")
}],
"loop": false,
"name": &"look_around_front_2",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_8s45y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qbqct")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ga5mk")
}],
"loop": false,
"name": &"look_around_rear_1",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_yu2nn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_g4v8m")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_20lqo")
}],
"loop": false,
"name": &"look_around_rear_2",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_l58xb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jrclg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wwwee")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_law7y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hme24")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qawtf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_srxh4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x6npu")
}],
"loop": true,
"name": &"walk_left",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_xavx3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8t4m8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3seah")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_koyeg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uw3v1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_265lf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tav7c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xs27")
}],
"loop": true,
"name": &"walk_right",
"speed": 10.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_mocsw"]
radius = 4.0
height = 28.0
[node name="AbstractEnemy" type="CharacterBody2D"]
collision_layer = 0
script = ExtResource("1_2wrno")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
material = SubResource("ShaderMaterial_vecdo")
sprite_frames = SubResource("SpriteFrames_2wrno")
animation = &"walk_right"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_mocsw")
+2
View File
@@ -0,0 +1,2 @@
class_name BlackEnemy
extends AbstractColorEnemy
+1
View File
@@ -0,0 +1 @@
uid://c2knsjcp6faf6
+26
View File
@@ -0,0 +1,26 @@
[gd_scene load_steps=5 format=3 uid="uid://cutjutvd8dqqc"]
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/abstract_color_enemy.tscn" id="1_gj2ks"]
[ext_resource type="Script" uid="uid://c2knsjcp6faf6" path="res://game/characters/black_enemy.gd" id="2_332ds"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_3jy5n"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3jy5n"]
resource_local_to_scene = true
shader = ExtResource("3_3jy5n")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = true
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="BlackEnemy" instance=ExtResource("1_gj2ks")]
collision_layer = 4
script = ExtResource("2_332ds")
[node name="AnimatedSprite2D" parent="." index="0"]
material = SubResource("ShaderMaterial_3jy5n")
[node name="CollisionSwitcher" parent="." index="2"]
initial_state = 0
+2
View File
@@ -0,0 +1,2 @@
class_name GrayEnemy
extends AbstractEnemy
+1
View File
@@ -0,0 +1 @@
uid://cern5veiqkrkc
+23
View File
@@ -0,0 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://cb0w6mt8g4mer"]
[ext_resource type="PackedScene" uid="uid://bx0luh4vdob3q" path="res://game/characters/abstract_enemy.tscn" id="1_q3s46"]
[ext_resource type="Script" uid="uid://cern5veiqkrkc" path="res://game/characters/gray_enemy.gd" id="2_olede"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_ho47d"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hsdrn"]
shader = ExtResource("3_ho47d")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 0.70000003325
shader_parameter/scale = 20.0
[node name="GrayEnemy" instance=ExtResource("1_q3s46")]
collision_layer = 16
collision_mask = 137
script = ExtResource("2_olede")
[node name="AnimatedSprite2D" parent="." index="0"]
material = SubResource("ShaderMaterial_hsdrn")
+11 -1
View File
@@ -2,6 +2,9 @@ class_name Player
extends CharacterBody2D
signal dead
const ANIMATION_IDLE = "idle"
const ANIMATION_LOOK_AROUND_1 = "look_around_1"
const ANIMATION_LOOK_AROUND_2 = "look_around_2"
@@ -47,7 +50,14 @@ func _physics_process(delta: float) -> void:
velocity.x = move_toward(velocity.x, 0, acceleration * delta)
_update_animation()
move_and_slide()
var was_collided := move_and_slide()
if was_collided:
for i in range(get_slide_collision_count()):
var collision := get_slide_collision(i)
if collision.get_collider() is AbstractEnemy:
queue_free()
dead.emit()
func _input(event: InputEvent) -> void:
+1 -1
View File
@@ -307,7 +307,7 @@ script = ExtResource("1_xln5q")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
material = SubResource("ShaderMaterial_i05k5")
sprite_frames = SubResource("SpriteFrames_v8w1g")
animation = &"fall_up"
animation = &"look_around_1"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 1)
+2
View File
@@ -0,0 +1,2 @@
class_name WhiteEnemy
extends AbstractColorEnemy
+1
View File
@@ -0,0 +1 @@
uid://dmcpkytgiuedi
+24
View File
@@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://bv2gahb4wxgb1"]
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/abstract_color_enemy.tscn" id="1_3yi7g"]
[ext_resource type="Script" uid="uid://dmcpkytgiuedi" path="res://game/characters/white_enemy.gd" id="2_c7pdf"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_uj6yw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gfhm1"]
resource_local_to_scene = true
shader = ExtResource("3_uj6yw")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="WhiteEnemy" instance=ExtResource("1_3yi7g")]
collision_layer = 64
collision_mask = 129
script = ExtResource("2_c7pdf")
[node name="AnimatedSprite2D" parent="." index="0"]
material = SubResource("ShaderMaterial_gfhm1")