Health and killing zones
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 400.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
|
||||
var jumped = false
|
||||
@onready var animation = get_node("AnimatedSprite2D")
|
||||
@onready var healthBar: ProgressBar = $ProgressBar
|
||||
|
||||
|
||||
var health = 100
|
||||
|
||||
func _ready() -> void:
|
||||
animation.play("idle")
|
||||
|
||||
@ -47,3 +49,13 @@ func _physics_process(delta: float) -> void:
|
||||
#print("DEAD")
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_enemy_hurt() -> void:
|
||||
if health - 50 == 0:
|
||||
get_tree().reload_current_scene()
|
||||
else:
|
||||
health -= 50
|
||||
healthBar.value -= 50
|
||||
|
Reference in New Issue
Block a user