Attempting to refactor the previously working self contained equidistent

code in the player.gd.
This commit is contained in:
Henry 2026-04-06 12:46:36 +01:00
parent 5d2efe9983
commit d419635d7f
15 changed files with 153 additions and 46 deletions

View file

@ -8,27 +8,26 @@ var weapon_spacing: float = 0.1
func shoot():
# Continuous fire
if player.is_shooting == true:
# Adjust bullet spacing before firing
if player.travel > weapon_component.bullet_data.projectile_spacing:
print("Travel is greater!")
for b in range(weapon_component.bullet_data.projectiles):
# Instantiate the bullets
var bullet = weapon_component.weapon_current.instantiate()
get_tree().root.add_child(bullet)
# Adjust bullet spacing before firing
bullet.position = player.position + Vector2((b - (weapon_component.bullet_data.projectiles - 1) / 2.0) * weapon_component.bullet_data.projectile_spacing, weapon_component.bullet_data.projectile_origin)
## Get weapon speed and spacing for equidistant calculations
#weapon_rate = bullet.weapon_component.bullet_data.rate
#weapon_spacing = bullet.weapon_component.bullet_data.projectile_spacing
#bullet.weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
#weapon_component.bullet_data.projectile_spacing = bullet.weapon_component.bullet_data.projectile_spacing
#weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
# Print which weapon is firing
prints(bullet.shot_data.shot_name, "weapon fired")
player.travel -= weapon_component.bullet_data.projectile_spacing
else: return