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:
parent
172830729f
commit
1794abe50a
3 changed files with 16 additions and 12 deletions
|
|
@ -87,7 +87,7 @@ size = Vector2(6, 5.75)
|
||||||
|
|
||||||
[node name="Player" type="Area2D" unique_id=652131079]
|
[node name="Player" type="Area2D" unique_id=652131079]
|
||||||
script = ExtResource("1_g2els")
|
script = ExtResource("1_g2els")
|
||||||
speed = 165
|
speed = 275
|
||||||
weapon_current = ExtResource("2_dqkch")
|
weapon_current = ExtResource("2_dqkch")
|
||||||
|
|
||||||
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
[node name="Player" parent="Level" unique_id=652131079 instance=ExtResource("2_rwgxs")]
|
[node name="Player" parent="Level" unique_id=652131079 instance=ExtResource("2_rwgxs")]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
position = Vector2(97, 173)
|
position = Vector2(97, 173)
|
||||||
|
speed = 200
|
||||||
|
|
||||||
[node name="Background" type="Node2D" parent="Level" unique_id=485120278]
|
[node name="Background" type="Node2D" parent="Level" unique_id=485120278]
|
||||||
z_index = -1
|
z_index = -1
|
||||||
|
|
|
||||||
|
|
@ -87,17 +87,20 @@ func _on_weapon_cooldown_timeout() -> void:
|
||||||
|
|
||||||
|
|
||||||
func shoot():
|
func shoot():
|
||||||
# Instantiate the bullet
|
var projectiles: int = 2
|
||||||
var bullet = weapon_current.instantiate()
|
for b in projectiles:
|
||||||
get_tree().root.add_child(bullet)
|
|
||||||
bullet.position = position + Vector2(0,-23)
|
|
||||||
|
|
||||||
# Get weapon speed and spacing for equidistant calculations
|
# Instantiate the bullets
|
||||||
weapon_rate = bullet.shot_data.rate
|
var bullet = weapon_current.instantiate()
|
||||||
weapon_spacing = bullet.shot_data.spacing
|
get_tree().root.add_child(bullet)
|
||||||
bullet_speed = abs(bullet.shot_data.speed)
|
bullet.position = position + Vector2((b * 10) - (projectiles * projectiles),-23)
|
||||||
|
|
||||||
# Print which weapon is firing
|
# Get weapon speed and spacing for equidistant calculations
|
||||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
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")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue