-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.gd
34 lines (27 loc) · 861 Bytes
/
player.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
extends Node2D
@onready var config: Resource = preload("res://resources/player.tres")
@export var Attack: PackedScene
@export var damage_intake: int
signal player_attacked
func _ready():
$Timer.start()
$".".get_parent().correct_input.connect(summon)
$".".get_parent().failed_input.connect(summon_fail)
func _process(_delta):
pass
func summon() -> void:
$playerAttack.play()
var attack = Attack.instantiate()
attack.set_sprite_texture(config.attack_texture)
$".".add_child(attack)
$AnimatedSprite2D.play("attack")
attack.add_to_group("attack")
attack.global_transform = $Marker2D.global_transform
func summon_fail() -> void:
$AnimatedSprite2D.play("fail")
$PlayerFail.play()
func _on_area_2d_area_entered(area):
if area.is_in_group("enemy_attack"):
area.queue_free()
config.take_damage(damage_intake)
emit_signal("player_attacked")