From f3fbf802508a635f10c469ad2220f584b5526981 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 4 Apr 2026 15:11:40 +0100 Subject: [PATCH 1/3] Tweaked the sprite a bit more for added banking clarity. --- graphics/ship.png | Bin 760 -> 766 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/graphics/ship.png b/graphics/ship.png index a260f6c3433ad399116828f327fa5cd974bd6621..c1e9c86cff8ded92a0c6ed8f046a2f382c629cd2 100644 GIT binary patch delta 532 zcmV+v0_*+w1^xw)^?&q9L_t(IjeV8DuB$K%M1vWWg}XzH*dSfW-jM(Qz$XXVl0aWn zQFUw|j}xFNeU{YEZONnhztG@5JY~E80=Yke=+4LNU!)%q^PJu8**Uu}Pn^XgcK2g> zU9;Uhh3b4DE%b;z@Yhn-Tkl-9HM?`{^GCYpbt^q-WGg- z%eIxA(Sf!T)RD#$v~{4FRbAK2xe0_8;@pGgTC#3iE5E8*YhF#sTYUAP*Sn-0top1q z&Stn=H7C2{BzB3vJgoswFN1aq_hu- z8%HI@Oh_GR7k?5NASJy8c@@R4BfAkhqCvFAjtj{_sw!fVW(JZ_RT6&XIQ1aKmw!oK zv(?yDZrDY5Yr{WT}gFETGRv@X2Usxdy)>H^L%o`0e@ol_rqXIN)k1pN=nQ3tptRp za5F|lZSBDy>u%TZckA|)B)U#hbdf52NHnqNkh&FpO{}|p1#r`p)Etl|JwS@__BJ0z zXa!wc7$DOS|02UAz<078fb7xy_Li5hxySY5KW3X`NNJF%olHa|Xu};e1S8_d?|({u WIziWpMhyu70000MBPIBKc1m9)fVF!+o=Qo6 z>xn6By*sOcwR?`T?*-$EwAYdVo5%UH0jbn|lx9nH-)kCI?0Z0l)CRjE-BSo zYf3Ue^@Ij#KA}25*;-mkvfLGz5z4uf=A0W;YVG|OA&z9PZp9J8UL*86pi=sS*$1-j zaH%;QJ=CIB93doL%!C07rKAYh9Wo%Mp&>*y_XtFH(|EnfB7kV7sy(EtX03R2+-An^ zTr!(qBr&sS+<&LLhrt~!TGv0^WD~VER5rOtAfzhROLR=wlnJg5Ob>}4_(%}p0=Hf| z9CL0UZz<=)*?v?+f3`!)`Rs?;D198RdH2MIOjp|Od|%bhmXJXRVyATQIiHRR2q8B~ zCAzLb05wxU!m1ucSz_Z2Iwd(EIh_My^*pk#Aw*>+s(&$r^?WL2Cj8pejE(RBli6NmQJW zUP2d%%fx??X^A3!aaa+RCrDH{`zrBlOPoTO;_^8e3xqauPmt(F=$QTsSkyfG6PPsS Q00000Ne4wvM6N<$f;Hsy;{X5v From 172830729fdbbbb94e0650d46b83163eba240a06 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 4 Apr 2026 15:14:13 +0100 Subject: [PATCH 2/3] Modified the resource and defaults for the projectile property ;made a backup of the original stock weapon scene just in case things went bad. --- resources/shot_stock.tres | 2 ++ scenes/stock_weapon.tscn | 5 ++++- scenes/stock_weapon_single_old.tscn | 22 ++++++++++++++++++++++ scripts/player_shot.gd | 1 + scripts/stock_weapon.gd | 1 - 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 scenes/stock_weapon_single_old.tscn diff --git a/resources/shot_stock.tres b/resources/shot_stock.tres index a485b71..6134269 100644 --- a/resources/shot_stock.tres +++ b/resources/shot_stock.tres @@ -6,6 +6,8 @@ [resource] script = ExtResource("1_dpne1") shot_name = "Stock" +damage = 3 speed = -350 +projectiles = 1 cooldown = 0.0 metadata/_custom_type_script = "uid://ccdohs4gduee5" diff --git a/scenes/stock_weapon.tscn b/scenes/stock_weapon.tscn index 3f1ed64..077183a 100644 --- a/scenes/stock_weapon.tscn +++ b/scenes/stock_weapon.tscn @@ -5,7 +5,7 @@ [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) +size = Vector2(6, 14) [node name="StockWeapon" type="Area2D" unique_id=1832200900] script = ExtResource("1_hsma2") @@ -13,10 +13,13 @@ shot_data = ExtResource("2_ckjv1") [node name="Sprite2D" type="Sprite2D" parent="." unique_id=2134507225] texture = ExtResource("3_mvdrj") +region_enabled = true +region_rect = Rect2(7, 6, 4, 12) [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059] shape = SubResource("RectangleShape2D_mvdrj") [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"] diff --git a/scenes/stock_weapon_single_old.tscn b/scenes/stock_weapon_single_old.tscn new file mode 100644 index 0000000..a1dcfbc --- /dev/null +++ b/scenes/stock_weapon_single_old.tscn @@ -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"] diff --git a/scripts/player_shot.gd b/scripts/player_shot.gd index 54418e6..9455240 100644 --- a/scripts/player_shot.gd +++ b/scripts/player_shot.gd @@ -4,6 +4,7 @@ extends Resource @export var shot_name: String @export var damage: int = 1 @export var speed: int = 135 +@export var projectiles: int = 2 @export var rate: float = 0.1 @export var cooldown: float = 0.25 @export var sprite: Texture2D = preload("res://graphics/shot.png") diff --git a/scripts/stock_weapon.gd b/scripts/stock_weapon.gd index b3e7f8c..f8d815c 100644 --- a/scripts/stock_weapon.gd +++ b/scripts/stock_weapon.gd @@ -3,7 +3,6 @@ extends Area2D @onready var bullet = load("res://scenes/stock_weapon.tscn") @export var shot_data: PlayerShot -@onready var player = get_node("../Player") func _process(delta): From 1794abe50a01760fc71843c8304d2f81d7834013 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 4 Apr 2026 15:17:13 +0100 Subject: [PATCH 3/3] 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. --- scenes/player.tscn | 2 +- scenes/world.tscn | 1 + scripts/player.gd | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scenes/player.tscn b/scenes/player.tscn index 7233823..d3bdfa5 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -87,7 +87,7 @@ size = Vector2(6, 5.75) [node name="Player" type="Area2D" unique_id=652131079] script = ExtResource("1_g2els") -speed = 165 +speed = 275 weapon_current = ExtResource("2_dqkch") [node name="Ship" type="Sprite2D" parent="." unique_id=1155866924] diff --git a/scenes/world.tscn b/scenes/world.tscn index b0110e3..859bfd0 100644 --- a/scenes/world.tscn +++ b/scenes/world.tscn @@ -13,6 +13,7 @@ [node name="Player" parent="Level" unique_id=652131079 instance=ExtResource("2_rwgxs")] z_index = 1 position = Vector2(97, 173) +speed = 200 [node name="Background" type="Node2D" parent="Level" unique_id=485120278] z_index = -1 diff --git a/scripts/player.gd b/scripts/player.gd index 9d12920..c3a4b34 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -87,17 +87,20 @@ func _on_weapon_cooldown_timeout() -> void: func shoot(): - # Instantiate the bullet - var bullet = weapon_current.instantiate() - get_tree().root.add_child(bullet) - bullet.position = position + Vector2(0,-23) + var projectiles: int = 2 + for b in projectiles: - # Get weapon speed and spacing for equidistant calculations - 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") + # Instantiate the bullets + var bullet = weapon_current.instantiate() + get_tree().root.add_child(bullet) + bullet.position = position + Vector2((b * 10) - (projectiles * projectiles),-23) + + # Get weapon speed and spacing for equidistant calculations + 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")