From 1794abe50a01760fc71843c8304d2f81d7834013 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 4 Apr 2026 15:17:13 +0100 Subject: [PATCH] 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. --- scenes/player.tscn | 2 +- scenes/world.tscn | 1 + scripts/player.gd | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scenes/player.tscn b/scenes/player.tscn index 7233823..d3bdfa5 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -87,7 +87,7 @@ size = Vector2(6, 5.75) [node name="Player" type="Area2D" unique_id=652131079] script = ExtResource("1_g2els") -speed = 165 +speed = 275 weapon_current = ExtResource("2_dqkch") [node name="Ship" type="Sprite2D" parent="." unique_id=1155866924] diff --git a/scenes/world.tscn b/scenes/world.tscn index b0110e3..859bfd0 100644 --- a/scenes/world.tscn +++ b/scenes/world.tscn @@ -13,6 +13,7 @@ [node name="Player" parent="Level" unique_id=652131079 instance=ExtResource("2_rwgxs")] z_index = 1 position = Vector2(97, 173) +speed = 200 [node name="Background" type="Node2D" parent="Level" unique_id=485120278] z_index = -1 diff --git a/scripts/player.gd b/scripts/player.gd index 9d12920..c3a4b34 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -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")