DrawPosition(TRUE, NULL);
}
+int
+Explode(Board board, int fromX, int fromY, int toX, int toY)
+{
+ if(gameInfo.variant == VariantAtomic &&
+ (board[toY][toX] != EmptySquare || // capture?
+ toX != fromX && (board[fromY][fromX] == WhitePawn || // e.p. ?
+ board[fromY][fromX] == BlackPawn )
+ )) {
+ AnimateAtomicCapture(board, fromX, fromY, toX, toY);
+ return TRUE;
+ }
+ return FALSE;
+}
+
void LeftClick(ClickType clickType, int xPix, int yPix)
{
int x, y;
}
PromotionPopUp();
} else {
+ int oldMove = currentMove;
UserMoveEvent(fromX, fromY, toX, toY, promoChoice);
if (!appData.highlightLastMove || gotPremove) ClearHighlights();
if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY);
+ if(saveAnimate && !appData.animate && currentMove != oldMove && // drag-move was performed
+ Explode(boards[currentMove-1], fromX, fromY, toX, toY))
+ DrawPosition(TRUE, boards[currentMove]);
fromX = fromY = -1;
}
appData.animate = saveAnimate;
extern void ics_update_width P((int new_width));
extern Boolean set_cont_sequence P((char *new_seq));
extern int wrap P((char *dest, char *src, int count, int width, int *lp));
+int Explode P((Board board, int fromX, int fromY, int toX, int toY));
typedef enum { CheckBox, ComboBox, TextBox, Button, Spin, ResetButton,
SaveButton, FileName, PathName, Slider, Message } Control;
void SetPremoveHighlights P((int fromX, int fromY, int toX, int toY));
void ClearPremoveHighlights P((void));
+void AnimateAtomicCapture P((Board board, int fromX, int fromY, int toX, int toY));
void ShutDownFrontEnd P((void));
void BoardToTop P((void));
void AnimateMove P((Board board, int fromX, int fromY, int toX, int toY));
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
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
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
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
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
EndAnimation(anim, finish);
}
+void
+AnimateAtomicCapture(Board board, int fromX, int fromY, int toX, int toY)
+{
+ int i, x, y;
+ ChessSquare piece = board[fromY][toY];
+ board[fromY][toY] = EmptySquare;
+ DrawPosition(FALSE, board);
+ if (flipView) {
+ x = lineGap + ((BOARD_WIDTH-1)-toX) * (squareSize + lineGap);
+ y = lineGap + toY * (squareSize + lineGap);
+ } else {
+ x = lineGap + toX * (squareSize + lineGap);
+ y = lineGap + ((BOARD_HEIGHT-1)-toY) * (squareSize + lineGap);
+ }
+ for(i=1; i<4*kFactor; i++) {
+ int r = squareSize * 9 * i/(20*kFactor - 5);
+ XFillArc(xDisplay, xBoardWindow, highlineGC,
+ x + squareSize/2 - r, y+squareSize/2 - r, 2*r, 2*r, 0, 64*360);
+ FrameDelay(appData.animSpeed);
+ }
+ board[fromY][toY] = piece;
+}
+
/* Main control logic for deciding what to animate and how */
void
else
Tween(&start, &mid, &finish, kFactor, frames, &nFrames);
FrameSequence(&game, piece, startColor, &start, &finish, frames, nFrames);
+ if(Explode(board, fromX, fromY, toX, toY)) { // mark as damaged
+ int i,j;
+ for(i=0; i<BOARD_WIDTH; i++) for(j=0; j<BOARD_HEIGHT; j++)
+ if((i-toX)*(i-toX) + (j-toY)*(j-toY) < 6) damage[0][j][i] = True;
+ }
/* Be sure end square is redrawn */
damage[0][toY][toX] = True;