32 lines
655 B
GDScript
32 lines
655 B
GDScript
extends ProjectileBase
|
|
|
|
var _is_spread_child := false
|
|
|
|
const DIRS := [
|
|
Vector2(1, 0),
|
|
Vector2(0.707107, 0.707107),
|
|
Vector2(0, 1),
|
|
Vector2(-0.707107, 0.707107),
|
|
Vector2(-1, 0),
|
|
Vector2(-0.707107, -0.707107),
|
|
Vector2(0, -1),
|
|
Vector2(0.707107, -0.707107),
|
|
]
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("enemies"):
|
|
body.hit()
|
|
|
|
func _ready() -> void:
|
|
if _is_spread_child:
|
|
super()
|
|
return
|
|
var spawn_pos = global_position
|
|
for dir in DIRS:
|
|
var bullet = duplicate()
|
|
bullet._is_spread_child = true
|
|
get_parent().add_child(bullet)
|
|
bullet.global_position = spawn_pos
|
|
bullet.launch(spawn_pos + dir * 1000)
|
|
queue_free()
|