ape-ame/tar.gd

53 lines
1 KiB
GDScript3
Raw Normal View History

2024-04-29 16:27:25 -04:00
extends RigidBody2D
var phase2_active = false
var health = 10
2024-05-06 10:05:42 -04:00
var spawn_remaining = 7
2024-04-29 16:27:25 -04:00
@onready var player = $"../Player"
func hit(body):
2024-05-06 10:05:42 -04:00
if not phase2_active:
return
2024-04-29 16:27:25 -04:00
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()
2024-04-24 15:20:36 -04:00
2024-04-26 16:32:56 -04:00
func _ready():
await get_tree().create_timer(1).timeout
phase()
2024-04-29 16:27:25 -04:00
func _physics_process(delta):
if phase2_active:
2024-04-30 15:37:00 -04:00
apply_central_force((global_position - player.global_position).normalized() * -1600)
2024-04-26 16:32:56 -04:00
2024-04-24 15:20:36 -04:00
func phase():
2024-04-29 16:27:25 -04:00
if phase2_active:
return
if spawn_remaining <= 0:
phase2()
return
spawn_remaining -= 1
2024-04-24 15:20:36 -04:00
$Sprite.play("spawn")
$"Riangle Zone".spawn()
await get_tree().create_timer(1).timeout
$Sprite.play("idle")
2024-04-25 15:27:00 -04:00
$"Riangle Zone".eject()
2024-04-29 16:27:25 -04:00
func phase2():
$Sprite.play("transform")
await $Sprite.animation_finished
$Sprite.play("phase2")
phase2_active = true
freeze = false