Set up a revised player scene with a component based apparoach; shooting
functionality incomplete.
This commit is contained in:
parent
8d89271074
commit
9b3841775c
13 changed files with 331 additions and 0 deletions
34
scripts/shoot_component.gd
Normal file
34
scripts/shoot_component.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class_name ShootComponent extends Node
|
||||
|
||||
@onready var weapon_component: Node = %WeaponComponent
|
||||
@onready var player: Player = $".."
|
||||
|
||||
var travel: float = 0
|
||||
var weapon_spacing: float = 0.1
|
||||
|
||||
|
||||
func shoot():
|
||||
|
||||
# Continuous fire
|
||||
if player.is_shooting == true:
|
||||
|
||||
# Adjust bullet spacing before firing
|
||||
|
||||
|
||||
for b in range(weapon_component.bullet_data.projectiles):
|
||||
|
||||
# Instantiate the bullets
|
||||
var bullet = weapon_component.weapon_current.instantiate()
|
||||
get_tree().root.add_child(bullet)
|
||||
bullet.position = player.position + Vector2((b - (weapon_component.bullet_data.projectiles - 1) / 2.0) * weapon_component.bullet_data.projectile_spacing, weapon_component.bullet_data.projectile_origin)
|
||||
|
||||
## Get weapon speed and spacing for equidistant calculations
|
||||
#weapon_rate = bullet.weapon_component.bullet_data.rate
|
||||
#weapon_spacing = bullet.weapon_component.bullet_data.projectile_spacing
|
||||
#bullet.weapon_component.bullet_data.speed = bullet.weapon_component.bullet_data.speed
|
||||
|
||||
# Print which weapon is firing
|
||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue