A classic Tetris implementation using vanilla JavaScript and HTML5 Canvas.
Screenshot of the game showing active gameplay with next piece preview and score tracking
This project is a modern implementation of the classic Tetris game that runs in the browser. It features:
- Smooth gameplay using HTML5 Canvas
- Classic Tetris scoring system
- Level progression with increasing difficulty
- Next piece preview
- Modern, clean UI design
- HTML5 Canvas for game rendering
- Vanilla JavaScript for game logic
- CSS3 for styling
- No external dependencies required
tetris/
├── index.html # Main HTML file
├── styles.css # CSS styles
└── tetris.js # Game logic
- Open
index.htmlin a modern web browser - The game starts automatically
- Use the following controls:
- ← → (Left/Right Arrow): Move piece horizontally
- ↑ (Up Arrow): Rotate piece
- ↓ (Down Arrow): Soft drop
- Space: Hard drop
- 1 line: 40 × level
- 2 lines: 100 × level
- 3 lines: 300 × level
- 4 lines: 1200 × level
- Level increases for every 1000 points
- Each level increases the falling speed of pieces
- Maximum fall speed is capped at level 10
The game is built using modern JavaScript features and follows these key principles:
- Game Loop: Uses
requestAnimationFramefor smooth animation - Collision Detection: Implements piece-board collision checking for movement and rotation
- Piece Generation: Random piece generation with next piece preview
- Board Management: Efficient line clearing and board state management
- Clone or download this repository
- No build process or dependencies required
- Open
index.htmlin your web browser - Start playing!
Works in all modern browsers that support HTML5 Canvas:
- Chrome
- Firefox
- Safari
- Edge
Potential enhancements that could be added:
- High score persistence
- Sound effects
- Mobile touch controls
- Multiplayer support
- Hold piece feature
- Ghost piece preview
