extends CharacterBody2D var SPEED = Vector2(150, 0) const JUMP_VELOCITY = -400.0 @onready var projectile: PackedScene = preload("res://scenes/core/projectile.tscn") var health_counter = 3 func _ready() -> void: $AnimatedSprite2D.play() $Timer.start() func _physics_process(delta: float) -> void: if abs(velocity.x) > 0.1: $AnimatedSprite2D.flip_h = velocity.x < 0 if health_counter == 2: $ColorRect4.hide() if health_counter == 1: $ColorRect3.hide() if health_counter == 0: queue_free() velocity += get_gravity() * delta patrol() move_and_slide() func patrol(): velocity.x = SPEED.x func _on_timer_timeout() -> void: SPEED = -SPEED $Timer.start() func _on_area_2d_area_entered(_area: Area2D) -> void: if GlobalData.hurtable: health_counter -= 1 elif GlobalData.weapon == 2: health_counter -= 1 func _on_area_2d_body_entered(_body: Node2D) -> void: GlobalData.death_counter -= 1