Fix Bullets

main
Luna Brovchuk 2023-10-02 20:02:24 +02:00
parent 306cde4a8a
commit 70840265fe
3 changed files with 22 additions and 25 deletions

View File

@ -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()

View File

@ -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")

View File

@ -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