Changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useSettings } from '@/contexts/SettingsContext';
|
||||
import { useAchievements } from '@/contexts/AchievementsContext';
|
||||
import { Link } from 'react-router-dom';
|
||||
import GlitchCrash from '@/components/GlitchCrash';
|
||||
import { Maximize2, Minimize2 } from 'lucide-react';
|
||||
@@ -43,6 +44,7 @@ const MAZE_TEMPLATE = [
|
||||
|
||||
const Pacman = () => {
|
||||
const { playSound } = useSettings();
|
||||
const { checkGameScoreAchievements, unlockMaxScore } = useAchievements();
|
||||
const [pacman, setPacman] = useState<Position>({ x: 10, y: 15 });
|
||||
const [direction, setDirection] = useState<Direction>('right');
|
||||
const [nextDirection, setNextDirection] = useState<Direction>('right');
|
||||
@@ -112,6 +114,14 @@ const Pacman = () => {
|
||||
if (saved) setHighScore(Math.min(parseInt(saved, 10), MAX_SCORE));
|
||||
}, []);
|
||||
|
||||
// Check score achievements
|
||||
useEffect(() => {
|
||||
if (score > 0) {
|
||||
checkGameScoreAchievements('pacman', score);
|
||||
if (score >= MAX_SCORE) unlockMaxScore();
|
||||
}
|
||||
}, [score, checkGameScoreAchievements, unlockMaxScore]);
|
||||
|
||||
const initDots = useCallback(() => {
|
||||
const newDots = new Set<string>();
|
||||
const newPowerPellets = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user