Hook up robot + perfect-block stun + moving block zone!

This commit is contained in:
Jennie Robinson Faber 2026-05-10 20:07:49 +01:00
parent 1d6b5c35ca
commit 9dd2546613
6 changed files with 95 additions and 14 deletions

View file

@ -13,11 +13,21 @@ var pulse_gap_min := 0.3
var block_zone_shrink := 3.0
var block_zone_min := 12.0
# Block zone movement (enabled per-floor by elevator_panel)
var block_zone_moving := false
var block_zone_speed := 0.0
var block_zone_direction := -1
var block_zone_min_x := 0.0
var block_zone_max_x := 0.0
const BLOCK_ZONE_RANGE_LEFT_RATIO := 0.5
const TRAIL_GHOSTS := 8
const TRAIL_SPACING := 3.0
const TRAIL_ALPHAS := [0.5, 0.42, 0.34, 0.27, 0.2, 0.14, 0.09, 0.05]
const GLOW_PADDING := Vector2(6, 6)
const GLOW_COLOR := Color(1, 0.3, 0.3, 0.35)
const PERFECT_ZONE_RATIO := 0.3
const PERFECT_ZONE_COLOR := Color(1.0, 0.95, 0.4, 0.85)
# Visual
var base_color: Color
@ -28,10 +38,12 @@ var pulses_blocked := 0
var _ready_pulse_tween: Tween = null
var _trail: Array[ColorRect] = []
var _glow: ColorRect
var _perfect_zone: ColorRect
var _face_scale_tween: Tween
var _face_shake_tween: Tween
signal pulse_blocked
signal pulse_blocked_perfect
signal doors_closing
func _ready():
@ -40,6 +52,12 @@ func _ready():
bz.size = Vector2(50, size.y - 40)
bz.position = Vector2(size.x - bz.size.x - 10, 20)
_perfect_zone = ColorRect.new()
_perfect_zone.color = PERFECT_ZONE_COLOR
_perfect_zone.mouse_filter = Control.MOUSE_FILTER_IGNORE
bz.add_child(_perfect_zone)
_update_perfect_zone()
# Pulse line (hidden until first pulse)
var sl = $SweepLine
sl.size = Vector2(4, size.y - 40)
@ -86,6 +104,17 @@ func start():
pulse_gap = 1.0
$AIFace.text = ">:)"
$TargetZone.visible = true
block_zone_moving = false
$TargetZone.position.x = size.x - $TargetZone.size.x - 10
func set_block_zone_movement(speed: float):
block_zone_speed = speed
block_zone_moving = speed > 0.0
var bz = $TargetZone
block_zone_max_x = size.x - bz.size.x - 10
block_zone_min_x = size.x * BLOCK_ZONE_RANGE_LEFT_RATIO
bz.position.x = block_zone_max_x
block_zone_direction = -1
func stop():
active = false
@ -98,6 +127,13 @@ func shrink_block_zone():
var new_width = max(bz.size.x - block_zone_shrink, block_zone_min)
bz.size.x = new_width
bz.position.x = size.x - new_width - 10
_update_perfect_zone()
func _update_perfect_zone():
var bz = $TargetZone
var width = bz.size.x * PERFECT_ZONE_RATIO
_perfect_zone.size = Vector2(width, bz.size.y)
_perfect_zone.position = Vector2((bz.size.x - width) / 2.0, 0)
# --- Pulse logic ---
@ -119,7 +155,20 @@ func get_pulse_gap() -> float:
return pulse_gap
func _process(delta):
if not active or not pulse_active:
if not active:
return
if block_zone_moving:
var bz = $TargetZone
bz.position.x += block_zone_speed * block_zone_direction * delta
if bz.position.x >= block_zone_max_x:
bz.position.x = block_zone_max_x
block_zone_direction = -1
elif bz.position.x <= block_zone_min_x:
bz.position.x = block_zone_min_x
block_zone_direction = 1
if not pulse_active:
return
pulse_x += pulse_speed * delta
@ -151,6 +200,9 @@ func attempt_block() -> bool:
if pulse_x >= bz_left and pulse_x <= bz_right:
# Blocked: doors stay open, this survivor gets in
var perfect_left = bz_left + _perfect_zone.position.x
var perfect_right = perfect_left + _perfect_zone.size.x
var was_perfect = pulse_x >= perfect_left and pulse_x <= perfect_right
pulse_active = false
pulses_blocked += 1
pulse_speed += pulse_speed_increase
@ -160,6 +212,8 @@ func attempt_block() -> bool:
_punch_face(1.4, 4.0)
flash(Color.GREEN)
pulse_blocked.emit()
if was_perfect:
pulse_blocked_perfect.emit()
return true
else:
# Mistimed: same result as letting it through