Animate piece explosions in drag-drop moves and in XB
[xboard.git] / winboard / winboard.c
index 73a36b6..f818927 100644 (file)
@@ -105,7 +105,6 @@ void DisplayHoldingsCount(HDC hdc, int x, int y, int align, int copyNumber);
 VOID NewVariantPopup(HWND hwnd);\r
 int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY,\r
                   /*char*/int promoChar));\r
-void AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames);\r
 void DisplayMove P((int moveNumber));\r
 Boolean ParseFEN P((Board board, int *blackPlaysFirst, char *fen));\r
 void ChatPopUp P((char *s));\r
@@ -3667,6 +3666,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)
   if(explodeInfo.radius) { // [HGM] atomic\r
        HBRUSH oldBrush;\r
        int x, y, r=(explodeInfo.radius * squareSize)/100;\r
+        ChessSquare piece = board[explodeInfo.fromY][explodeInfo.fromX];\r
         board[explodeInfo.fromY][explodeInfo.fromX] = EmptySquare; // suppress display of capturer\r
        SquareToPos(explodeInfo.toY, explodeInfo.toX, &x, &y);\r
        x += squareSize/2;\r
@@ -3679,6 +3679,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)
        DrawHighlightsOnDC(hdcmem, &highlightInfo, HIGHLIGHT_PEN);\r
        DrawHighlightsOnDC(hdcmem, &premoveHighlightInfo, PREMOVE_PEN);\r
        DrawBoardOnDC(hdcmem, board, tmphdc);\r
+        board[explodeInfo.fromY][explodeInfo.fromX] = piece;\r
        oldBrush = SelectObject(hdcmem, explodeBrush);\r
        Ellipse(hdcmem, x-r, y-r, x+r, y+r);\r
        SelectObject(hdcmem, oldBrush);\r
@@ -9616,26 +9617,26 @@ static void Tween( POINT * start, POINT * mid, POINT * finish, int factor,
      POINT frames[], int * nFrames);\r
 \r
 \r
+#define kFactor 4\r
+\r
 void\r
-AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames)\r
+AnimateAtomicCapture(Board board, int fromX, int fromY, int toX, int toY)\r
 {      // [HGM] atomic: animate blast wave\r
        int i;\r
-if(appData.debugMode) fprintf(debugFP, "exploding (%d,%d)\n", toX, toY);\r
+\r
        explodeInfo.fromX = fromX;\r
        explodeInfo.fromY = fromY;\r
        explodeInfo.toX = toX;\r
        explodeInfo.toY = toY;\r
-       for(i=1; i<nFrames; i++) {\r
-           explodeInfo.radius = (i*180)/(nFrames-1);\r
-           DrawPosition(FALSE, NULL);\r
+       for(i=1; i<4*kFactor; i++) {\r
+           explodeInfo.radius = (i*180)/(4*kFactor-1);\r
+           DrawPosition(FALSE, board);\r
            Sleep(appData.animSpeed);\r
        }\r
        explodeInfo.radius = 0;\r
-       DrawPosition(TRUE, NULL);\r
+       DrawPosition(TRUE, board);\r
 }\r
 \r
-#define kFactor 4\r
-\r
 void\r
 AnimateMove(board, fromX, fromY, toX, toY)\r
      Board board;\r
@@ -9694,9 +9695,7 @@ AnimateMove(board, fromX, fromY, toX, toY)
   animInfo.pos = finish;\r
   DrawPosition(FALSE, NULL);\r
   animInfo.piece = EmptySquare;\r
-  if(gameInfo.variant == VariantAtomic && \r
-     (board[toY][toX] != EmptySquare || fromX != toX && (piece == WhitePawn || piece == BlackPawn) ) )\r
-       AnimateAtomicCapture(fromX, fromY, toX, toY, 2*nFrames);\r
+  Explode(board, fromX, fromY, toX, toY);\r
 }\r
 \r
 /*      Convert board position to corner of screen rect and color       */\r