Spaces:
Sleeping
Sleeping
| title: Retro Tetris | |
| emoji: ๐ฎ | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: docker | |
| app_file: index.html | |
| pinned: false | |
| # ๐ฎ Retro Tetris | |
| A stunning retro-styled Tetris game with authentic CRT TV aesthetics, dynamic backdrops, and procedurally generated music. Built with Phaser 3 and modern web technologies. | |
|  | |
| ## โจ Features | |
| ### ๐ฅ๏ธ Authentic CRT TV Experience | |
| - **Realistic CRT Shader Effects** | |
| - Barrel distortion/curvature for authentic tube TV look | |
| - 480i-style scanlines | |
| - Subtle static noise with 4x4 pixel grains | |
| - Dynamic flicker effect with multiple frequencies | |
| - Phosphor glow on bright areas | |
| - Edge vignetting | |
| - **Vintage TV Frame** - Game displayed inside a beautiful retro TV bezel | |
| - **Pixel-Perfect Rendering** - Crisp 8x8 pixel blocks with nearest-neighbor filtering | |
| ### ๐จ Dynamic Visual System | |
| - **10 Unique Level Backdrops** - Each level features a distinct hand-crafted backdrop | |
| - **Adaptive Color Palette** - Block colors automatically extract and enhance from each level's backdrop for perfect visual harmony | |
| - **Sprite-Based Blocks** - Detailed block rendering with depth and shading | |
| - **Smooth Animations** - Crush animations, level transitions, and particle effects | |
| ### ๐ต Dynamic Music System | |
| - **10 Unique Tracks** - Each level has its own AI-generated music track created with Suno AI | |
| - **Thematic Soundscapes** - Music complements each level's visual theme | |
| - **Retro Sound Effects** - Authentic 8-bit style procedurally generated sound effects | |
| ### ๐ฏ Two Game Modes | |
| 1. **Classic Mode** - Traditional Tetris with 7 standard pieces (I, O, T, S, Z, J, L) | |
| 2. **Advanced Mode** - Extended gameplay with additional unique pieces for extra challenge | |
| ### ๐ Advanced Gameplay Features | |
| - **Progressive Difficulty** - 10 levels with increasing speed | |
| - **Combo System** - Chain multiple line clears for bonus points | |
| - **Perfect Clear Bonus** - Extra points for clearing the entire board | |
| - **T-Spin Detection** - Bonus points for advanced T-piece maneuvers | |
| - **Hard Drop** - Instant piece placement with space bar | |
| - **Ghost Piece** - Preview where your piece will land | |
| - **Next Piece Preview** - Plan your strategy ahead | |
| - **Pause Functionality** - Press P to pause/resume | |
| ### ๐ Scoring System | |
| - Single line: 100 points ร level | |
| - Double lines: 300 points ร level | |
| - Triple lines: 500 points ร level | |
| - Tetris (4 lines): 800 points ร level | |
| - T-Spin: 400 points ร level | |
| - Combo multiplier: +50 points per combo ร level | |
| - Perfect Clear: 2000 points ร level | |
| ### ๐ฎ Controls | |
| - **Arrow Keys** - Move and rotate pieces | |
| - โ โ : Move left/right | |
| - โ : Soft drop (faster descent) | |
| - โ : Rotate piece | |
| - **Space Bar** - Hard drop (instant placement) | |
| - **P** - Pause/Resume game | |
| - **Mouse/Touch** - Navigate menus | |
| ## ๐ Getting Started | |
| ### Prerequisites | |
| - Node.js (v14 or higher) | |
| - npm or yarn | |
| ### Installation | |
| 1. Clone the repository: | |
| ```bash | |
| git clone <repository-url> | |
| cd tetris | |
| ``` | |
| 2. Install dependencies: | |
| ```bash | |
| npm install | |
| ``` | |
| 3. Start the development server: | |
| ```bash | |
| npm run dev | |
| ``` | |
| 4. Open your browser and navigate to `http://localhost:5173` | |
| ### Building for Production | |
| ```bash | |
| npm run build | |
| ``` | |
| The built files will be in the `dist` directory. | |
| ## ๐ ๏ธ Technical Details | |
| ### Technologies Used | |
| - **Phaser 3** - Game framework | |
| - **Vite** - Build tool and dev server | |
| - **WebGL** - Hardware-accelerated rendering and custom shaders | |
| - **Canvas API** - Backdrop generation and color extraction | |
| ### Architecture | |
| - **Scene-Based Structure** - Modular game scenes (Preload, Mode Select, Game) | |
| - **Custom Shaders** - GLSL fragment shaders for CRT effects | |
| - **Color Extraction System** - Automatic palette generation from backdrop images | |
| - **Sprite Rendering Pipeline** - Dynamic block colorization and rendering | |
| - **Procedural Sound Effects** - Real-time sound effect generation | |
| ### Performance | |
| - 60 FPS target frame rate | |
| - Optimized WebGL rendering | |
| - Efficient sprite batching | |
| - Minimal memory footprint | |
| ## ๐จ Customization | |
| ### Adding New Levels | |
| 1. Create a new backdrop image (256x224 pixels) | |
| 2. Place it in `public/assets/backdrops/level-X/backdrop.png` | |
| 3. Add corresponding music track in `public/assets/music/level-X/track.mp3` | |
| 4. Update `MAX_LEVEL` in `src/constants.js` | |
| See `BACKDROP-GUIDE.md` for detailed instructions on creating backdrops. | |
| ### Adjusting CRT Effects | |
| Edit `src/shaderOverlay.js` to customize: | |
| - Curvature intensity | |
| - Scanline density | |
| - Static grain size and intensity | |
| - Flicker frequency and amplitude | |
| - Vignette strength | |
| ## ๐ Project Structure | |
| ``` | |
| tetris/ | |
| โโโ public/ | |
| โ โโโ assets/ | |
| โ โโโ backdrops/ # Level backdrop images | |
| โ โโโ fonts/ # Bitmap fonts | |
| โ โโโ music/ # Level music tracks | |
| โ โโโ blocks-sprite.png | |
| โ โโโ game-over.png | |
| โ โโโ title.png | |
| โ โโโ tv.png | |
| โโโ src/ | |
| โ โโโ scenes/ | |
| โ โ โโโ PreloadScene.js | |
| โ โ โโโ ModeSelectScene.js | |
| โ โ โโโ GameScene.js | |
| โ โโโ utils/ | |
| โ โ โโโ ColorExtractor.js | |
| โ โ โโโ SpriteBlockRenderer.js | |
| โ โ โโโ SoundGenerator.js | |
| โ โโโ constants.js | |
| โ โโโ main.js | |
| โ โโโ shaderOverlay.js | |
| โโโ index.html | |
| โโโ package.json | |
| ``` | |
| ## ๐ฏ Game Mechanics | |
| ### Piece Movement | |
| - Pieces fall automatically based on level speed | |
| - Wall kicks allow rotation near edges | |
| - Floor kicks prevent unfair lockouts | |
| - Smooth movement with keyboard repeat | |
| ### Level Progression | |
| - Levels 1-10 with exponentially increasing speed | |
| - New backdrop and music for each level | |
| - Visual transition effects between levels | |
| - Speed ranges from 1000ms (Level 1) to 100ms (Level 10) | |
| ### Line Clearing | |
| - Standard Tetris line clear mechanics | |
| - Animated crush effect for cleared lines | |
| - Combo system rewards consecutive clears | |
| - Perfect clear detection and bonus | |
| ## ๐ Troubleshooting | |
| See `TROUBLESHOOTING.md` for common issues and solutions. | |
| ## ๐ License | |
| This project is licensed under the [Creative Commons Attribution 4.0 International License (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/). | |
| You are free to: | |
| - **Share** โ copy and redistribute the material in any medium or format | |
| - **Adapt** โ remix, transform, and build upon the material for any purpose, even commercially | |
| Under the following terms: | |
| - **Attribution** โ You must give appropriate credit, provide a link to the license, and indicate if changes were made. | |
| ## ๐จโ๐ป Credits | |
| **Created by Marco van Hylckama Vlieg** | |
| - Website: [ai-created.com](https://ai-created.com) | |
| - Twitter/X: [@AIandDesign](https://x.com/AIandDesign) | |
| ### Tools & Technologies | |
| - **Code**: Written with [Augment Code](https://www.augmentcode.com/) (Claude 4.5 Sonnet / Opus) | |
| - **Music**: AI-generated with [Suno AI](https://suno.ai/) | |
| - **Graphics**: Created on [Freepik](https://www.freepik.com/) and post-processed in Adobe Photoshop | |
| - **Game Framework**: [Phaser 3](https://phaser.io/) | |
| ## ๐ Acknowledgments | |
| - Phaser 3 framework and community | |
| - Suno AI for music generation capabilities | |
| - Freepik for graphic design tools | |
| - Augment Code for AI-assisted development | |
| - Retro gaming aesthetics and CRT shader techniques | |
| - Classic Tetris gameplay mechanics |