From 7c037ed22cc8f370f949f7b7610409d3950451f9 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 8 Jun 2026 13:35:06 +0100 Subject: [PATCH] Updated CRT enemy facing logic. --- scenes/enemy_crt.gd | 46 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/scenes/enemy_crt.gd b/scenes/enemy_crt.gd index a0aa936..14915da 100644 --- a/scenes/enemy_crt.gd +++ b/scenes/enemy_crt.gd @@ -47,29 +47,29 @@ func start(pos): func _on_timer_timeout(): speed = randf_range(75, 100) $DirectionTimer.start() - + $ShootTimer.stop() # Stop shooting when changing direction func _on_direction_timer_timeout(): var move_direction = randi_range(0,2) match move_direction: 0: - crt.frame = 0 + crt.frame = 0 # down - facing direction = Vector2(0,1) can_shoot = true - vulnerable = true - #$DirectionTimer.start() + $DirectionTimer.start() + $ShootTimer.start() 1: - crt.frame = 1 + crt.frame = 1 # right - facing right direction = Vector2(1,0) can_shoot = false vulnerable = false - #$DirectionTimer.start() + $DirectionTimer.start() 2: - crt.frame = 2 + crt.frame = 2 # left - facing left direction = Vector2(-1,0) can_shoot = false vulnerable = false - #$DirectionTimer.start() - + $DirectionTimer.start() + func _on_shoot_timer_timeout(): @@ -80,30 +80,30 @@ func _on_shoot_timer_timeout(): b.start(position) #$ShootTimer.wait_time = randf_range(4, 20) $ShootTimer.start() - - else: - $ShootTimer.start() + + else: + $ShootTimer.stop() # Don't shoot when can_shoot is false - prevents timer race condition func _process(delta): - + if stunned == true: return - - if stunned == false: + + if stunned == false: position += direction * speed * delta - + #if position.x > screensize.x + 32: #start(start_pos) - + if travel == true and position.y > screensize.y + 32 or position.x > screensize.x or position.x < -screensize.x: print("I'm off screen!") start(start_pos) - + func hit_detection(): if exploding: return - + if vulnerable == true: exploding = true EventBus.enemy_hit.emit(5) @@ -114,10 +114,10 @@ func hit_detection(): await $AnimationPlayer.animation_finished queue_free() EventBus.enemy_died.emit() - + if vulnerable == false: block() - + func block(): #if blocking: return #blocking = true @@ -132,7 +132,5 @@ func block(): shader_active = false stunned = false $DirectionTimer.start() + $ShootTimer.start() ## Restart shooting after stun period print("CRT Not Stunned!") - - -