Commit 1401d21f authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: chess pieces now ACTUALLY animate — call board.animateMove() before setPosition

The animateMove method existed on the board but was never called.
Game scene was still doing board.setPosition() instantly.

Fixed:
- Player moves: animateMove(from, to) → piece slides 200ms → then setPosition
- Bot moves: same — piece slides smoothly before board updates
- Initial position: stays instant (correct — no animation needed on load)

The animation method uses requestAnimationFrame to interpolate piece
position linearly from source square to destination over 200ms.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 18d0e512
......@@ -280,8 +280,11 @@ function executeMove(el, from, to, promotion) {
if (!m) return;
gameState.moveCount++;
board.setPosition(engine.fen());
board.setLastMove(from, to);
// Animate piece sliding from → to, THEN update board state
board.animateMove(from, to, () => {
board.setPosition(engine.fen());
board.setLastMove(from, to);
});
// Sound + Juice
if (m.san.includes('#')) {
......@@ -374,8 +377,11 @@ async function requestBotMove(el) {
const m = engine.move(from, to, promo);
if (m) {
board.setPosition(engine.fen());
board.setLastMove(from, to);
// Animate bot's piece sliding smoothly
board.animateMove(from, to, () => {
board.setPosition(engine.fen());
board.setLastMove(from, to);
});
if (m.san.includes('#')) audio.play('gameOver', 'game');
else if (m.san.includes('+')) audio.play('check', 'game');
......
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