Compare commits

...

3 commits

Author SHA1 Message Date
Henry
1794abe50a 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.
2026-04-04 15:17:13 +01:00
Henry
172830729f Modified the resource and defaults for the projectile property ;made a
backup of the original stock weapon scene just in case things went bad.
2026-04-04 15:14:13 +01:00
Henry
f3fbf80250 Tweaked the sprite a bit more for added banking clarity. 2026-04-04 15:11:40 +01:00
9 changed files with 45 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 766 B

Before After
Before After

View file

@ -6,6 +6,8 @@
[resource] [resource]
script = ExtResource("1_dpne1") script = ExtResource("1_dpne1")
shot_name = "Stock" shot_name = "Stock"
damage = 3
speed = -350 speed = -350
projectiles = 1
cooldown = 0.0 cooldown = 0.0
metadata/_custom_type_script = "uid://ccdohs4gduee5" metadata/_custom_type_script = "uid://ccdohs4gduee5"

View file

@ -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]

View file

@ -5,7 +5,7 @@
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_mvdrj"] [ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_mvdrj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
size = Vector2(12, 8) size = Vector2(6, 14)
[node name="StockWeapon" type="Area2D" unique_id=1832200900] [node name="StockWeapon" type="Area2D" unique_id=1832200900]
script = ExtResource("1_hsma2") script = ExtResource("1_hsma2")
@ -13,10 +13,13 @@ shot_data = ExtResource("2_ckjv1")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225] [node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225]
texture = ExtResource("3_mvdrj") texture = ExtResource("3_mvdrj")
region_enabled = true
region_rect = Rect2(7, 6, 4, 12)
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059] [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
shape = SubResource("RectangleShape2D_mvdrj") shape = SubResource("RectangleShape2D_mvdrj")
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=985862716] [node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=985862716]
rect = Rect2(-3, -7, 6, 14)
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] [connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -0,0 +1,22 @@
[gd_scene format=3 uid="uid://b2ltmeb14nc17"]
[ext_resource type="Script" uid="uid://d1rwqotmrag1r" path="res://scripts/stock_weapon.gd" id="1_kx6bj"]
[ext_resource type="Resource" uid="uid://cels8t3hqjtsu" path="res://resources/shot_stock.tres" id="2_hefae"]
[ext_resource type="Texture2D" uid="uid://ti1uy42vnnhw" path="res://graphics/shot.png" id="3_58qml"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
size = Vector2(12, 8)
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
script = ExtResource("1_kx6bj")
shot_data = ExtResource("2_hefae")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225]
texture = ExtResource("3_58qml")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
shape = SubResource("RectangleShape2D_mvdrj")
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=985862716]
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -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

View file

@ -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")

View file

@ -4,6 +4,7 @@ extends Resource
@export var shot_name: String @export var shot_name: String
@export var damage: int = 1 @export var damage: int = 1
@export var speed: int = 135 @export var speed: int = 135
@export var projectiles: int = 2
@export var rate: float = 0.1 @export var rate: float = 0.1
@export var cooldown: float = 0.25 @export var cooldown: float = 0.25
@export var sprite: Texture2D = preload("res://graphics/shot.png") @export var sprite: Texture2D = preload("res://graphics/shot.png")

View file

@ -3,7 +3,6 @@ extends Area2D
@onready var bullet = load("res://scenes/stock_weapon.tscn") @onready var bullet = load("res://scenes/stock_weapon.tscn")
@export var shot_data: PlayerShot @export var shot_data: PlayerShot
@onready var player = get_node("../Player")
func _process(delta): func _process(delta):