Added traps

This commit is contained in:
2026-01-08 15:13:28 +03:00
parent 4528b4a61a
commit 9431bb4f44
7 changed files with 96 additions and 4 deletions
+4 -1
View File
@@ -1,8 +1,9 @@
[gd_scene load_steps=45 format=3 uid="uid://bx0luh4vdob3q"]
[gd_scene load_steps=46 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"]
[ext_resource type="PackedScene" uid="uid://dpvsvsd8pcjqn" path="res://game/player_killer.tscn" id="4_vecdo"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vecdo"]
shader = ExtResource("2_tjvyk")
@@ -370,5 +371,7 @@ animation = &"idle_front"
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_mocsw")
[node name="PlayerKiller" parent="." instance=ExtResource("4_vecdo")]
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
[connection signal="animation_looped" from="AnimatedSprite2D" to="." method="_on_animation_looped"]
+8 -1
View File
@@ -62,7 +62,7 @@ func _physics_process(delta: float) -> void:
if was_collided and _is_alive:
for i in range(get_slide_collision_count()):
var collision := get_slide_collision(i)
if collision.get_collider() is AbstractEnemy:
if _is_killing_collider(collision.get_collider()):
_is_alive = false
collision_mask = 1
get_tree().paused = true
@@ -91,6 +91,13 @@ func _slow_down(delta: float) -> void:
velocity.x = move_toward(velocity.x, 0, acceleration * delta)
func _is_killing_collider(collider: Object) -> bool:
if not collider is Node: return false
var node := collider as Node
return node.has_node("PlayerKiller")
func _update_animation() -> void:
var animation := _get_animation()
if sprite.animation != animation: