spreads and stacks!
This commit is contained in:
parent
08763960ca
commit
8eb39f4a70
5 changed files with 72 additions and 22 deletions
27
systems/bullets/spawn_patterns/spread_pattern.gd
Normal file
27
systems/bullets/spawn_patterns/spread_pattern.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
class_name SpreadPattern
|
||||
extends BulletSpawnPattern
|
||||
|
||||
|
||||
## Number of bullets to spawn along the spread.
|
||||
@export_range(1, 1, 1, "or_greater") var bullet_count: int
|
||||
## The speed that bullets will start with.
|
||||
@export var bullet_speed: float
|
||||
|
||||
## Angular distance between first and last bullet.
|
||||
@export_range(0.0, 360.0, 0.1, "radians_as_degrees") var spread
|
||||
## Radius of the arc that bullets spawn along the edge of.
|
||||
@export var radius: float
|
||||
## Rotation of the entire pattern.
|
||||
@export_custom(0, "radians_as_degrees") var angle_offset: float
|
||||
## Rotation of each bullet's travel direction.
|
||||
@export_custom(0, "radians_as_degrees") var direction_rotation: float
|
||||
|
||||
|
||||
func _spawn_bullets(bullet_set: BulletSet, preset: BulletPreset) -> void:
|
||||
for i in bullet_count:
|
||||
var angle = remap(float(i), 0.0, float(bullet_count - 1), -spread * 0.5, spread * 0.5)
|
||||
angle += angle_offset + bullet_set.spawn_rotation
|
||||
var bullet = Bullet.create(preset, Vector2.from_angle(angle + direction_rotation))
|
||||
bullet.speed = bullet_speed
|
||||
bullet.position = bullet_set.spawn_offset + Vector2.from_angle(angle) * radius
|
||||
bullet_set.add_bullet(bullet)
|
||||
Loading…
Add table
Add a link
Reference in a new issue