shaack / cm-chessboard

A JavaScript chessboard without dependencies. Rendered in SVG, coded in ES6. Views FEN, handles move input, animated, responsive, expandable
MIT License
223 stars 67 forks source link

Moving pieces over existing pieces during an animation #63

Closed wiegerw closed 2 years ago

wiegerw commented 2 years ago

When calling movePiece, the animated piece moves under or over existing pieces depending on the direction of the movement. This becomes visible in the example below. Is it possible to always make the animated piece move over existing pieces? I'm trying to use animations for captures in the game of draughts. During a capture move you jump over other pieces, and then it looks weird if an animation does it the other way around.

        board.setPiece("c4", PIECE.wq)
        board.setPiece("d4", PIECE.bp)
        board.setPiece("c5", PIECE.bp)
        board.setPiece("b4", PIECE.bp)
        board.setPiece("c3", PIECE.bp)
        await board.movePiece("c4", "e4")
        await board.movePiece("e4", "c4")
        await board.movePiece("c4", "c6")
        await board.movePiece("c6", "c4")
        await board.movePiece("c4", "a4")
        await board.movePiece("a4", "c4")
        await board.movePiece("c4", "c2")
        await board.movePiece("c2", "c4")
shaack commented 2 years ago

This is fixed with 4.0.6. Moving pieces will now be rendered above not moving pieces.