Adjusted the shoot function to shoot as many projectiles as defined in a

local variable and ensure they are distributed evenly when firing in
front of the ship.
This commit is contained in:
Henry 2026-04-04 15:17:13 +01:00
parent 172830729f
commit 1794abe50a
3 changed files with 16 additions and 12 deletions

View file

@ -87,17 +87,20 @@ func _on_weapon_cooldown_timeout() -> void:
func shoot():
# Instantiate the bullet
var bullet = weapon_current.instantiate()
get_tree().root.add_child(bullet)
bullet.position = position + Vector2(0,-23)
var projectiles: int = 2
for b in projectiles:
# Get weapon speed and spacing for equidistant calculations
weapon_rate = bullet.shot_data.rate
weapon_spacing = bullet.shot_data.spacing
bullet_speed = abs(bullet.shot_data.speed)
# Print which weapon is firing
prints(bullet.shot_data.shot_name, "weapon fired")
# Instantiate the bullets
var bullet = weapon_current.instantiate()
get_tree().root.add_child(bullet)
bullet.position = position + Vector2((b * 10) - (projectiles * projectiles),-23)
# Get weapon speed and spacing for equidistant calculations
weapon_rate = bullet.shot_data.rate
weapon_spacing = bullet.shot_data.spacing
bullet_speed = abs(bullet.shot_data.speed)
# Print which weapon is firing
prints(bullet.shot_data.shot_name, "weapon fired")