Health and killing zones

This commit is contained in:
2024-10-28 10:25:07 +01:00
parent e242f59c0b
commit a15966a361
9 changed files with 42 additions and 47 deletions

View File

@ -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