A modern, responsive Tetris game built with React and Vite. Features classic Tetris gameplay with both desktop and mobile controls, scoring system, and a 3-minute time challenge.
- Classic Tetris Gameplay: All 7 traditional Tetris pieces (I, J, L, O, S, T, Z)
- Responsive Design: Works seamlessly on desktop and mobile devices
- Multiple Control Methods:
- Keyboard controls (arrow keys)
- Touch/swipe gestures for mobile
- On-screen control buttons
- Game Features:
- Real-time scoring system
- 3-minute time challenge
- Next piece preview
- Line clearing mechanics
- Game over detection
- Mobile Optimized: Touch-friendly interface with swipe controls
- Node.js (version 14 or higher)
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd blocks- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser and navigate to
http://localhost:5173
- Left Arrow: Move piece left
- Right Arrow: Move piece right
- Down Arrow: Move piece down faster
- Up Arrow: Rotate piece
- Swipe Left/Right: Move piece horizontally
- Swipe Down: Move piece down faster
- Swipe Up: Rotate piece
- Control Buttons: Use the on-screen buttons for precise control
- Complete horizontal lines to clear them and earn points
- Game ends when pieces reach the top of the board
- You have 3 minutes to achieve the highest score possible
- Each cleared line awards 100 points
- React 19 - Frontend framework
- Vite - Build tool and development server
- CSS3 - Styling and animations
- Capacitor - Mobile app deployment (Android support included)
This project includes Android app support through Capacitor:
# Build for Android
npm run build
npx cap add android
npx cap sync android
npx cap open androidsrc/
├── components/
│ └── TetrisGame.jsx # Main game component
├── styles/
│ └── TetrisGame.css # Game styling
├── App.jsx # Root component
└── main.jsx # Entry point
The game can be easily customized by modifying:
- Colors: Update the
COLORSobject inTetrisGame.jsx - Game Duration: Change
GAME_DURATIONconstant - Piece Shapes: Modify the
TETROMINOESobject - Styling: Edit
TetrisGame.cssfor visual changes
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- 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
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
- Classic Tetris game mechanics
- React community for excellent documentation
- Vite team for the amazing build tool
Enjoy playing Blocks! 🎮✨
