Added blinks
This commit is contained in:
@@ -6,6 +6,8 @@ signal accelerate(direction: Vector2, delta: float)
|
||||
|
||||
signal shoot(weapon_index: int)
|
||||
|
||||
signal blink(direction: Vector2)
|
||||
|
||||
|
||||
const WEAPON_ACTIONS := {
|
||||
0: "shoot_weapon_1",
|
||||
@@ -14,9 +16,18 @@ const WEAPON_ACTIONS := {
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
var input_direction := _get_input_direction()
|
||||
accelerate.emit(input_direction, delta)
|
||||
|
||||
for index : int in WEAPON_ACTIONS:
|
||||
if Input.is_action_pressed(WEAPON_ACTIONS[index]):
|
||||
shoot.emit(index)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("blink"):
|
||||
var input_direction := _get_input_direction()
|
||||
blink.emit(input_direction)
|
||||
|
||||
func _get_input_direction() -> Vector2:
|
||||
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
|
||||
Reference in New Issue
Block a user