Compare commits
2 commits
e2cf516c90
...
cf172bc546
| Author | SHA1 | Date | |
|---|---|---|---|
| cf172bc546 | |||
| 63ed0aae3a |
11 changed files with 112 additions and 51 deletions
|
|
@ -12,7 +12,7 @@ config_version=5
|
||||||
|
|
||||||
config/name="Facsimile Wing"
|
config/name="Facsimile Wing"
|
||||||
run/main_scene="uid://bj4fytc3sy482"
|
run/main_scene="uid://bj4fytc3sy482"
|
||||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
@ -52,6 +52,11 @@ shoot={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
cycle={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,4 @@ extends Resource
|
||||||
|
|
||||||
@export_category("Spread")
|
@export_category("Spread")
|
||||||
@export var horizontal_offset: float = 6.5 # Horizontal distance between projectiles
|
@export var horizontal_offset: float = 6.5 # Horizontal distance between projectiles
|
||||||
@export var stagger_offset: float = 5 # Time delay per projectile index
|
@export var stagger_offset: float = 0.1 # Time delay per projectile index
|
||||||
|
|
|
||||||
17
resources/player_weapon_resources/weapon_shot_spread.tres
Normal file
17
resources/player_weapon_resources/weapon_shot_spread.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" script_class="WeaponShot" format=3 uid="uid://bhc6aja38vyr"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/player_weapons/weapon_stock.tscn" id="1_bullet"]
|
||||||
|
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://resources/player_weapon_resources/weapon_shot.gd" id="2_script"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_script")
|
||||||
|
shot_name = "Spread Shot"
|
||||||
|
bullet_scene = ExtResource("1_bullet")
|
||||||
|
damage = 1
|
||||||
|
speed = 450
|
||||||
|
projectiles = 5
|
||||||
|
spacing = 30.0
|
||||||
|
origin = -15
|
||||||
|
horizontal_offset = 10.0
|
||||||
|
stagger_offset = 0.2
|
||||||
|
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||||
|
|
@ -20,7 +20,7 @@ var ship_displacement: float
|
||||||
var travel: float = 0
|
var travel: float = 0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
||||||
## Set initial start position
|
## Set initial start position
|
||||||
position = Vector2(screensize.x / 2, screensize.y - 45)
|
position = Vector2(screensize.x / 2, screensize.y - 45)
|
||||||
|
|
||||||
|
|
@ -37,12 +37,16 @@ func _process(delta) -> void:
|
||||||
if is_shooting == true:
|
if is_shooting == true:
|
||||||
shoot_component.shoot()
|
shoot_component.shoot()
|
||||||
$%MuzzleFlash.show()
|
$%MuzzleFlash.show()
|
||||||
|
|
||||||
if is_shooting == false:
|
if is_shooting == false:
|
||||||
$%MuzzleFlash.hide()
|
$%MuzzleFlash.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Read Movement Component
|
# Read Movement Component
|
||||||
movement_component.input = input_component.move_dir
|
movement_component.input = input_component.move_dir
|
||||||
movement_component.tick(delta)
|
movement_component.tick(delta)
|
||||||
|
|
||||||
|
# Cycle weapon (testing key)
|
||||||
|
if input_component.cycle_weapon:
|
||||||
|
weapon_component.cycle_weapon()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
[ext_resource type="Script" uid="uid://c0rikbakpcags" path="res://scripts/movement_component.gd" id="5_ur7pv"]
|
[ext_resource type="Script" uid="uid://c0rikbakpcags" path="res://scripts/movement_component.gd" id="5_ur7pv"]
|
||||||
[ext_resource type="Script" uid="uid://suynuijl68qp" path="res://scripts/shoot_component.gd" id="6_y4r1p"]
|
[ext_resource type="Script" uid="uid://suynuijl68qp" path="res://scripts/shoot_component.gd" id="6_y4r1p"]
|
||||||
[ext_resource type="Script" uid="uid://ylmao2ndp22y" path="res://scripts/weapon_component.gd" id="7_d2wvv"]
|
[ext_resource type="Script" uid="uid://ylmao2ndp22y" path="res://scripts/weapon_component.gd" id="7_d2wvv"]
|
||||||
|
[ext_resource type="Resource" uid="uid://b75ae840k03dy" path="res://resources/player_weapon_resources/weapon_shot_stock.tres" id="8_stock"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bhc6aja38vyr" path="res://resources/player_weapon_resources/weapon_shot_spread.tres" id="9_ur7pv"]
|
||||||
|
[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://resources/player_weapon_resources/weapon_shot.gd" id="10_d2wvv"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||||
atlas = ExtResource("5_qlg0r")
|
atlas = ExtResource("5_qlg0r")
|
||||||
|
|
@ -34,7 +37,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_fjrip")
|
"texture": SubResource("AtlasTexture_fjrip")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": 1,
|
||||||
"name": &"banked",
|
"name": &"banked",
|
||||||
"speed": 15.0
|
"speed": 15.0
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -45,7 +48,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_ur7pv")
|
"texture": SubResource("AtlasTexture_ur7pv")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": 1,
|
||||||
"name": &"fwd",
|
"name": &"fwd",
|
||||||
"speed": 15.0
|
"speed": 15.0
|
||||||
}]
|
}]
|
||||||
|
|
@ -74,7 +77,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_d2wvv")
|
"texture": SubResource("AtlasTexture_d2wvv")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": 1,
|
||||||
"name": &"stock",
|
"name": &"stock",
|
||||||
"speed": 15.0
|
"speed": 15.0
|
||||||
}]
|
}]
|
||||||
|
|
@ -90,9 +93,6 @@ size = Vector2(6, 5.75)
|
||||||
|
|
||||||
[node name="Player" type="Area2D" unique_id=652131079]
|
[node name="Player" type="Area2D" unique_id=652131079]
|
||||||
script = ExtResource("1_ur7pv")
|
script = ExtResource("1_ur7pv")
|
||||||
can_shoot = null
|
|
||||||
is_shooting = null
|
|
||||||
muzzle_flash = null
|
|
||||||
|
|
||||||
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
@ -148,11 +148,12 @@ metadata/_custom_type_script = "uid://c0rikbakpcags"
|
||||||
[node name="ShootComponent" type="Node" parent="." unique_id=623642425]
|
[node name="ShootComponent" type="Node" parent="." unique_id=623642425]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("6_y4r1p")
|
script = ExtResource("6_y4r1p")
|
||||||
metadata/_custom_type_script = "uid://bgd1hwindc2ui"
|
|
||||||
|
|
||||||
[node name="WeaponComponent" type="Node" parent="." unique_id=1648685183]
|
[node name="WeaponComponent" type="Node" parent="." unique_id=1648685183]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("7_d2wvv")
|
script = ExtResource("7_d2wvv")
|
||||||
|
weapon_data = ExtResource("9_ur7pv")
|
||||||
|
available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("9_ur7pv")])
|
||||||
metadata/_custom_type_script = "uid://ylmao2ndp22y"
|
metadata/_custom_type_script = "uid://ylmao2ndp22y"
|
||||||
|
|
||||||
[connection signal="timeout" from="WeaponCooldown" to="." method="_on_weapon_cooldown_timeout"]
|
[connection signal="timeout" from="WeaponCooldown" to="." method="_on_weapon_cooldown_timeout"]
|
||||||
|
|
|
||||||
53
scenes/player_weapons/weapon_spreadshot.tscn
Normal file
53
scenes/player_weapons/weapon_spreadshot.tscn
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
[gd_scene format=3 uid="uid://clpyd8qfwthk2"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c5blhfopjpfny" path="res://scenes/player_weapons/weapon_stock.gd" id="1_nx6aw"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bnpm8b62n1pr5" path="res://graphics/shot_stock_og.png" id="2_s6ult"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_5bykt"]
|
||||||
|
atlas = ExtResource("2_s6ult")
|
||||||
|
region = Rect2(0, 0, 7, 11)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_vsqoq"]
|
||||||
|
atlas = ExtResource("2_s6ult")
|
||||||
|
region = Rect2(7, 0, 7, 11)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_yqx5m"]
|
||||||
|
atlas = ExtResource("2_s6ult")
|
||||||
|
region = Rect2(14, 0, 7, 11)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_fdubj"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_5bykt")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_vsqoq")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_yqx5m")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 24.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mvdrj"]
|
||||||
|
size = Vector2(6.666667, 14)
|
||||||
|
|
||||||
|
[node name="StockWeapon" type="Area2D" unique_id=1832200900]
|
||||||
|
script = ExtResource("1_nx6aw")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1831184252]
|
||||||
|
scale = Vector2(1.5, 1.5)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_fdubj")
|
||||||
|
autoplay = "default"
|
||||||
|
frame_progress = 0.35886022
|
||||||
|
|
||||||
|
[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"]
|
||||||
|
|
@ -27,7 +27,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_yqx5m")
|
"texture": SubResource("AtlasTexture_yqx5m")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": 1,
|
||||||
"name": &"default",
|
"name": &"default",
|
||||||
"speed": 24.0
|
"speed": 24.0
|
||||||
}]
|
}]
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@ class_name InputComponent extends Node
|
||||||
var move_dir: Vector2 = Vector2.ZERO
|
var move_dir: Vector2 = Vector2.ZERO
|
||||||
var shoot_pressed: bool = false
|
var shoot_pressed: bool = false
|
||||||
var shooting: bool = false
|
var shooting: bool = false
|
||||||
|
var cycle_weapon: bool = false
|
||||||
|
|
||||||
func update() -> void:
|
func update() -> void:
|
||||||
move_dir = Input.get_vector("left", "right", "up", "down")
|
move_dir = Input.get_vector("left", "right", "up", "down")
|
||||||
shoot_pressed = Input.is_action_just_pressed("shoot")
|
shoot_pressed = Input.is_action_just_pressed("shoot")
|
||||||
shooting = Input.is_action_pressed("shoot")
|
shooting = Input.is_action_pressed("shoot")
|
||||||
|
|
||||||
|
|
||||||
# Development Keys
|
# Development Keys
|
||||||
# Cycle Available Weapons
|
cycle_weapon = Input.is_action_just_pressed("cycle")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func tick(delta: float):
|
||||||
if player == null: return
|
if player == null: return
|
||||||
|
|
||||||
# Shorten variable for accessing weapon_component for clarity
|
# Shorten variable for accessing weapon_component for clarity
|
||||||
var weapon_system = weapon_component.data
|
var weapon_system = weapon_component.weapon_data
|
||||||
|
|
||||||
# Calculate ship to bullet displacement
|
# Calculate ship to bullet displacement
|
||||||
player.ship_displacement = player.position.y - player.previous_position.y
|
player.ship_displacement = player.position.y - player.previous_position.y
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
class_name ShootComponent extends Node
|
class_name ShootComponent extends Node
|
||||||
|
|
||||||
@export var stagger_offset: float = 0.5 # Time delay per projectile index (seconds)
|
|
||||||
@export var horizontal_offset: float = 1.0 # Horizontal distance per projectile index
|
|
||||||
|
|
||||||
@onready var weapon_component: Node = %WeaponComponent
|
@onready var weapon_component: Node = %WeaponComponent
|
||||||
@onready var player = $".."
|
@onready var player = $".."
|
||||||
|
|
||||||
func shoot():
|
func shoot():
|
||||||
var weapon_data = weapon_component.data # WeaponShot resource configuration
|
var weapon_data = weapon_component.weapon_data
|
||||||
var current_time = Time.get_ticks_msec() / 1000.0
|
var current_time = Time.get_ticks_msec() / 1000.0
|
||||||
var total_projectiles = weapon_data.projectiles
|
var total_projectiles = weapon_data.projectiles
|
||||||
|
|
||||||
|
|
@ -18,15 +15,14 @@ func shoot():
|
||||||
|
|
||||||
if total_projectiles > 0:
|
if total_projectiles > 0:
|
||||||
for b in range(total_projectiles):
|
for b in range(total_projectiles):
|
||||||
var bullet_scene = weapon_data.bullet_scene
|
var bullet := weapon_data.bullet_scene.instantiate() as Area2D
|
||||||
var bullet := bullet_scene.instantiate() as Area2D
|
|
||||||
get_tree().root.add_child(bullet)
|
get_tree().root.add_child(bullet)
|
||||||
|
|
||||||
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
# Calculate index relative to center (0 = center, -1/+1 = first from center)
|
||||||
var index_from_center: float = b - center_index
|
var index_from_center: float = b - center_index
|
||||||
|
|
||||||
# Calculate timing offset for staggered firing
|
# Calculate timing offset for staggered firing
|
||||||
var time_offset: float = index_from_center * stagger_offset
|
var time_offset: float = index_from_center * weapon_data.stagger_offset
|
||||||
|
|
||||||
# Calculate horizontal offset for this bullet (symmetrical: left=-ve, right=+ve)
|
# Calculate horizontal offset for this bullet (symmetrical: left=-ve, right=+ve)
|
||||||
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
var bullet_horizontal_offset: float = index_from_center * weapon_data.horizontal_offset
|
||||||
|
|
@ -42,7 +38,7 @@ func shoot():
|
||||||
bullet.time_offset = time_offset
|
bullet.time_offset = time_offset
|
||||||
bullet.fire_time = current_time + time_offset
|
bullet.fire_time = current_time + time_offset
|
||||||
|
|
||||||
# Set the bullet data (this is what was missing)
|
# Set the bullet data
|
||||||
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)
|
||||||
|
|
||||||
# Subtract projectile spacing from current Player travel for next shot
|
# Subtract projectile spacing from current Player travel for next shot
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,20 @@
|
||||||
class_name WeaponComponent extends Node
|
class_name WeaponComponent extends Node
|
||||||
|
|
||||||
enum WeaponType {
|
@export var weapon_data: WeaponShot = null
|
||||||
STOCK,
|
@export var available_weapons: Array[WeaponShot] = []
|
||||||
NONE,
|
|
||||||
}
|
|
||||||
|
|
||||||
@export_enum("STOCK", "NONE") var loaded_weapon: int = WeaponType.STOCK
|
var _current_weapon_index: int = 0
|
||||||
|
|
||||||
var data: WeaponShot = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
|
||||||
|
|
||||||
func get_bullet_scene() -> PackedScene:
|
func get_bullet_scene() -> PackedScene:
|
||||||
if loaded_weapon == WeaponType.STOCK:
|
return weapon_data.bullet_scene if weapon_data else null
|
||||||
return preload("res://scenes/player_weapons/weapon_stock.tscn")
|
|
||||||
else:
|
|
||||||
return null
|
|
||||||
|
|
||||||
func get_weapon_resource() -> Resource:
|
func get_weapon_resource() -> Resource:
|
||||||
var weapon_resource_path: String
|
return weapon_data
|
||||||
|
|
||||||
if loaded_weapon == WeaponType.STOCK:
|
func cycle_weapon() -> void:
|
||||||
weapon_resource_path = "res://resources/player_weapon_resources/weapon_shot_stock.tres"
|
if available_weapons.is_empty():
|
||||||
data = load(weapon_resource_path)
|
return
|
||||||
return data
|
|
||||||
else:
|
|
||||||
return null
|
|
||||||
|
|
||||||
|
_current_weapon_index = (_current_weapon_index + 1) % available_weapons.size()
|
||||||
#var data : WeaponShot = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
weapon_data = available_weapons[_current_weapon_index]
|
||||||
|
print("Switched to: ", weapon_data.shot_name)
|
||||||
|
|
||||||
|
|
||||||
#func get_bullet_scene() -> PackedScene:
|
|
||||||
#return data.weapon_shot # Reference to the Shot scene from the resource
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue