fix: player attack logic; add sfx to the player attack;
This commit is contained in:
@@ -6,6 +6,7 @@ class_name Player
|
||||
@export var push_strength: int = 50
|
||||
@export var move_acceleration: float = 50
|
||||
var is_attacking: bool = false
|
||||
var can_interact: bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -26,7 +27,7 @@ func _physics_process(delta: float) -> void:
|
||||
push_blocks()
|
||||
update_scrolls()
|
||||
move_and_slide()
|
||||
if Input.is_action_just_pressed("Interact"):
|
||||
if Input.is_action_just_pressed("Interact") and not can_interact:
|
||||
attack()
|
||||
|
||||
func move_player():
|
||||
@@ -62,11 +63,13 @@ func update_scrolls():
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("interactable"):
|
||||
can_interact = true
|
||||
body.can_interact = true
|
||||
|
||||
|
||||
func _on_area_2d_body_exited(body: Node2D) -> void:
|
||||
if body.is_in_group("interactable"):
|
||||
can_interact = false
|
||||
body.can_interact = false
|
||||
|
||||
|
||||
@@ -105,6 +108,7 @@ func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
||||
body.queue_free()
|
||||
|
||||
func attack():
|
||||
$Sword/SwordSFX.play()
|
||||
if not $Sword/SwordTimer.is_stopped():
|
||||
return
|
||||
var player_animation: String = $AnimatedSprite2D.animation
|
||||
|
||||
Reference in New Issue
Block a user