diff --git a/res/shaders/empty_material.tres b/res/shaders/empty_material.tres new file mode 100644 index 0000000..24e7954 --- /dev/null +++ b/res/shaders/empty_material.tres @@ -0,0 +1,3 @@ +[gd_resource type="ShaderMaterial" format=2] + +[resource] diff --git a/src/models/bullet/bullet.gd b/src/models/bullet/bullet.gd index ce9b2d8..57821e7 100644 --- a/src/models/bullet/bullet.gd +++ b/src/models/bullet/bullet.gd @@ -8,7 +8,7 @@ var frozen = false var target func _physics_process(delta): - if target != null and is_instance_valid(target): + if target != null and is_instance_valid(target) and not target.dead: var target_texture = target.get_node("Sprite").frames.get_frame("idle", 0) var target_sprite_size = Vector2(target_texture.get_width(), target_texture.get_width()) var target_center = target.global_position + (target_sprite_size / 2) diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index cbd8d2a..940b0be 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -19,7 +19,6 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 3 playing = true centered = false diff --git a/src/models/enemies/ghost/Ghost.tscn b/src/models/enemies/ghost/Ghost.tscn index df33a2d..13e0c74 100644 --- a/src/models/enemies/ghost/Ghost.tscn +++ b/src/models/enemies/ghost/Ghost.tscn @@ -25,7 +25,7 @@ flip_h = true use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 1 +frame = 4 playing = true centered = false diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn index 34a0e7a..384a845 100644 --- a/src/models/enemies/rat/Rat.tscn +++ b/src/models/enemies/rat/Rat.tscn @@ -13,7 +13,7 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 1 +frame = 2 playing = true centered = false diff --git a/src/models/fireball/fireball.gd b/src/models/fireball/fireball.gd index 2b8273b..71489b3 100644 --- a/src/models/fireball/fireball.gd +++ b/src/models/fireball/fireball.gd @@ -4,13 +4,13 @@ var velocity = Vector2.ZERO var sin_timer = .0 var speed = 64 var poisoned = false -var damage = 5 +var damage = 8 var frozen = false var target func _physics_process(delta): sin_timer += delta - if target != null and is_instance_valid(target): + if target != null and is_instance_valid(target) and not target.dead: var target_texture = target.get_node("Sprite").frames.get_frame("idle", 0) var target_sprite_size = Vector2(target_texture.get_width(), target_texture.get_width()) var target_center = target.global_position + (target_sprite_size / 2) diff --git a/src/scripts/enemy_class.gd b/src/scripts/enemy_class.gd index a188a8c..576905c 100644 --- a/src/scripts/enemy_class.gd +++ b/src/scripts/enemy_class.gd @@ -1,6 +1,9 @@ extends KinematicBody2D +var empty_material = load("res://res/shaders/empty_material.tscn") var hp +var dead = false +var dead_timer = .0 var poisoned = false var poisoned_timer = .0 var speed_multiplier = 1 @@ -15,9 +18,22 @@ var frozen = false func deal_damage(amount): hp -= amount if hp <= 0: - call_deferred("free") + death() + +func death(): + dead = true + $Area2D.call_deferred("free") + remove_from_group("enemy") + material = empty_material + $Sprite.material = empty_material func _physics_process(delta): + if dead: + dead_timer += delta + $Sprite.modulate.a = 1 - (dead_timer / 2) + if dead_timer >= 2.0: + self.call_deferred("free") + if poisoned: poisoned_timer += delta poison_damage_timer += delta