Slight update to fire timing to allow for even pairs.
This commit is contained in:
parent
936bcbc5e3
commit
48a2ba3ddb
3 changed files with 41 additions and 24 deletions
|
|
@ -23,27 +23,24 @@ func shoot():
|
|||
get_tree().root.add_child(bullet)
|
||||
|
||||
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
||||
var index_from_center: int = b - center_index
|
||||
var index_from_center: float = b - center_index
|
||||
|
||||
# Calculate timing offset for staggered firing
|
||||
# Negative = fire before center (left), positive = fire after center (right)
|
||||
var time_offset: float = index_from_center * stagger_offset
|
||||
|
||||
# Calculate horizontal offset for symmetrical spread (left = negative, right = positive)
|
||||
horizontal_offset = index_from_center * weapon_data.horizontal_offset
|
||||
# Calculate horizontal offset for this bullet (symmetrical: left=-ve, right=+ve)
|
||||
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
||||
|
||||
# Calculate vertical offset from center point (creates symmetrical vertical spread)
|
||||
# Bullets on either side of center get offset by distance_from_center * spacing / 2
|
||||
# This keeps the center bullet at origin and creates symmetrical vertical spread
|
||||
# Calculate vertical offset from center point (symmetrical vertical spread)
|
||||
var distance_from_center: float = abs(index_from_center)
|
||||
var vertical_offset: float = (distance_from_center * weapon_data.origin * -1) / 2
|
||||
|
||||
# Final position combines symmetrical horizontal spread with symmetrical vertical spacing
|
||||
bullet.position = player.position + Vector2(horizontal_offset, weapon_data.origin + vertical_offset)
|
||||
bullet.position = player.position + Vector2(bullet_horizontal_offset, weapon_data.origin + vertical_offset)
|
||||
|
||||
## Set timing properties on the bullet
|
||||
#bullet.time_offset = time_offset
|
||||
#bullet.fire_time = current_time + time_offset
|
||||
# Set timing properties on the bullet
|
||||
bullet.time_offset = time_offset
|
||||
bullet.fire_time = current_time + time_offset
|
||||
|
||||
# Subtract projectile spacing from current Player travel for next
|
||||
player.travel -= weapon_data.spacing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue