Tutorials completed.

This commit is contained in:
Alan Youngblood
2024-12-01 21:20:10 -05:00
parent d103dac31a
commit 98c8da0338
19 changed files with 494 additions and 27 deletions

View File

@@ -1,5 +1,7 @@
extends KinematicBody2D
const PlayerHurtSound = preload("res://Player/PlayerHurtSound.tscn")
var velocity = Vector2.ZERO
var input_vector = Vector2.ZERO
var roll_vector = Vector2.DOWN
@@ -19,6 +21,7 @@ enum {
var state = MOVE
onready var animationPlayer = $AnimationPlayer
onready var blinkAnimationPlayer = $BlinkAnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
onready var swordHitbox = $HitboxPivot/SwordHitbox
@@ -28,6 +31,7 @@ func _ready():
stats.connect("no_health", self, "queue_free")
animationTree.active = true
swordHitbox.knockback_vector = roll_vector
blinkAnimationPlayer.play("Stop")
func _process(delta):
match state:
@@ -35,10 +39,10 @@ func _process(delta):
move_state(delta)
ROLL:
roll_state(delta)
roll_state()
ATTACK:
attack_state(delta)
attack_state()
func move_state(delta):
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
@@ -71,12 +75,12 @@ func move_state(delta):
func roll_animation_finished():
state = MOVE
func roll_state(delta):
func roll_state():
velocity = roll_vector * ROLL_SPEED
animationState.travel("Roll")
move()
func attack_state(delta):
func attack_state():
#velocity = Vector2.ZERO
#animationTree.set("parameters/Attack/blend_position", input_vector)
velocity = Vector2.ZERO
@@ -95,7 +99,17 @@ func attack_aninimation_finished():
# pass
func _on_Hurtbox_area_entered(area):
func _on_Hurtbox_area_entered(_area):
stats.health -= 1
hurtBox.start_invincibility(0.5)
hurtBox.start_invincibility(0.6)
hurtBox.create_hit_effect()
var playerHurtSounds = PlayerHurtSound.instance()
get_tree().current_scene.add_child(playerHurtSounds)
func _on_Hurtbox_invincibility_started():
blinkAnimationPlayer.play("Start")
func _on_Hurtbox_invincibility_ended():
blinkAnimationPlayer.play("Stop")