Attempting to refactor the previously working self contained equidistent
code in the player.gd.
This commit is contained in:
parent
5d2efe9983
commit
d419635d7f
15 changed files with 153 additions and 46 deletions
31
scripts/player_component.gd
Normal file
31
scripts/player_component.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
class_name Player extends Area2D
|
||||
|
||||
@onready var input_component: InputComponent = %InputComponent
|
||||
@onready var movement_component: MovementComponent = %MovementComponent
|
||||
@onready var shoot_component: ShootComponent = %ShootComponent
|
||||
@onready var weapon_component: WeaponComponent = %WeaponComponent
|
||||
|
||||
@export var can_shoot: bool = true
|
||||
@export var is_shooting: bool = false
|
||||
|
||||
var previous_position: Vector2
|
||||
var ship_displacement: float
|
||||
var travel: float = 0
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
|
||||
# Read Controls
|
||||
input_component.update()
|
||||
|
||||
# Read Movement Component
|
||||
movement_component.input = input_component.move_dir
|
||||
movement_component.tick(delta)
|
||||
|
||||
# Read shooting
|
||||
if input_component.shooting:
|
||||
is_shooting = true
|
||||
else: is_shooting = false
|
||||
|
||||
if is_shooting == true:
|
||||
shoot_component.shoot()
|
||||
Loading…
Add table
Add a link
Reference in a new issue