From acb2fc82bad0c21cec3ff2cf010a1393c08ecb84 Mon Sep 17 00:00:00 2001 From: hypercross Date: Sun, 5 Apr 2026 09:45:01 +0800 Subject: [PATCH] feat: animate after booped --- .qwenignore | 1 + packages/boop-game/src/game/commands.ts | 11 ++++++++++- packages/boop-game/src/scenes/PieceSpawner.ts | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .qwenignore diff --git a/.qwenignore b/.qwenignore new file mode 100644 index 0000000..22fb128 --- /dev/null +++ b/.qwenignore @@ -0,0 +1 @@ +!node_modules \ No newline at end of file diff --git a/packages/boop-game/src/game/commands.ts b/packages/boop-game/src/game/commands.ts index 7a5df4b..d422a0d 100644 --- a/packages/boop-game/src/game/commands.ts +++ b/packages/boop-game/src/game/commands.ts @@ -51,6 +51,7 @@ const placeCommand = registry.register( 'place (); await game.produceAsync((state: BoopState) => { // 按照远离放置位置的方向推动 for (const [dr, dc] of getNeighborPositions()) { @@ -73,8 +74,9 @@ async function boop(game: BoopGame, row: number, col: number, type: PieceType) { // 检查新位置是否为空或在棋盘外 if (!isInBounds(newRow, newCol)) { // 棋子被推出棋盘,返回玩家supply + toRemove.add(part.id); booped.push(part.id); - moveToRegion(part, state.regions.board, state.regions[part.player]); + moveToRegion(part, state.regions.board, state.regions.board, [newRow, newCol]); } else if (!isCellOccupied(state, newRow, newCol)) { // 新位置为空,移动过去 booped.push(part.id); @@ -83,6 +85,13 @@ async function boop(game: BoopGame, row: number, col: number, type: PieceType) { // 如果新位置被占用,则不移动(两个棋子都保持原位) } }); + await game.produceAsync((state: BoopState) => { + // 移除被吃掉的棋子 + for (const partId of toRemove) { + const part = state.pieces[partId]; + moveToRegion(part, state.regions.board, state.regions[part.player]); + } + }); return { booped }; } diff --git a/packages/boop-game/src/scenes/PieceSpawner.ts b/packages/boop-game/src/scenes/PieceSpawner.ts index e748e49..ba5d107 100644 --- a/packages/boop-game/src/scenes/PieceSpawner.ts +++ b/packages/boop-game/src/scenes/PieceSpawner.ts @@ -22,13 +22,14 @@ class BoopPartSpawner implements Spawner const x = BOARD_OFFSET.x + col * CELL_SIZE + CELL_SIZE / 2; const y = BOARD_OFFSET.y + row * CELL_SIZE + CELL_SIZE / 2; - this.scene.tweens.add({ + const tween = this.scene.tweens.add({ targets: obj, x: x, y: y, duration: 200, ease: 'Power2', }); + this.scene.addTweenInterruption(tween); } onSpawn(part: BoopPart) {