Skip to content

Commit

Permalink
made an update to the dice animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Avelous committed Feb 24, 2024
1 parent 05a48fc commit c14c3e3
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions packages/nextjs/pages/game/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,25 @@ function GamePage() {
}
setRolls(rolls);
let iterations = 0;
for (let i = 0; i < isUnitRolling.length; i++) {
setTimeout(() => {
setIsUnitRolling(prevState => {
const newState = [...prevState];
newState[i] = false;
return newState;
});
iterations++;
if (iterations === isUnitRolling.length) {
setIsRolling(false);
setTimeout(() => {
setSpinning(false);
setRolledResult(rolls);
}, 500);
}
}, i * 1200);
}
setTimeout(() => {
for (let i = 0; i < isUnitRolling.length; i++) {
setTimeout(() => {
setIsUnitRolling(prevState => {
const newState = [...prevState];
newState[i] = false;
return newState;
});
iterations++;
if (iterations === isUnitRolling.length) {
setIsRolling(false);
setTimeout(() => {
setSpinning(false);
setRolledResult(rolls);
}, 500);
}
}, i * 800);
}
}, 800);
}
};

Expand Down Expand Up @@ -189,7 +191,7 @@ function GamePage() {
const autoRoll = () => {
if (autoRolling && game?.mode === "auto") {
rollTheDice();
timeout = setTimeout(autoRoll, 6500);
timeout = setTimeout(autoRoll, 5000);
}
};
if (game?.winner) {
Expand Down

0 comments on commit c14c3e3

Please sign in to comment.