Spaces:
Sleeping
Sleeping
File size: 7,357 Bytes
1c41409 7f532af 1c41409 e5f2822 7f532af | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | ---
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 |