A modern implementation of the classic Tetris game built with Vue 3, TypeScript, and modern web technologies. Features multiple themes, 8-bit audio system, mobile-first responsive design, and comprehensive game mechanics.
- Vue 3 with Composition API for reactive state management
- TypeScript for type safety and better developer experience
- Vite for lightning-fast development and optimized builds
- Vitest for comprehensive unit testing
- ESLint + Prettier for code quality and consistency
- 8 Stunning Themes: Classic (default), Retro, Neon, Ocean, Sunset, Minimal, Matrix, Game Boy
- Mobile-First Layout: Side-by-side design with game board left, info panel right
- Optimized Screen Usage: Dynamic viewport sizing for maximum gameplay area
- Smooth Animations: CSS transitions and transforms for polished UX
- Accessibility: WCAG 2.1 AA compliant with 56px+ touch targets
- 8-bit Sound Effects: Move, rotate, drop, line clear, and game over sounds
- Background Music: 4 different retro music tracks with seamless looping
- Advanced Audio Controls: Individual volume controls and track selection
- Web Audio API: High-performance audio with proper context management
- Classic Tetris Gameplay: All 7 tetromino pieces with proper physics
- Difficulty Modes: Three difficulty levels (Easy, Normal, Hard) affecting speed, scoring, level progression, and piece generation
- Progressive Difficulty: Speed increases with level progression
- Scoring System: Points based on lines cleared and level multiplier
- Achievement System: 74 achievements across 7 categories with animated notifications
- Persistent Settings: Theme, audio, speed, and difficulty preferences saved locally
- Pause/Resume: Full game state management with audio coordination
- In-Game Reset: Instant game restart with confirmation modal
- Side-by-Side Layout: Game board left, compact info panel right for single-screen play
- Enhanced Touch Controls: 75x75px control buttons with rich haptic feedback
- Contextual Vibration: Different vibration patterns for each game action
- Dynamic Sizing: Viewport-based calculations for optimal screen space usage
- Single-Screen Fit: No scrolling required on any mobile device
- Performance: 60fps target with optimized rendering
- PWA Ready: Service worker and manifest for app-like experience
- Node.js 18+
- npm 9+ or yarn 1.22+
# Clone the repository
git clone https://github.com/darth-dodo/tetrys.git
cd tetrys
# Install dependencies
npm install
# Start development server
npm run dev
# Visit http://localhost:5173# Build optimized production bundle
npm run build
# Preview production build locally
npm run preview
# Run all tests
npm run test
# Type check
npm run type-check- 🚀 Getting Started
- 🏗️ Architecture Overview
- 🧩 Vue Components
- ⚡ Composables Deep Dive
- 🧪 Testing Guide
- 🚀 Deployment Guide
- ←/→/↓: Move piece left/right/down
- ↑: Rotate piece clockwise
- Space: Hard drop piece
- P: Pause/resume game
- R: Reset current game
- Game Board Touch: Tap to rotate, swipe left/right to move, swipe down to drop
- Control Buttons: Enhanced 75x75px buttons with haptic feedback
- Swipe Gestures: Intuitive directional controls on game board
- Vibration Feedback: Contextual haptic patterns for different actions
- Side Panel: Compact score and next piece info on the right
- Settings: Access via gear icon in header to change difficulty, theme, and audio preferences
tetrys/
├── src/
│ ├── components/ # Vue components
│ │ ├── AudioControls.vue # Audio settings panel
│ │ ├── GameBoard.vue # Main game board
│ │ ├── GameControls.vue # Game action buttons
│ │ ├── NextPiece.vue # Next piece preview
│ │ ├── ScoreBoard.vue # Score and stats
│ │ ├── SpeedControl.vue # Speed multiplier
│ │ └── ThemeSelector.vue # Theme switcher
│ ├── composables/ # Vue composition functions
│ │ ├── useAudio.ts # Audio system management
│ │ ├── useSpeed.ts # Speed control logic
│ │ ├── useTetris.ts # Core game logic
│ │ └── useTheme.ts # Theme management
│ ├── types/ # TypeScript definitions
│ │ ├── tetris.ts # Game state types
│ │ └── theme.ts # Theme configuration
│ ├── App.vue # Root component
│ ├── main.ts # Application entry point
│ └── style.css # Global styles
├── tutorials/ # Comprehensive documentation
├── public/ # Static assets
├── dist/ # Production build output
└── tests/ # Test suites
Tetrys uses an event-driven architecture with mitt as the event bus for decoupled communication between game logic and the achievement system.
The game uses a centralized event bus (useGameBus()) that enables components and composables to communicate without tight coupling. This promotes testability, maintainability, and extensibility.
Game Events:
game:started- Fired when a new game beginsgame:paused- Fired when game is pausedgame:over- Fired when game endsgame:reset- Fired when game is reset
Gameplay Events:
lines:cleared- Payload:{ count: number }- Lines cleared in single actionscore:updated- Payload:{ score: number }- Current score valuelevel:up- Payload:{ level: number }- New level reachedcombo:updated- Payload:{ combo: number }- Current combo counttime:tick- Payload:{ timeElapsed: number }- Game time in seconds
Achievement Events:
achievement:unlocked- Payload:{ achievement: Achievement }- New achievement unlocked
import { useGameBus } from '@/composables/useGameBus'
const gameBus = useGameBus()
// Subscribe to an event
gameBus.on('lines:cleared', (data) => {
console.log(`Cleared ${data.count} lines!`)
})
// Emit an event
gameBus.emit('score:updated', { score: 1000 })- Decoupling: Game logic and achievements don't directly depend on each other
- Testability: Easy to mock events in unit tests
- Extensibility: Add new listeners without modifying existing code
- Type Safety: TypeScript ensures event payload type correctness
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Type checking
npm run type-check
# Linting
npm run lint# Build and deploy to Netlify
npm run build
# Upload dist/ folder to Netlify
# Or use Netlify CLI
netlify deploy --prod --dir=dist- Vercel: Connect GitHub repository for automatic deployments
- GitHub Pages: Use GitHub Actions workflow
- Docker: Dockerfile included for containerized deployments
See Deployment Guide for detailed instructions.
// src/types/theme.ts
export const customTheme: Theme = {
id: 'custom',
name: 'Custom Theme',
colors: {
bg: '#your-bg-color',
surface: '#your-surface-color'
// ... more colors
}
}// src/composables/useAudio.ts
const musicTracks = {
custom: [
{ freq: 440, duration: 0.5 }
// ... your custom notes
]
}- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow TypeScript strict mode
- Write tests for new features
- Use conventional commit messages
- Ensure accessibility compliance
- Test on multiple devices/browsers
This project is licensed under the MIT License - see the LICENSE file for details.
- Tetris: Original game created by Alexey Pajitnov
- Vue.js: Reactive frontend framework
- TypeScript: Type safety and developer experience
- Web Audio API: High-performance audio processing
- Modern Web Standards: PWA, Accessibility, Performance
- Lighthouse Score: 95+ on all metrics
- Bundle Size: <100KB gzipped
- First Contentful Paint: <1.5s
- Time to Interactive: <2.5s
- Mobile Performance: 60fps on modern devices
- Safari audio context may require user interaction
- IE11 not supported (modern browsers only)
- Some older Android devices may experience reduced performance
- Achievement system (74 achievements with notifications) ✨
- Multiplayer support with WebRTC
- Tournament mode with leaderboards
- Custom piece skins
- Advanced statistics and analytics
- Social sharing integration
Made with ❤️ by the Tetrys team
📦 Source Code: github.com/darth-dodo/tetrys
Tetrys - Where classic gameplay meets modern technology