Skip to content

Commit

Permalink
fix(drop-and-fusion): バブルゲームのリトライボタンでリトライができない問題を修正 (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Jan 9, 2024
2 parents 5efea32 + 96240f7 commit 38469c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/frontend/src/pages/drop-and-fusion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div :class="$style.frame">
<div :class="$style.frameInner">
<MkButton danger @click="surrender">Retry</MkButton>
<MkButton v-if="!isGameOver && !replaying" full danger @click="surrender">Surrender</MkButton>
<MkButton v-else full @click="retry">Retry</MkButton>
</div>
</div>
</div>
Expand Down Expand Up @@ -483,15 +484,22 @@ async function surrender() {
game.surrender();
}

async function retry() {
end();
await start();
}

function end() {
game.dispose();
isGameOver.value = false;
replaying.value = false;
currentPick.value = null;
dropReady.value = true;
stock.value = [];
score.value = 0;
combo.value = 0;
comboPrev.value = 0;
maxCombo.value = 0;
bgmNodes?.soundSource.stop();
gameStarted.value = false;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/scripts/drop-and-fusion-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,13 @@ export class DropAndFusionGame extends EventEmitter<{
});
this.emit('changeStock', this.stock);

const x = Math.min(this.gameWidth - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), Math.round(_x)));
const inputX = Math.round(_x);
const x = Math.min(this.gameWidth - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), inputX));
const body = this.createBody(head.mono, x, 50 + head.mono.size / 2);
this.logs.push({
frame: this.frame,
operation: 'drop',
x,
x: inputX,
});
Matter.Composite.add(this.engine.world, body);
this.activeBodyIds.push(body.id);
Expand Down

0 comments on commit 38469c2

Please sign in to comment.