diff --git a/docs/bay-area-blitz.md b/docs/bay-area-blitz.md index b7a7512b..0937b876 100644 --- a/docs/bay-area-blitz.md +++ b/docs/bay-area-blitz.md @@ -32,7 +32,7 @@ All art comes from `Assets/bay-area-blitz-assets-only`; Hoppy uses that pack's e | Critter / reviewer / boss HP | 1 / 2 / 8 | | Token / ordinary enemy / boss score | 25 / 100 / 1,000 | | Boss cycle | 1.6 s tracking, 0.8 s slam warning, 0.4 s slam, 0.8 s recovery, 0.7 s volley warning, volley and recovery; 6 s total | -| Shield | Blocks one hit; does not stack | +| Shield | Blocks one hit; does not stack. A translucent bubble around Hoppy shows it is held and pops when it absorbs a hit | | LGTM | 5 seconds, 1.35× speed and invulnerability; refresh on pickup | | Auto-Fix | Defeats ordinary enemies within 350 pixels; excludes boss | | Coffee / Full Review | Restore 1 / all HP, capped at 3 | @@ -47,7 +47,7 @@ Terrain uses cropped existing street sprites with matching static solids. This f ## Validation -Run `Godot --headless --path hoppys-adventure-arcade --script res://tests/platformer_smoke.gd` (or omit `--headless` for screenshots in `/tmp/hoppy-*.png`). The suite covers spawn collision, jumping, buffering/coyote time, damage protection, capped healing, shield/boost, pause input, moving cable-car support, melee deduplication, enemy scoring, boss unlock, completion, fresh retry, whole-ground-route traversal, death, and music restoration. +Run `Godot --headless --path hoppys-adventure-arcade --script res://tests/platformer_smoke.gd` (or omit `--headless` for screenshots in `/tmp/hoppy-*.png`). The suite covers spawn collision, jumping, buffering/coyote time, damage protection, capped healing, shield/boost (including the shield bubble, in `platformer_shield.gd`), pause input, moving cable-car support, melee deduplication, enemy scoring, boss unlock, completion, fresh retry, whole-ground-route traversal, death, and music restoration. The existing `tests/menu_smoke.gd` should run with a rendered display for its mouse-hover assertions; headless mouse dispatch does not reproduce those assertions reliably. Keyboard/gamepad action definitions are present; physical-controller feel and packaged exports still need human/device testing. diff --git a/docs/enchanted-repo.md b/docs/enchanted-repo.md index 602ebc0c..b06f1ce0 100644 --- a/docs/enchanted-repo.md +++ b/docs/enchanted-repo.md @@ -12,7 +12,9 @@ Cross the forest and ruined castle, defeat the Legacy Monolith, then land on or ## Route and hazards -The 5,300-pixel route has three gaps (160–170 px), six solid raised root platforms, five crumbling branches, six ordinary enemies, five timed hazards, 25 Commit Tokens, and the existing shield, healing, boost and Auto-Fix pickups. Raised root platforms preserve the artwork's transparent underside; only ground and boundary walls receive a solid backing. Upper routes offer rewards; gaps are also jumpable without waiting for branch regrowth. A full-heal pickup precedes the boss arena. +The 5,300-pixel route has three gaps (160–170 px), six solid raised root platforms, five crumbling branches, six ordinary enemies, five timed hazards, 25 Commit Tokens, and the existing shield, healing, boost and Auto-Fix pickups. A held shield shows as a translucent bubble around Hoppy that pops when it absorbs a hit. + +![Hoppy inside the translucent Approve Shield bubble](previews/enchanted-repo/shield-bubble.png) Raised root platforms preserve the artwork's transparent underside; only ground and boundary walls receive a solid backing. Upper routes offer rewards; gaps are also jumpable without waiting for branch regrowth. A full-heal pickup precedes the boss arena. Branches support Hoppy until 0.7 seconds after landing, then remove collision, show breaking/falling art, and regrow after a 0.25-second break plus 3.5-second absence. Regrowth waits if Hoppy occupies the future platform shape. Pause freezes all timers. Branches over gaps provide stepping stones; falling into a pit still kills Hoppy through the normal retry flow. diff --git a/docs/orbital-ops.md b/docs/orbital-ops.md index 13d999f0..4fc41288 100644 --- a/docs/orbital-ops.md +++ b/docs/orbital-ops.md @@ -17,7 +17,7 @@ Launch the project, choose **Platformer Game → Play Orbital Ops**. Direct scen A 5,300-pixel station route includes upper one-way decks, two gaps, a service shuttle, six ordinary enemies, three timed CI lasers, three vacuum vents, a marked zero-gravity bay, pickups, and a gated boss arena. The shuttle uses Bay Area's ten-second round-trip timetable with one-second endpoint stops, dedicated moving-platform collision layer, and upward/horizontal dismount velocity inheritance. The main route does not require riding it. -Lasers cycle through 2.0s off, 0.9s amber warning, 1.6s red active, and 0.7s cooldown. Wait for a safe phase before crossing; only active beams damage. Vents use the same phase lengths with different offsets, pull nearby Hoppy down and toward the grille, and damage on contact with the active grille. Their amber warnings are safe. Damage respects the same shields and invulnerability as Bay Area. +Lasers cycle through 2.0s off, 0.9s amber warning, 1.6s red active, and 0.7s cooldown. Wait for a safe phase before crossing; only active beams damage. Vents use the same phase lengths with different offsets, pull nearby Hoppy down and toward the grille, and damage on contact with the active grille. Their amber warnings are safe. Damage respects the same shields and invulnerability as Bay Area; a held shield shows as the shared bubble around Hoppy. Rogue AI bots have 2 HP, patrol locally, warn for 0.75s, and fire one non-homing plasma shot. Security Vulnerability Drones have 1 HP and visibly mark a target before committing to a dive, then return to their patrol origin. Ordinary enemies award 100 points; Commit Tokens award 25. Existing shared pickups retain Bay Area behavior, including Auto-Fix excluding the boss. diff --git a/docs/previews/enchanted-repo/shield-bubble.png b/docs/previews/enchanted-repo/shield-bubble.png new file mode 100644 index 00000000..9d57e89f Binary files /dev/null and b/docs/previews/enchanted-repo/shield-bubble.png differ diff --git a/hoppys-adventure-arcade/modes/platformer/player.gd b/hoppys-adventure-arcade/modes/platformer/player.gd index 736cb94c..a8d4926b 100644 --- a/hoppys-adventure-arcade/modes/platformer/player.gd +++ b/hoppys-adventure-arcade/modes/platformer/player.gd @@ -5,12 +5,20 @@ signal jumped signal hurt signal swiped const Art = preload("res://modes/platformer/art.gd") +const ShieldBubble = preload("res://modes/platformer/shield_bubble.gd") const SPEED := 310.0 const JUMP := -740.0 var dead := false var input_lock := 0.0 var hp := 3 -var shield := false +## One absorbed hit. The bubble child mirrors it: raised when gained, popped when lost. +var shield := false: + set(value): + var changed := value != shield + shield = value + if bubble == null or not changed: return + if value: bubble.raise() + else: bubble.pop() var boost := 0.0 var invulnerable := 0.0 var hurt_time := 0.0 @@ -24,6 +32,7 @@ var zero_gravity := false var environmental_acceleration := Vector2.ZERO var sprite: AnimatedSprite2D var swipe: Area2D +var bubble: Node2D func _ready() -> void: collision_layer = 2 collision_mask = 1 | 8 @@ -33,6 +42,8 @@ func _ready() -> void: sprite = Art.sprite("hoppy/platformer", "idle") sprite.offset.y = -40 add_child(sprite) + bubble = ShieldBubble.new() + add_child(bubble) swipe = Area2D.new() swipe.collision_layer = 0 swipe.collision_mask = 4 @@ -86,7 +97,7 @@ func _physics_process(dt: float) -> void: target.take_hit() move_and_slide() sprite.flip_h = facing < 0 - sprite.modulate = Color(0.6, 1, 0.8) if boost > 0 or shield else Color.WHITE + sprite.modulate = Color(0.6, 1, 0.8) if boost > 0 else Color.WHITE sprite.modulate.a = 0.4 if invulnerable > 0 and fmod(invulnerable, 0.16) < 0.08 else 1.0 var clip := "idle" if hurt_time > 0: clip = "hurt" @@ -126,6 +137,7 @@ func _die() -> void: invulnerable = 0 health_changed.emit() sprite.modulate = Color.WHITE + bubble.clear() sprite.animation = &"death" sprite.pause() sprite.frame = sprite.sprite_frames.get_frame_count(&"death") - 1 diff --git a/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd b/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd new file mode 100644 index 00000000..a0cf3a02 --- /dev/null +++ b/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd @@ -0,0 +1,87 @@ +## The Approve Shield's visual: a translucent pixel bubble drawn around Hoppy. +## +## The player owns one of these as a child in front of its sprite. It shows when the shield +## is gained, breathes gently while the shield holds, and pops (a quick swell and fade) when +## the shield absorbs a hit or is otherwise lost. It is presentation only; the gameplay flag +## stays on the player. +extends Node2D +const RADIUS := Vector2(36.0, 48.0) +const CENTER := Vector2(0.0, -38.0) +const SEGMENTS := 20 +const FILL := Color(0.45, 0.85, 1.0, 0.22) +const RIM := Color(0.6, 0.95, 1.0, 0.85) +const SHINE := Color(1.0, 1.0, 1.0, 0.75) +const POP_TIME := 0.22 +## True while the shield holds; false once it is popping or hidden. +var active := false +var _pulse := 0.0 +var _tween: Tween + + +func _ready() -> void: + z_index = 1 + visible = false + + +func _process(dt: float) -> void: + if not active: return + _pulse += dt + scale = Vector2.ONE * (1.0 + 0.03 * sin(_pulse * 4.0)) + queue_redraw() + + +## Show the bubble; a shield gained while the bubble was still popping reopens it cleanly. +func raise() -> void: + _kill_tween() + active = true + _pulse = 0.0 + scale = Vector2.ONE + modulate = Color.WHITE + visible = true + queue_redraw() + + +## Swell and fade out, then hide. Safe to call when already hidden. +func pop() -> void: + if not active: return + active = false + _kill_tween() + _tween = create_tween().set_parallel(true) + _tween.tween_property(self, "scale", Vector2.ONE * 1.35, POP_TIME).set_ease(Tween.EASE_OUT) + _tween.tween_property(self, "modulate:a", 0.0, POP_TIME) + _tween.chain().tween_callback(_finish_pop) + + +## Hide at once with no animation (death, scene reset). +func clear() -> void: + _kill_tween() + active = false + visible = false + modulate = Color.WHITE + scale = Vector2.ONE + + +func _finish_pop() -> void: + _tween = null + visible = false + modulate = Color.WHITE + scale = Vector2.ONE + + +func _kill_tween() -> void: + if _tween != null and _tween.is_valid(): _tween.kill() + _tween = null + + +func _draw() -> void: + var points := PackedVector2Array() + for i in SEGMENTS: + var angle := TAU * i / SEGMENTS + points.append(CENTER + Vector2(cos(angle) * RADIUS.x, sin(angle) * RADIUS.y)) + draw_colored_polygon(points, FILL) + points.append(points[0]) + draw_polyline(points, RIM, 3.0) + # A chunky highlight on the upper-left, like a soap bubble catching the light. + var shine := CENTER + Vector2(-RADIUS.x * 0.55, -RADIUS.y * 0.6) + draw_rect(Rect2(shine, Vector2(8, 4)), SHINE) + draw_rect(Rect2(shine + Vector2(-4, 4), Vector2(4, 8)), SHINE) diff --git a/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd.uid b/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd.uid new file mode 100644 index 00000000..02ff3b7d --- /dev/null +++ b/hoppys-adventure-arcade/modes/platformer/shield_bubble.gd.uid @@ -0,0 +1 @@ +uid://cnvrx6k3sfivl diff --git a/hoppys-adventure-arcade/tests/platformer_shield.gd b/hoppys-adventure-arcade/tests/platformer_shield.gd new file mode 100644 index 00000000..f5bc31b3 --- /dev/null +++ b/hoppys-adventure-arcade/tests/platformer_shield.gd @@ -0,0 +1,89 @@ +## The Approve Shield shows as a bubble around Hoppy, not as a tint on the sprite. +## +## Runs headless against Bay Area Blitz, the shared platformer level. Covers: the bubble is +## hidden on spawn, appears when the shield is gained, replaces the old green tint, pops when +## the shield absorbs a hit (and the hit still costs no health), hides once the pop finishes, +## reopens for a second pickup, and clears instantly on death. +extends SceneTree +var failures := 0 +var level +var player + + +func _initialize() -> void: call_deferred("run") + + +func frames(count: int) -> void: + for i in count: await physics_frame + + +func check(ok: bool, message: String) -> void: + print("PASS: " if ok else "FAIL: ", message) + if not ok: failures += 1 + + +func run() -> void: + change_scene_to_file("res://scenes/platformer/bay_area_blitz.tscn") + await frames(12) + level = current_scene + player = level.player + await process_frame + level._resume() + var bubble: Node2D = player.bubble + check(bubble != null and bubble.get_parent() == player, "The player owns a shield bubble child") + check(bubble.get_index() > player.sprite.get_index() and bubble.z_index >= player.sprite.z_index, + "The bubble draws in front of Hoppy's sprite") + check(not bubble.visible and not bubble.active, "The bubble is hidden before any pickup") + player.boost = 0 + player.invulnerable = 0 + player.shield = true + check(bubble.visible and bubble.active, "Gaining the shield raises the bubble") + await frames(3) + check(player.sprite.modulate == Color.WHITE, "The shield no longer tints Hoppy green") + check(bubble.visible and bubble.active, "The bubble stays while the shield holds") + player.hp = 3 + player.damage(0) + check(player.hp == 3 and not player.shield, "The shield still absorbs one hit without health loss") + check(not bubble.active, "Absorbing a hit pops the bubble") + await frames(30) + check(not bubble.visible, "The popped bubble is hidden once its pop animation ends") + # The blink and boost tints survive the change. + check(player.invulnerable > 0, "Absorbing a hit still grants invulnerability") + player.boost = 5 + await frames(2) + check(player.sprite.modulate.r < 1.0, "The LGTM boost tint still shows") + player.boost = 0 + player.invulnerable = 0 + # A second pickup reopens the bubble even if it was still popping. + player.shield = true + player.shield = false + player.shield = true + check(bubble.visible and bubble.active and bubble.modulate.a == 1.0, + "A new shield reopens a popping bubble at full strength") + player.shield = true + check(bubble.active, "Setting an already-held shield is a no-op") + # The level's real pickup path raises it too. + player.shield = false + await frames(30) + var shield_item: Dictionary = {} + for item in level.pickups: + if item.kind == "approve_shield": shield_item = item + check(not shield_item.is_empty(), "Bay Area still has an Approve Shield pickup") + if not shield_item.is_empty(): + player.invulnerable = 999 + player.position = shield_item.origin + player.velocity = Vector2.ZERO + await frames(4) + check(player.shield and bubble.visible and bubble.active, + "Collecting the pickup raises the bubble") + # Death clears it without waiting on an animation. + player.invulnerable = 0 + player.hp = 1 + player.shield = true + player.shield = false + player.damage(0) + check(player.hp == 0 and not bubble.visible and not bubble.active, + "Death clears the bubble at once") + print("Shield bubble suite finished with %d failure(s)" % failures) + await process_frame + quit(1 if failures > 0 else 0) diff --git a/hoppys-adventure-arcade/tests/platformer_shield.gd.uid b/hoppys-adventure-arcade/tests/platformer_shield.gd.uid new file mode 100644 index 00000000..a417af7c --- /dev/null +++ b/hoppys-adventure-arcade/tests/platformer_shield.gd.uid @@ -0,0 +1 @@ +uid://dqpxakaa16bvk