ape-ame/tar.gd
ultrablob 8cb01d7918
All checks were successful
CI / build (push) Successful in 2m23s
ite update
2025-02-05 18:20:26 -05:00

53 lines
1.1 KiB
GDScript

extends RigidBody2D
var phase2_active = false
var health = 10
var spawn_remaining = 7
@onready var player = $"../Player"
func hit(body):
if not phase2_active:
return
if body.is_in_group("destructible"):
if body.has_method("destroy"):
body.destroy()
else:
body.queue_free()
health -= 1
if body.name == "Border":
health -= 1
if health <= 0 and not is_queued_for_deletion():
# do the death stuff
queue_free()
func _ready():
await get_tree().create_timer(1).timeout
phase()
func _physics_process(delta):
if phase2_active:
#print((global_position - player.global_position).normalized())
apply_central_force((global_position - (player.global_position + player.linear_velocity * 1)).normalized() * -1600 * (player.speed / 1000.0))
func phase():
if phase2_active:
return
if spawn_remaining <= 0:
phase2()
return
spawn_remaining -= 1
$Sprite.play("spawn")
$"Riangle Zone".spawn()
await get_tree().create_timer(1).timeout
$Sprite.play("idle")
$"Riangle Zone".eject()
func phase2():
$Sprite.play("transform")
await $Sprite.animation_finished
$Sprite.play("phase2")
phase2_active = true
freeze = false