Attempt to refactor components.
This commit is contained in:
parent
e3fb082139
commit
79122a074e
15 changed files with 241 additions and 112 deletions
34
scenes/player_component.gd
Normal file
34
scenes/player_component.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class_name Player extends Node
|
||||
|
||||
# Components managed by Player
|
||||
@onready var input_component: InputComponent = %InputComponent
|
||||
@onready var movement_component: MovementComponent = %MovementComponent
|
||||
@onready var shoot_component: ShootComponent = %ShootComponent
|
||||
@onready var weapon_component: WeaponComponent = %WeaponComponent
|
||||
|
||||
# Variables for Player shooting status
|
||||
@export var can_shoot: bool = true
|
||||
@export var is_shooting: bool = false
|
||||
|
||||
# Variables for Player position calculations for equidistant bullets
|
||||
var previous_position: Vector2
|
||||
var ship_displacement: float
|
||||
var travel: float = 0
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
|
||||
# Read Controls
|
||||
input_component.update()
|
||||
|
||||
# Read Shooting
|
||||
if input_component.shooting:
|
||||
is_shooting = true
|
||||
else: is_shooting = false
|
||||
|
||||
if is_shooting == true:
|
||||
shoot_component.shoot()
|
||||
|
||||
# Read Movement Component
|
||||
movement_component.input = input_component.move_dir
|
||||
movement_component.tick(delta)
|
||||
Loading…
Add table
Add a link
Reference in a new issue