Beginning to update weapon components
This commit is contained in:
parent
db57a0234e
commit
e3fb082139
11 changed files with 66 additions and 37 deletions
|
|
@ -11,6 +11,7 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Facsimile Wing"
|
config/name="Facsimile Wing"
|
||||||
|
run/main_scene="uid://coix5dqblmu7r"
|
||||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_t07sl")
|
script = ExtResource("1_t07sl")
|
||||||
shot_name = "Stock"
|
shot_name = "Stock"
|
||||||
speed = 375
|
speed = 500
|
||||||
projectiles = 4
|
|
||||||
spacing = 28.0
|
spacing = 28.0
|
||||||
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,5 @@
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_reevt")
|
script = ExtResource("1_reevt")
|
||||||
shot_name = "Stock"
|
shot_name = "Stock"
|
||||||
speed = -350
|
speed = 500
|
||||||
cooldown = 0.0
|
|
||||||
projectile_spacing = 10.0
|
|
||||||
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
metadata/_custom_type_script = "uid://ccdohs4gduee5"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ extends Area2D
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
position.y -= shot_data.speed * delta # This works normally
|
|
||||||
|
#Calculation position along Y axis
|
||||||
|
position.y -= shot_data.speed * delta
|
||||||
|
|
||||||
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ func tick(delta: float):
|
||||||
# Check to see if there's a player to move
|
# Check to see if there's a player to move
|
||||||
if player == null: return
|
if player == null: return
|
||||||
|
|
||||||
|
# Shorten variable for accessing weapon_component for clarity
|
||||||
var weapon_system = weapon_component.data
|
var weapon_system = weapon_component.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
|
||||||
player.travel += abs(weapon_system.speed) * delta + (player.ship_displacement)
|
player.travel += abs(weapon_system.speed) * delta + (player.ship_displacement)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
class_name PlayerShot
|
class_name PlayerShotResource
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
@export_category("Info")
|
@export_category("Info")
|
||||||
|
|
@ -11,5 +11,3 @@ extends Resource
|
||||||
@export var projectiles: int = 2
|
@export var projectiles: int = 2
|
||||||
@export var spacing: float = 35
|
@export var spacing: float = 35
|
||||||
@export var origin: int = -23
|
@export var origin: int = -23
|
||||||
#@export var rate: float = 0.1
|
|
||||||
#@export var cooldown: float = 0.25
|
|
||||||
|
|
|
||||||
|
|
@ -3,36 +3,29 @@ class_name ShootComponent extends Node
|
||||||
@onready var weapon_component: Node = %WeaponComponent
|
@onready var weapon_component: Node = %WeaponComponent
|
||||||
@onready var player: Player = $".."
|
@onready var player: Player = $".."
|
||||||
|
|
||||||
#var travel: float = 0
|
|
||||||
#var weapon_spacing: float = 0.1
|
|
||||||
|
|
||||||
|
|
||||||
func shoot():
|
func shoot():
|
||||||
|
|
||||||
var weapon_system = weapon_component.data
|
# Shorten variable for accessing weapon_component for clarity
|
||||||
|
var weapon_system = weapon_component.data
|
||||||
|
|
||||||
if player.travel > weapon_system.spacing:
|
if player.travel > weapon_system.spacing:
|
||||||
print("Travel is greater!")
|
|
||||||
for b in range(weapon_system.projectiles):
|
|
||||||
|
|
||||||
# Instantiate the bullets
|
for b in range(weapon_system.projectiles):
|
||||||
var bullet = weapon_component.weapon_current.instantiate()
|
|
||||||
get_tree().root.add_child(bullet)
|
|
||||||
# Adjust bullet spacing before firing
|
|
||||||
|
|
||||||
bullet.position = player.position + Vector2((b - (weapon_system.projectiles - 1) / 2.0) * round(round((weapon_system.projectiles + weapon_system.spacing / 2)) / 2), weapon_system.origin)
|
# Instantiate the bullets
|
||||||
print(b, bullet.position.x)
|
var bullet = weapon_component.weapon_current.instantiate()
|
||||||
## Get weapon speed and spacing for equidistant calculations - non comp
|
get_tree().root.add_child(bullet)
|
||||||
#weapon_rate = bullet.weapon_component.bullet_data.rate
|
# Adjust bullet spacing before firing
|
||||||
#weapon_component.bullet_data.projectile_spacing = bullet.weapon_component.bullet_data.projectile_spacing
|
|
||||||
#weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
|
|
||||||
|
|
||||||
# Print which weapon is firing
|
bullet.position = player.position + Vector2((b - (weapon_system.projectiles - 1) / 2.0) * round(round((weapon_system.projectiles + weapon_system.spacing / 2)) / 2), weapon_system.origin)
|
||||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
print(b, bullet.position.x)
|
||||||
|
|
||||||
# Subtract projectile spacing from current Player travel for next
|
# Print which weapon is firing
|
||||||
player.travel -= weapon_system.spacing
|
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||||
|
|
||||||
else: return
|
# Subtract projectile spacing from current Player travel for next
|
||||||
|
player.travel -= weapon_system.spacing
|
||||||
|
|
||||||
|
else: return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
21
scripts/weapon_component_original.gd
Normal file
21
scripts/weapon_component_original.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
class_name WeaponComponent extends Node
|
||||||
|
|
||||||
|
@export var weapon_current : PackedScene
|
||||||
|
var data: PlayerShot = load("res://resources/player_weapons/shot_stock.tres")
|
||||||
|
#@export var projectile_origin: int = -23
|
||||||
|
|
||||||
|
#@export_category("Temp Bullet Data")
|
||||||
|
#@export var projectiles: int = 3
|
||||||
|
#@export var projectile_spacing: float = 10
|
||||||
|
|
||||||
|
#var damage: int = 0
|
||||||
|
#var speed: int = 135
|
||||||
|
#var projectiles: int = 2
|
||||||
|
#var rate: float = 0.1
|
||||||
|
#var cooldown: float = 0.25
|
||||||
|
#var projectile_spacing: float = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1
scripts/weapon_component_original.gd.uid
Normal file
1
scripts/weapon_component_original.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cy50u6ksjqvjc
|
||||||
13
scripts/weapon_shot.gd
Normal file
13
scripts/weapon_shot.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class_name PlayerShot
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
@export_category("Info")
|
||||||
|
@export var shot_name: String
|
||||||
|
@export var sprite: Texture2D = preload("res://graphics/shot.png")
|
||||||
|
|
||||||
|
@export_category("Shot Data")
|
||||||
|
@export var damage: int = 1
|
||||||
|
@export var speed: int = 135
|
||||||
|
@export var projectiles: int = 2
|
||||||
|
@export var spacing: float = 35
|
||||||
|
@export var origin: int = -23
|
||||||
1
scripts/weapon_shot.gd.uid
Normal file
1
scripts/weapon_shot.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://7n1itonn35fm
|
||||||
Loading…
Add table
Add a link
Reference in a new issue