A classic Tetris game implementation built with vanilla HTML, CSS, and JavaScript. Experience the timeless puzzle game with modern web technologies, featuring smooth animations, visual effects, and responsive design.
| Dark Theme Gameplay | Light Theme Gameplay | Initial Rules Screen |
|---|---|---|
![]() |
![]() |
![]() |
- Features
- Quick Start
- How to Play
- Game Controls
- Game Features
- Technical Details
- File Structure
- Browser Compatibility
- Development
- Contributing
- License
- ๐ฏ Classic Tetris Gameplay: All 7 traditional Tetris pieces (I, O, T, S, Z, J, L)
- ๐ Progressive Difficulty: 20 levels with increasing speed
- ๐ Visual Effects: Line clear animations (Single, Double, Triple, Tetris!)
- ๐ป Ghost Piece: Preview where your piece will land
- โธ๏ธ Pause/Resume: Press ESC to pause anytime
- ๐จ Theme Toggle: Switch between light and dark themes
- ๐ฑ Mobile Responsive: Optimized for desktop and mobile devices
- ๐ต Classic Scoring: Traditional Tetris scoring system
- โฑ๏ธ Time Tracking: Monitor your play time
- ๐ Restart Functionality: Easy game restart after game over
Simply open index.html or https://abhinavramanan.github.io/Tetris/ in your web browser to start playing immediately!
- Download or clone this repository
- Open
index.htmlin your web browser - Click "Start Game" and enjoy!
visit: https://abhinavramanan.github.io/Tetris/
- Start: Click the "Start Game" button or press "Start Game" in the rules modal
- Objective: Fill complete horizontal lines to clear them and score points
- Strategy: Arrange falling Tetris pieces to create solid lines without gaps
- Progression: Clear lines to advance levels and increase game speed
- End Game: Game ends when pieces reach the top of the playing field
- Single Line: Base points ร level multiplier
- Double Lines: Higher bonus points
- Triple Lines: Even higher bonus points
- Tetris (4 lines): Maximum bonus points with special animation
- Piece Placement: Small bonus for each piece placed
| Key | Action |
|---|---|
| โฌ ๏ธ Left Arrow | Move piece left |
| โก๏ธ Right Arrow | Move piece right |
| โฌ๏ธ Down Arrow | Move piece down (soft drop) |
| โฌ๏ธ Up Arrow | Rotate piece clockwise |
| ESC | Pause/Resume game |
- Theme Button: Toggle between light and dark themes (top-right corner)
- Start/Restart Button: Begin new game or restart after game over
- Resume Button: Continue game after pause
- Line Clear Animations: Different effects for Single, Double, Triple, and Tetris clears
- Screen Flash: Brief flash effect when clearing lines
- Ghost Piece: Semi-transparent preview showing landing position
- Smooth Animations: Fluid piece movement and transitions
- Level Progression: 20 levels with increasing difficulty
- Speed Increase: Game speed increases with each level
- Next Piece Preview: See what piece is coming next
- Classic Piece Colors:
- T-piece (Cyan) - Type 0
- I-piece (Red) - Type 1
- L-piece (Orange) - Type 2
- J-piece (Purple) - Type 3
- S-piece (Green) - Type 4
- Z-piece (Yellow) - Type 5
- O-piece (Blue) - Type 6
- Responsive Design: Works on desktop, tablet, and mobile
- Theme Support: Light and dark mode toggle
- Pause Functionality: Pause overlay with resume option
- Level Up Modals: Celebration when advancing levels
- Game Over Handling: Clear indication and restart option
- HTML5: Semantic markup and game structure
- CSS3: Styling, animations, and responsive design
- Vanilla JavaScript: Game logic and DOM manipulation
- DOM Manipulation: Dynamic element creation and modification
- Event Listeners: Keyboard and mouse input handling
- CSS Animations: Smooth visual effects and transitions
- Local Storage: (Future enhancement for high scores)
- Modular Design: Game logic separated into logical functions
- Object-Oriented: Main game object with organized methods
- Event-Driven: Responsive to user input and game events
- Cross-Browser: Compatible with modern browsers
Tetris/
โโโ index.html # Main HTML structure and game layout
โโโ script.js # Complete game logic and functionality
โโโ styles.css # Styling, animations, and responsive design
โโโ README.md # This documentation file
index.html
- Game canvas and playing field
- Info panel with score, level, lines, time
- Next piece preview area
- Pause, level-up, and rules modals
- Control buttons and UI elements
script.js
- Core Tetris game engine
- Piece movement and rotation logic
- Line clearing and scoring system
- Level progression and speed control
- Visual effects and animations
- Input handling and game state management
styles.css
- Classic Tetris visual styling
- Responsive design for all devices
- CSS animations and transitions
- Theme system (light/dark modes)
- Mobile-optimized layouts
- โ Chrome 60+ (Recommended)
- โ Firefox 55+
- โ Safari 11+
- โ Edge 79+
- โ Opera 47+
- โ iOS Safari 11+
- โ Chrome Mobile 60+
- โ Firefox Mobile 55+
- โ Samsung Internet 7+
- JavaScript: Must be enabled
- CSS3: For animations and modern styling
- HTML5: For semantic structure
- No plugins: Runs entirely in the browser
# Clone and navigate
git clone https://github.com/abhinavramanan/Tetris.git
cd Tetris
# Start development server
python3 -m http.server 8000
# or
npx http-server
# Open http://localhost:8000 in your browser- ES5/ES6 Compatible: Works in older and modern browsers
- Vanilla JavaScript: No external dependencies
- Modular Functions: Easy to understand and modify
- Comments: Well-documented for easy maintenance
- Colors: Modify piece colors in CSS (
.type0-.type6) - Speed: Adjust
speedvalues inscript.js - Board Size: Change
canvasHeightandcanvasWidth - Scoring: Modify scoring multipliers in
initLevelScores()
Contributions are welcome! Here are some ways you can help improve the game:
- ๐ต Sound Effects: Add audio for line clears, piece drops, and game events
- ๐ High Scores: Local storage for best scores
- ๐ฎ Touch Controls: Swipe gestures for mobile devices
- ๐จ More Themes: Additional color schemes and visual styles
- ๐ Statistics: Detailed gameplay statistics tracking
- ๐ Multiplayer: Real-time multiplayer functionality
- ๐ฏ Game Modes: Sprint, Marathon, and Challenge modes
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Maintain compatibility with supported browsers
- Follow existing code style and patterns
- Add comments for new functionality
- Test on multiple devices and browsers
- Update documentation for new features
This project is open source and available under the MIT License.
Enjoy playing this classic Tetris game! Whether you're a casual player or a Tetris master, this implementation offers the authentic experience you love with modern web enhancements.
Happy Gaming! ๐ฎ
Built with โค๏ธ using vanilla web technologies


