add boss enemy and refactor
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed = 60
|
||||
@export var hp = 1
|
||||
|
||||
var direction = 1
|
||||
|
||||
@onready var ray_cast_right: RayCast2D = $RayCastRight
|
||||
@onready var ray_cast_left: RayCast2D = $RayCastLeft
|
||||
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -25,3 +27,10 @@ func _physics_process(delta: float) -> void:
|
||||
position.x += direction * speed * delta
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _on_hit_box_hit() -> void:
|
||||
hp -= 1
|
||||
|
||||
if hp <= 0:
|
||||
animated_sprite.play("die")
|
||||
animation_player.play("die")
|
||||
|
||||
Reference in New Issue
Block a user