diff --git a/src/models/bullet/bullet.gd b/src/models/bullet/bullet.gd index 5d01120..a54fada 100644 --- a/src/models/bullet/bullet.gd +++ b/src/models/bullet/bullet.gd @@ -33,7 +33,7 @@ func _physics_process(delta): target_center = target.global_position + Vector2(0, 2) self.global_position = self.global_position.move_toward(target_center, delta * speed * speed_modifier) else: - self.call_deferred("free") + call_deferred("free") func area_entered(area): var parent = area.get_parent() diff --git a/src/models/fireball/fireball.gd b/src/models/fireball/fireball.gd index 71489b3..389ab9a 100644 --- a/src/models/fireball/fireball.gd +++ b/src/models/fireball/fireball.gd @@ -3,9 +3,7 @@ extends KinematicBody2D var velocity = Vector2.ZERO var sin_timer = .0 var speed = 64 -var poisoned = false var damage = 8 -var frozen = false var target func _physics_process(delta): @@ -25,6 +23,4 @@ func area_entered(area): var parent = area.get_parent() if parent.is_in_group("enemy"): parent.deal_damage(damage) - parent.frozen = frozen - parent.poisoned = poisoned call_deferred("free") diff --git a/src/scripts/enemy_class.gd b/src/scripts/enemy_class.gd index ab81859..7135964 100644 --- a/src/scripts/enemy_class.gd +++ b/src/scripts/enemy_class.gd @@ -5,17 +5,16 @@ var empty_material = load("res://res/shaders/empty_material.tres") var hp var dead = false var dead_timer = .0 -var poisoned = false +var poison_damage = 0 var poisoned_timer = .0 var speed_multiplier = 1 var frozen_timer = .0 var frozen_time = 2 +var freeze_modifier = 1 var poisoned_time = 3 -var poisoned_damage = 5 -var poison_damage_timer = .0 +var poisoned_damage_timer = .0 var death_position -var frozen = false func deal_damage(amount): hp -= amount @@ -29,39 +28,41 @@ func _process(delta): $Sprite.flip_h = true if player.global_position.x > self.global_position.x else false func death(): - dead = true - $Sprite.playing = false - $Area2D.call_deferred("free") - remove_from_group("enemy") - material = empty_material - $Sprite.material = empty_material + if not dead: + dead = true + $Sprite.playing = false + $Area2D.call_deferred("free") + remove_from_group("enemy") + material = empty_material + $Sprite.material = empty_material func _physics_process(delta): if Global.playing: - death_position = self.global_position if dead: self.global_position = death_position dead_timer += delta $Sprite.modulate.a = 1 - (dead_timer * 2) + else: + death_position = self.global_position if dead_timer >= 0.5: self.call_deferred("free") - if poisoned: + if poison_damage != 0: poisoned_timer += delta - poison_damage_timer += delta + poisoned_damage_timer += delta if poisoned_timer >= poisoned_time: poisoned_timer = .0 - poison_damage_timer = .0 - poisoned = false - if poison_damage_timer >= 1: - deal_damage(poisoned_damage) + poisoned_damage_timer = .0 + poison_damage = 0 + if poisoned_damage_timer >= 1: + deal_damage(poison_damage) - if frozen: + if freeze_modifier != 1: frozen_timer += delta - speed_multiplier = 0.5 + speed_multiplier = freeze_modifier if frozen_timer >= frozen_time: frozen_time = 0 - frozen = false + freeze_modifier = 1 else: speed_multiplier = 1