A modern rebuild of the Number Locks puzzle game using React, TypeScript, and Capacitor for cross-platform deployment (Web, Android, iOS).
Number Locks is a challenging puzzle game where players swipe numbered tiles to subtract them from each other, with the goal of clearing all tiles from the board. The game features:
- 30 progressive levels across 3 vaults
- Tutorial system for new players
- Star/key-based progression system
- Sound effects and haptic feedback
- Offline PWA support
- Cross-platform (Web, Android, iOS)
- React 18 - Modern UI framework
- TypeScript 5 - Type-safe development
- Vite 5 - Lightning-fast build tool
- Capacitor 6 - Native mobile bridge
- Zustand 4 - Lightweight state management with persistence
- localStorage - Progress and settings persistence
- CSS Modules - Scoped component styling
- Framer Motion 11 - Smooth animations and transitions
- @use-gesture/react - 8-directional swipe detection
- @capacitor/haptics - Haptic feedback
- @capacitor/status-bar - Status bar customization
- @capacitor/splash-screen - Launch screen
- @capacitor/screen-orientation - Portrait lock
- vite-plugin-pwa - Progressive Web App features
- Workbox - Offline caching strategies
- Vitest - Fast unit testing
- ESLint - Code linting
- TypeScript strict mode - Full type safety
numberlocks-react/
├── public/ # Static assets
│ ├── audio/ # Sound effects
│ ├── img/ # Images and icons
│ └── manifest.json # PWA manifest
├── src/
│ ├── components/
│ │ ├── Game/ # Game board components
│ │ ├── Modals/ # Modal dialogs
│ │ ├── Screens/ # App screens
│ │ └── ErrorBoundary.tsx
│ ├── config/
│ │ ├── levels.ts # All 30 level definitions
│ │ ├── constants.ts # Game constants
│ │ ├── admob.config.ts
│ │ └── analytics.config.ts
│ ├── hooks/
│ │ └── useSwipeGesture.ts
│ ├── services/
│ │ ├── AudioService.ts
│ │ ├── HapticsService.ts
│ │ ├── AnalyticsService.ts
│ │ ├── AdMobService.ts
│ │ └── CapacitorService.ts
│ ├── store/
│ │ ├── gameStore.ts # Current game state
│ │ ├── progressStore.ts # Player progress
│ │ ├── settingsStore.ts # App settings
│ │ └── navigationStore.ts # Screen navigation
│ ├── types/
│ │ ├── game.types.ts
│ │ └── level.types.ts
│ ├── utils/
│ │ ├── gameLogic.ts # Core game mechanics
│ │ └── starCalculator.ts # Star rating system
│ ├── App.tsx
│ └── main.tsx
├── capacitor.config.ts # Capacitor configuration
├── vite.config.ts # Vite build configuration
└── MIGRATION_PLAN.md # Full migration documentation
- Node.js 18+ (20+ recommended)
- npm 10+
- For mobile builds:
- Android Studio (for Android)
- Xcode (for iOS, macOS only)
- Clone the repository:
git clone https://github.com/ap0894/numberlocks-react.git
cd numberlocks-react- Install dependencies:
npm install- Start development server:
npm run dev- Open browser to
http://localhost:5173
npm run dev- Start development server with hot reloadnpm run build- Build production bundle todist/npm run preview- Preview production build locallynpm run test- Run unit tests with Vitestnpm run lint- Run ESLint
npm run devThe app will automatically open in your browser at http://localhost:5173.
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coveragenpx tsc --noEmitnpm run buildThis creates an optimized production build in the dist/ directory with:
- Minified JavaScript and CSS
- Tree-shaken dependencies
- Service worker for offline support
- PWA manifest
npm run preview- Build the web app:
npm run build- Sync with Capacitor:
npx cap sync android- Open in Android Studio:
npx cap open android- Build and run from Android Studio, or use:
npx cap run android- Build the web app:
npm run build- Sync with Capacitor:
npx cap sync ios- Open in Xcode:
npx cap open ios- Build and run from Xcode, or use:
npx cap run ios- Push to GitHub:
git add .
git commit -m "Build production version"
git push origin main- Configure your webhost to pull from GitHub repository
- Set build command:
npm run build - Set publish directory:
dist
- Open project in Android Studio
- Build > Generate Signed Bundle / APK
- Follow Google Play Console upload process
- Open project in Xcode
- Product > Archive
- Follow App Store Connect upload process
The game uses Zustand for state management with three main stores:
- gameStore - Current game session (tiles, moves, stars)
- progressStore - Player progress (levels completed, total stars)
- settingsStore - App settings (sound, etc.)
- navigationStore - Screen navigation state
All stores use Zustand persist middleware for automatic localStorage synchronization.
Core game mechanics in src/utils/gameLogic.ts:
- Tile Movement - Calculate target position based on swipe direction
- Subtraction -
Math.abs(tile1 - tile2) - Pair Detection - Find adjacent matching numbers
- Game Over Detection - Identify isolated tiles (no valid moves)
- Diagonal Support - Unlocked at level 11
Located in src/utils/starCalculator.ts:
- 3 stars: Minimum moves
- 2 stars: Medium range
- 1 star: Maximum range
- Supports range thresholds (e.g., "12-13" moves)
src/hooks/useSwipeGesture.ts:
- 8-directional swipe support (up, down, left, right, diagonals)
- 4-directional mode for levels 1-10
- Configurable threshold and velocity
- Uses @use-gesture/react
The app is a Progressive Web App with:
- Offline Support - Play without internet connection
- Install Prompt - Add to home screen
- App Manifest - Native-like experience
- Service Worker - Asset caching with Workbox
- Responsive Design - Works on all screen sizes
This is a complete rewrite of the original Cordova/jQuery app. See MIGRATION_PLAN.md for full details on the migration process, architecture decisions, and progress.
- ✅ Modern React architecture (vs. jQuery)
- ✅ TypeScript for type safety (vs. vanilla JS)
- ✅ Capacitor for native features (vs. Cordova)
- ✅ Zustand for state management (vs. global variables)
- ✅ Framer Motion for animations (vs. jQuery.animate)
- ✅ Vite for fast builds (vs. no build system)
- ✅ Component-based architecture
- ✅ PWA support for web
- ✅ Automatic progress migration from old app
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Mobile Safari 14+
- Chrome Mobile 90+
This is a personal project migration. For issues or suggestions, please open a GitHub issue.
See LICENSE file for details.
- Original Number Locks game concept
- Icons from Material Design Icons
- Sound effects from original game
Repository: https://github.com/ap0894/numberlocks-react Original Legacy App: https://github.com/ap0894/numberlocks Migration Documentation: MIGRATION_PLAN.md