feat: 018 — larger pig hitbox - #20
Conversation
Extract buildHitRects as pure function so rect logic is testable without Tauri. Hitbox is 16px larger than sprite and centred, so clicks within ~8px outside the pig still register.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ChangesHitbox Padding & Rect Building
sequenceDiagram
participant User
participant React_UI as React (PigSprite)
participant Hook as usePigMovement
participant Rust as WASM/Rust PigHitTester
User->>React_UI: click near pig
React_UI->>Hook: (render / polling) request pig rects
Hook->>Hook: buildHitRects(pigs, dpr) -> padded DPR-scaled rects
Hook->>Rust: update_pig_rects(rects)
Rust->>Rust: PigHitTester.is_hit checks rects against cursor
Rust-->>React_UI: (hit result) toggle click-through / state
React_UI-->>User: UI response (detail open / click)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 6/10 reviews remaining, refill in 19 minutes and 39 seconds. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/usePigMovement.ts`:
- Around line 127-130: The function buildHitRects currently returns an inline
object type; define and export a named type/interface (e.g., export type HitRect
= { x: number; y: number; size: number }) at the top of the module and change
the function signature to return HitRect[] (keeping PigState and dpr as-is),
then update any usages to reference HitRect so the module boundary uses a named
type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 10d35d8c-05a9-4a3f-8cb9-ac5dacd734d5
📒 Files selected for processing (2)
src/hooks/usePigMovement.test.tssrc/hooks/usePigMovement.ts
Summary
HITBOX_PADDING = 16constant (exported)buildHitRects(pigs, dpr)as pure function — rect size isPIG_SIZE + HITBOX_PADDING, centred on sprite with-(HITBOX_PADDING/2)offsetsyncRectsdelegates tobuildHitRects; no Rust changes neededTest plan
task checkgreenCloses #16
Summary by CodeRabbit
Improvements
Tests