Commit 873b7000 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: backgammon gameplay — working buttons, correct canvas rendering, no DPR bugs

- Remove DPR ctx.scale() that compounded every frame and broke all rendering
- Use logical pixel dimensions directly (canvas.width = logical size)
- Fix isSel/isValid closures that caused undefined reference errors in checker glow
- Simplify game scene: roll button is now a normal element in .bgg-controls (not overlay)
- Event handlers correctly scale click coords via rect ratio
- Remove unused getCheckerScreenPos import from move-animator
- All buttons (roll, double, emote, quit) bind via addEventListener properly
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 4cf9baa5
......@@ -150,13 +150,15 @@ export function drawBoard(ctx, w, h, state, options = {}) {
const vis = Math.min(count, maxVis);
const spacing = Math.min(checkerR * 2, pointH / vis);
const pointIsSelected = selectedPoint === i;
const pointIsValid = highlights.includes(i);
for (let j = 0; j < vis; j++) {
const cy = isTop ? y + checkerR + j * spacing : y - checkerR - j * spacing;
const isTopChecker = j === vis - 1;
const glowing = isTopChecker && isSel === i;
drawChecker(ctx, cx, cy, pieces[j].type, checkerR, {
glow: isSel && isTopChecker,
pulse: isValid(i) && isTopChecker
glow: pointIsSelected && isTopChecker,
pulse: pointIsValid && isTopChecker
});
}
if (count > maxVis) {
......@@ -194,9 +196,6 @@ export function drawBoard(ctx, w, h, state, options = {}) {
// ── Particles ──
if (particles.length) drawParticles(ctx, particles);
function isValid(idx) { return highlights.includes(idx); }
function isSel(idx) { return selectedPoint === idx; }
return layout;
}
......
// Arc-based move animator with overshoot bounce + particle burst
import { getPointCoords, getCheckerScreenPos } from './board-renderer.js';
import { getPointCoords } from './board-renderer.js';
const MOVE_DURATION = 320;
const HIT_DURATION = 420;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment