Skip to content

Commit

Permalink
[πŸ› FIX] λΉŒλ“œ νƒ€μž…μ—λŸ¬ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
bishoe01 committed Jul 19, 2024
1 parent 31875c6 commit 812a3e0
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions handtris/src/components/TetrisPlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -922,25 +922,31 @@ const Home: React.FC = () => {
});

useEffect(() => {
let timeoutId;
if (
!tetrisGameRef.current?.isDonutAttackToggleOn &&
tetrisGameRef.current?.linesCleared > 0
) {
setAnimationState({ opacity: 0, y: -500 });

// Change the image after 1 second if `isDonutAttackToggleOn` is false
timeoutId = setTimeout(() => {
let timeoutId: NodeJS.Timeout | undefined;

if (tetrisGameRef.current) {
const { isDonutAttackToggleOn, linesCleared } = tetrisGameRef.current;

if (!isDonutAttackToggleOn && linesCleared > 0) {
setAnimationState({ opacity: 0, y: -500 });

timeoutId = setTimeout(() => {
setAnimationState({ opacity: 1, y: 0 });
setDonutAttackToggle("/image/DropDefault.png");
}, 1000);
} else if (linesCleared > 0) {
setAnimationState({ opacity: 1, y: 0 });
setDonutAttackToggle("/image/DropDefault.png");
}, 1000);
} else if (tetrisGameRef.current?.linesCleared > 0) {
setAnimationState({ opacity: 1, y: 0 });
setDonutAttackToggle("/image/DropPressed.png");
setDonutAttackToggle("/image/DropPressed.png");
}
}

return () => clearTimeout(timeoutId);
}, [tetrisGameRef.current?.isDonutAttackToggleOn]);
return () => {
if (timeoutId) clearTimeout(timeoutId);
};
}, [
tetrisGameRef.current?.isDonutAttackToggleOn,
tetrisGameRef.current?.linesCleared,
]);

const toggleShowFirstAttack = useCallback(() => {
setShowFirstAttack(true);
Expand Down

0 comments on commit 812a3e0

Please sign in to comment.