Skip to content

Commit 4b6761f

Browse files
authored
Merge pull request #110 from coderabbitai/feat/platformer-shield-bubble
feat(platformer): draw the Approve Shield as a bubble around Hoppy
2 parents 5de28fc + 27f0b30 commit 4b6761f

9 files changed

Lines changed: 198 additions & 6 deletions

File tree

‎docs/bay-area-blitz.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ All art comes from `Assets/bay-area-blitz-assets-only`; Hoppy uses that pack's e
3232
| Critter / reviewer / boss HP | 1 / 2 / 8 |
3333
| Token / ordinary enemy / boss score | 25 / 100 / 1,000 |
3434
| 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 |
35-
| Shield | Blocks one hit; does not stack |
35+
| Shield | Blocks one hit; does not stack. A translucent bubble around Hoppy shows it is held and pops when it absorbs a hit |
3636
| LGTM | 5 seconds, 1.35× speed and invulnerability; refresh on pickup |
3737
| Auto-Fix | Defeats ordinary enemies within 350 pixels; excludes boss |
3838
| 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
4747

4848
## Validation
4949

50-
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.
50+
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.
5151

5252
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.
5353

‎docs/enchanted-repo.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Cross the forest and ruined castle, defeat the Legacy Monolith, then land on or
1212

1313
## Route and hazards
1414

15-
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.
15+
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.
16+
17+
![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.
1618

1719
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.
1820

‎docs/orbital-ops.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Launch the project, choose **Platformer Game → Play Orbital Ops**. Direct scen
1717

1818
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.
1919

20-
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.
20+
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.
2121

2222
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.
2323

124 KB
Loading

‎hoppys-adventure-arcade/modes/platformer/player.gd‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ signal jumped
55
signal hurt
66
signal swiped
77
const Art = preload("res://modes/platformer/art.gd")
8+
const ShieldBubble = preload("res://modes/platformer/shield_bubble.gd")
89
const SPEED := 310.0
910
const JUMP := -740.0
1011
var dead := false
1112
var input_lock := 0.0
1213
var hp := 3
13-
var shield := false
14+
## One absorbed hit. The bubble child mirrors it: raised when gained, popped when lost.
15+
var shield := false:
16+
set(value):
17+
var changed := value != shield
18+
shield = value
19+
if bubble == null or not changed: return
20+
if value: bubble.raise()
21+
else: bubble.pop()
1422
var boost := 0.0
1523
var invulnerable := 0.0
1624
var hurt_time := 0.0
@@ -24,6 +32,7 @@ var zero_gravity := false
2432
var environmental_acceleration := Vector2.ZERO
2533
var sprite: AnimatedSprite2D
2634
var swipe: Area2D
35+
var bubble: Node2D
2736
func _ready() -> void:
2837
collision_layer = 2
2938
collision_mask = 1 | 8
@@ -33,6 +42,8 @@ func _ready() -> void:
3342
sprite = Art.sprite("hoppy/platformer", "idle")
3443
sprite.offset.y = -40
3544
add_child(sprite)
45+
bubble = ShieldBubble.new()
46+
add_child(bubble)
3647
swipe = Area2D.new()
3748
swipe.collision_layer = 0
3849
swipe.collision_mask = 4
@@ -86,7 +97,7 @@ func _physics_process(dt: float) -> void:
8697
target.take_hit()
8798
move_and_slide()
8899
sprite.flip_h = facing < 0
89-
sprite.modulate = Color(0.6, 1, 0.8) if boost > 0 or shield else Color.WHITE
100+
sprite.modulate = Color(0.6, 1, 0.8) if boost > 0 else Color.WHITE
90101
sprite.modulate.a = 0.4 if invulnerable > 0 and fmod(invulnerable, 0.16) < 0.08 else 1.0
91102
var clip := "idle"
92103
if hurt_time > 0: clip = "hurt"
@@ -126,6 +137,7 @@ func _die() -> void:
126137
invulnerable = 0
127138
health_changed.emit()
128139
sprite.modulate = Color.WHITE
140+
bubble.clear()
129141
sprite.animation = &"death"
130142
sprite.pause()
131143
sprite.frame = sprite.sprite_frames.get_frame_count(&"death") - 1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## The Approve Shield's visual: a translucent pixel bubble drawn around Hoppy.
2+
##
3+
## The player owns one of these as a child in front of its sprite. It shows when the shield
4+
## is gained, breathes gently while the shield holds, and pops (a quick swell and fade) when
5+
## the shield absorbs a hit or is otherwise lost. It is presentation only; the gameplay flag
6+
## stays on the player.
7+
extends Node2D
8+
const RADIUS := Vector2(36.0, 48.0)
9+
const CENTER := Vector2(0.0, -38.0)
10+
const SEGMENTS := 20
11+
const FILL := Color(0.45, 0.85, 1.0, 0.22)
12+
const RIM := Color(0.6, 0.95, 1.0, 0.85)
13+
const SHINE := Color(1.0, 1.0, 1.0, 0.75)
14+
const POP_TIME := 0.22
15+
## True while the shield holds; false once it is popping or hidden.
16+
var active := false
17+
var _pulse := 0.0
18+
var _tween: Tween
19+
20+
21+
func _ready() -> void:
22+
z_index = 1
23+
visible = false
24+
25+
26+
func _process(dt: float) -> void:
27+
if not active: return
28+
_pulse += dt
29+
scale = Vector2.ONE * (1.0 + 0.03 * sin(_pulse * 4.0))
30+
queue_redraw()
31+
32+
33+
## Show the bubble; a shield gained while the bubble was still popping reopens it cleanly.
34+
func raise() -> void:
35+
_kill_tween()
36+
active = true
37+
_pulse = 0.0
38+
scale = Vector2.ONE
39+
modulate = Color.WHITE
40+
visible = true
41+
queue_redraw()
42+
43+
44+
## Swell and fade out, then hide. Safe to call when already hidden.
45+
func pop() -> void:
46+
if not active: return
47+
active = false
48+
_kill_tween()
49+
_tween = create_tween().set_parallel(true)
50+
_tween.tween_property(self, "scale", Vector2.ONE * 1.35, POP_TIME).set_ease(Tween.EASE_OUT)
51+
_tween.tween_property(self, "modulate:a", 0.0, POP_TIME)
52+
_tween.chain().tween_callback(_finish_pop)
53+
54+
55+
## Hide at once with no animation (death, scene reset).
56+
func clear() -> void:
57+
_kill_tween()
58+
active = false
59+
visible = false
60+
modulate = Color.WHITE
61+
scale = Vector2.ONE
62+
63+
64+
func _finish_pop() -> void:
65+
_tween = null
66+
visible = false
67+
modulate = Color.WHITE
68+
scale = Vector2.ONE
69+
70+
71+
func _kill_tween() -> void:
72+
if _tween != null and _tween.is_valid(): _tween.kill()
73+
_tween = null
74+
75+
76+
func _draw() -> void:
77+
var points := PackedVector2Array()
78+
for i in SEGMENTS:
79+
var angle := TAU * i / SEGMENTS
80+
points.append(CENTER + Vector2(cos(angle) * RADIUS.x, sin(angle) * RADIUS.y))
81+
draw_colored_polygon(points, FILL)
82+
points.append(points[0])
83+
draw_polyline(points, RIM, 3.0)
84+
# A chunky highlight on the upper-left, like a soap bubble catching the light.
85+
var shine := CENTER + Vector2(-RADIUS.x * 0.55, -RADIUS.y * 0.6)
86+
draw_rect(Rect2(shine, Vector2(8, 4)), SHINE)
87+
draw_rect(Rect2(shine + Vector2(-4, 4), Vector2(4, 8)), SHINE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://cnvrx6k3sfivl
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
## The Approve Shield shows as a bubble around Hoppy, not as a tint on the sprite.
2+
##
3+
## Runs headless against Bay Area Blitz, the shared platformer level. Covers: the bubble is
4+
## hidden on spawn, appears when the shield is gained, replaces the old green tint, pops when
5+
## the shield absorbs a hit (and the hit still costs no health), hides once the pop finishes,
6+
## reopens for a second pickup, and clears instantly on death.
7+
extends SceneTree
8+
var failures := 0
9+
var level
10+
var player
11+
12+
13+
func _initialize() -> void: call_deferred("run")
14+
15+
16+
func frames(count: int) -> void:
17+
for i in count: await physics_frame
18+
19+
20+
func check(ok: bool, message: String) -> void:
21+
print("PASS: " if ok else "FAIL: ", message)
22+
if not ok: failures += 1
23+
24+
25+
func run() -> void:
26+
change_scene_to_file("res://scenes/platformer/bay_area_blitz.tscn")
27+
await frames(12)
28+
level = current_scene
29+
player = level.player
30+
await process_frame
31+
level._resume()
32+
var bubble: Node2D = player.bubble
33+
check(bubble != null and bubble.get_parent() == player, "The player owns a shield bubble child")
34+
check(bubble.get_index() > player.sprite.get_index() and bubble.z_index >= player.sprite.z_index,
35+
"The bubble draws in front of Hoppy's sprite")
36+
check(not bubble.visible and not bubble.active, "The bubble is hidden before any pickup")
37+
player.boost = 0
38+
player.invulnerable = 0
39+
player.shield = true
40+
check(bubble.visible and bubble.active, "Gaining the shield raises the bubble")
41+
await frames(3)
42+
check(player.sprite.modulate == Color.WHITE, "The shield no longer tints Hoppy green")
43+
check(bubble.visible and bubble.active, "The bubble stays while the shield holds")
44+
player.hp = 3
45+
player.damage(0)
46+
check(player.hp == 3 and not player.shield, "The shield still absorbs one hit without health loss")
47+
check(not bubble.active, "Absorbing a hit pops the bubble")
48+
await frames(30)
49+
check(not bubble.visible, "The popped bubble is hidden once its pop animation ends")
50+
# The blink and boost tints survive the change.
51+
check(player.invulnerable > 0, "Absorbing a hit still grants invulnerability")
52+
player.boost = 5
53+
await frames(2)
54+
check(player.sprite.modulate.r < 1.0, "The LGTM boost tint still shows")
55+
player.boost = 0
56+
player.invulnerable = 0
57+
# A second pickup reopens the bubble even if it was still popping.
58+
player.shield = true
59+
player.shield = false
60+
player.shield = true
61+
check(bubble.visible and bubble.active and bubble.modulate.a == 1.0,
62+
"A new shield reopens a popping bubble at full strength")
63+
player.shield = true
64+
check(bubble.active, "Setting an already-held shield is a no-op")
65+
# The level's real pickup path raises it too.
66+
player.shield = false
67+
await frames(30)
68+
var shield_item: Dictionary = {}
69+
for item in level.pickups:
70+
if item.kind == "approve_shield": shield_item = item
71+
check(not shield_item.is_empty(), "Bay Area still has an Approve Shield pickup")
72+
if not shield_item.is_empty():
73+
player.invulnerable = 999
74+
player.position = shield_item.origin
75+
player.velocity = Vector2.ZERO
76+
await frames(4)
77+
check(player.shield and bubble.visible and bubble.active,
78+
"Collecting the pickup raises the bubble")
79+
# Death clears it without waiting on an animation.
80+
player.invulnerable = 0
81+
player.hp = 1
82+
player.shield = true
83+
player.shield = false
84+
player.damage(0)
85+
check(player.hp == 0 and not bubble.visible and not bubble.active,
86+
"Death clears the bubble at once")
87+
print("Shield bubble suite finished with %d failure(s)" % failures)
88+
await process_frame
89+
quit(1 if failures > 0 else 0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://dqpxakaa16bvk

0 commit comments

Comments
 (0)