paratate/systems/bullets/spawn_patterns/line_pattern.gd

26 lines
644 B
GDScript

class_name LinePattern
extends BulletSpawnPattern
@export var bullet_count: int
@export var line_width: float
@export_custom(0, "direction") var line_normal: Vector2 = Vector2.RIGHT
func spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
for i in bullet_count:
var bullet = Bullet.create(
preset.textures.pick_random(),
preset.hitbox_size,
line_normal,
preset.face_direction
)
var line = line_normal.orthogonal()
var weight = float(i) / float(bullet_count - 1)
weight -= 0.5
if bullet_count == 1:
weight = 0.0
bullet.position = line * weight * line_width
bullet_set.add_bullet(bullet)