A modern implementation of the classic Tetris game built with JavaScript and Vite.
- Classic Tetris gameplay with modern web technologies
- Responsive design that works on desktop and mobile devices
- Multiple background music tracks and sound effects
- Touch controls for mobile play
- Progressive Web App (PWA) support for offline play
- Level progression system with unique backgrounds per level
- Fullscreen support
- Node.js (v16 or higher recommended)
- npm or yarn
- Clone the repository:
git clone https://github.com/klevze/tetris.git
cd tetris
- Install dependencies:
npm install
# or
yarn
Start the development server:
npm run dev
# or
yarn dev
The game will be available at http://localhost:5173
(or another port if 5173 is in use).
Build the project for production:
npm run build
# or
yarn build
This will generate optimized assets in the dist
directory.
npm run preview
# or
yarn preview
- Arrow Left/Right: Move piece horizontally
- Arrow Down: Soft drop
- Arrow Up: Rotate piece
- Spacebar: Hard drop
- P: Pause game
- Swipe Left/Right: Move piece horizontally
- Swipe Down: Soft drop
- Tap: Rotate piece
- Swipe Up: Hard drop
- Button (on-screen): Pause game
The game is structured using an ES6 module architecture:
main.js
: Entry point that bootstraps the applicationgame.js
: Core game controller managing state and game flow- Other specialized modules handling specific functionality (blocks, grid, effects, etc.)
- Vite: Fast build tool and dev server
- Sass: For structured styling
- Firebase: For potential online features or score tracking
- PWA Support: For installable web app experience
This game can be installed as a Progressive Web App on compatible devices:
- Open the game in a web browser
- Look for "Add to Home Screen" or installation prompt
- Enjoy the game in fullscreen mode with offline support
Contributions are welcome! Feel free to submit pull requests or open issues to improve the game.
This project is licensed under the terms found in the LICENSE file.
Built with ❤️ and JavaScript