Compare commits

...

2 Commits

Author SHA1 Message Date
Luna Brovchuk 9ce8c66680 Merge branch 'main' of http://meowo.cc:3000/meowo/LD54 2023-10-02 20:02:27 +02:00
Luna Brovchuk 70840265fe Fix Bullets 2023-10-02 20:02:24 +02:00
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) target_center = target.global_position + Vector2(0, 2)
self.global_position = self.global_position.move_toward(target_center, delta * speed * speed_modifier) self.global_position = self.global_position.move_toward(target_center, delta * speed * speed_modifier)
else: else:
self.call_deferred("free") call_deferred("free")
func area_entered(area): func area_entered(area):
var parent = area.get_parent() var parent = area.get_parent()

View File

@ -3,9 +3,7 @@ extends KinematicBody2D
var velocity = Vector2.ZERO var velocity = Vector2.ZERO
var sin_timer = .0 var sin_timer = .0
var speed = 64 var speed = 64
var poisoned = false
var damage = 8 var damage = 8
var frozen = false
var target var target
func _physics_process(delta): func _physics_process(delta):
@ -25,6 +23,4 @@ func area_entered(area):
var parent = area.get_parent() var parent = area.get_parent()
if parent.is_in_group("enemy"): if parent.is_in_group("enemy"):
parent.deal_damage(damage) parent.deal_damage(damage)
parent.frozen = frozen
parent.poisoned = poisoned
call_deferred("free") call_deferred("free")

View File

@ -5,17 +5,16 @@ var empty_material = load("res://res/shaders/empty_material.tres")
var hp var hp
var dead = false var dead = false
var dead_timer = .0 var dead_timer = .0
var poisoned = false var poison_damage = 0
var poisoned_timer = .0 var poisoned_timer = .0
var speed_multiplier = 1 var speed_multiplier = 1
var frozen_timer = .0 var frozen_timer = .0
var frozen_time = 2 var frozen_time = 2
var freeze_modifier = 1
var poisoned_time = 3 var poisoned_time = 3
var poisoned_damage = 5 var poisoned_damage_timer = .0
var poison_damage_timer = .0
var death_position var death_position
var frozen = false
func deal_damage(amount): func deal_damage(amount):
hp -= 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 $Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func death(): func death():
dead = true if not dead:
$Sprite.playing = false dead = true
$Area2D.call_deferred("free") $Sprite.playing = false
remove_from_group("enemy") $Area2D.call_deferred("free")
material = empty_material remove_from_group("enemy")
$Sprite.material = empty_material material = empty_material
$Sprite.material = empty_material
func _physics_process(delta): func _physics_process(delta):
if Global.playing: if Global.playing:
death_position = self.global_position
if dead: if dead:
self.global_position = death_position self.global_position = death_position
dead_timer += delta dead_timer += delta
$Sprite.modulate.a = 1 - (dead_timer * 2) $Sprite.modulate.a = 1 - (dead_timer * 2)
else:
death_position = self.global_position
if dead_timer >= 0.5: if dead_timer >= 0.5:
self.call_deferred("free") self.call_deferred("free")
if poisoned: if poison_damage != 0:
poisoned_timer += delta poisoned_timer += delta
poison_damage_timer += delta poisoned_damage_timer += delta
if poisoned_timer >= poisoned_time: if poisoned_timer >= poisoned_time:
poisoned_timer = .0 poisoned_timer = .0
poison_damage_timer = .0 poisoned_damage_timer = .0
poisoned = false poison_damage = 0
if poison_damage_timer >= 1: if poisoned_damage_timer >= 1:
deal_damage(poisoned_damage) deal_damage(poison_damage)
if frozen: if freeze_modifier != 1:
frozen_timer += delta frozen_timer += delta
speed_multiplier = 0.5 speed_multiplier = freeze_modifier
if frozen_timer >= frozen_time: if frozen_timer >= frozen_time:
frozen_time = 0 frozen_time = 0
frozen = false freeze_modifier = 1
else: else:
speed_multiplier = 1 speed_multiplier = 1