diff options
Diffstat (limited to 'dicaprio.gd')
-rw-r--r-- | dicaprio.gd | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dicaprio.gd b/dicaprio.gd new file mode 100644 index 0000000..3750015 --- /dev/null +++ b/dicaprio.gd @@ -0,0 +1,28 @@ +extends Area2D + +@onready var player: Node2D = get_node("../Player") +@export var speed = 2.0 +@export var life = 3.0 + + +func type() -> String: return "dicaprio" + + +func _physics_process(_delta: float) -> void: + $Glitch.position = Vector2(randf_range(-16, 16), randf_range(-16, 16)) + $Glitch.modulate.r = randi() % 2 + $Glitch.modulate.g = randi() % 2 + $Glitch.modulate.b = randi() % 2 + position += (player.position - position).normalized() * speed + + +func _on_area_entered(area: Area2D) -> void: + if area.type() == "arrow": + area.damage(self) + + +func damage(x: float) -> void: + life -= x + if life <= 0: + Globals.spawn_primogem(position) + queue_free() |