virus deals damage and takes double damage while spawning

This commit is contained in:
SondreElg
2025-10-05 14:11:03 +02:00
parent 44b8d2504b
commit 724139155e
2 changed files with 21 additions and 5 deletions

View File

@@ -65,6 +65,9 @@ func set_spawned():
func take_hit(damage, knockback_vector, knockback_strength = 1): func take_hit(damage, knockback_vector, knockback_strength = 1):
$HitSFX.play(); $HitSFX.play();
if self.spawning_state == SpawningState.Spawning:
health -= damage * 2
else:
health -= damage health -= damage
if health <= 0: if health <= 0:
queue_free() queue_free()
@@ -72,3 +75,6 @@ func take_hit(damage, knockback_vector, knockback_strength = 1):
knockback = -knockback_vector; knockback = -knockback_vector;
knockback_timer.start(0.2 * knockback_strength); knockback_timer.start(0.2 * knockback_strength);
# Flash white? # Flash white?
func _on_body_entered(body: Node2D) -> void:
body.take_hit(1, self.position.direction_to(body.position) * 100, 2)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=30 format=3 uid="uid://bsv3h2lpv7h77"] [gd_scene load_steps=31 format=3 uid="uid://bsv3h2lpv7h77"]
[ext_resource type="Script" uid="uid://bwhxwf77egesx" path="res://virus.gd" id="1_5nuwd"] [ext_resource type="Script" uid="uid://bwhxwf77egesx" path="res://virus.gd" id="1_5nuwd"]
[ext_resource type="Texture2D" uid="uid://mbey3bjcno10" path="res://assets/animations/Enemy_1_MERGED/Grow 1.png" id="2_2g5hr"] [ext_resource type="Texture2D" uid="uid://mbey3bjcno10" path="res://assets/animations/Enemy_1_MERGED/Grow 1.png" id="2_2g5hr"]
@@ -227,8 +227,11 @@ animations = [{
"speed": 5.0 "speed": 5.0
}] }]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ifgnm"] [sub_resource type="CircleShape2D" id="CircleShape2D_ob56v"]
size = Vector2(128, 128) radius = 85.0
[sub_resource type="CircleShape2D" id="CircleShape2D_lk7jo"]
radius = 120.0
[node name="Virus" type="Node2D"] [node name="Virus" type="Node2D"]
position = Vector2(0, -1) position = Vector2(0, -1)
@@ -261,4 +264,11 @@ collision_layer = 31
collision_mask = 31 collision_mask = 31
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("RectangleShape2D_ifgnm") shape = SubResource("CircleShape2D_ob56v")
[node name="Hurtbox" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
shape = SubResource("CircleShape2D_lk7jo")
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]