Attempting to set up equidistant bullets based on player movement.

This commit is contained in:
Henry 2026-03-21 18:30:26 +00:00
parent 142bf87eca
commit 07c63f4122
4 changed files with 25 additions and 4 deletions

View file

@ -2,6 +2,6 @@
[ext_resource type="PackedScene" uid="uid://bj4fytc3sy482" path="res://scenes/world.tscn" id="1_uwrxv"]
[node name="Game" type="Node2D" unique_id=1673976895]
[node name="Main" type="Node2D" unique_id=1673976895]
[node name="World" parent="." unique_id=1317852169 instance=ExtResource("1_uwrxv")]

View file

@ -4,9 +4,15 @@
[ext_resource type="Resource" uid="uid://cels8t3hqjtsu" path="res://resources/shot_stock.tres" id="2_ckjv1"]
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_mvdrj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
size = Vector2(12, 8)
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
script = ExtResource("1_hsma2")
shot_data = ExtResource("2_ckjv1")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225]
texture = ExtResource("3_mvdrj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
shape = SubResource("RectangleShape2D_mvdrj")

View file

@ -46,7 +46,7 @@ func _process(delta):
if is_shooting == false: return
func shield_set(_sdvalue: int):
func shield_set(_value: int):
return
@ -64,9 +64,22 @@ func shoot():
bullet.position = self.position + Vector2(0,-12)
get_tree().root.add_child(bullet)
weapon_rate = bullet.shot_data.rate
print(bullet.shot_data.shot_name, " weapon fired") #Print which weapon is firing
prints(bullet.shot_data.shot_name, "weapon fired") #Print which weapon is firing
#weapon_cooldown = $WeaponCooldown
#weapon_cooldown.wait_time = bullet.shot_data.cooldown
#weapon_cooldown.start()
#can_shoot = not can_shoot
#I track the vertical distance the last bullet traveled relative to the ship:
#
#travel += bulletSpeed*dt + (Ship.y - prevShipY)
#set prevShipY to Ship.y
#
#when travel > spacing -> fire bullet and
#
#set travel -= spacing
#
#(where spacing is the distance you want bullets to be apart, in pixels)

View file

@ -6,4 +6,6 @@ extends Area2D
func _process(delta):
position.y += shot_data.speed * delta
#position.y += shot_data.speed * delta #This works normally
var player_position = get_node("../Player").position
position.y += player_position.y * shot_data.speed * delta