CoolFace
Apppublic

broadfield-dev/stack-overflow-game

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

๐ŸŽฎ 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.

[image]

โœจ 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. 1.Classic Mode - Traditional Tetris with 7 standard pieces (I, O, T, S, Z, J, L)
  2. 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. 1.Clone the repository:
bash
git clone <repository-url>
cd tetris
  1. 1.Install dependencies:
bash
npm install
  1. 1.Start the development server:
bash
npm run dev
  1. 1.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. 1.Create a new backdrop image (256x224 pixels)
  2. 2.Place it in public/assets/backdrops/level-X/backdrop.png
  3. 3.Add corresponding music track in public/assets/music/level-X/track.mp3
  4. 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).

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

Tools & Technologies

  • โ€”Code: Written with Augment Code (Claude 4.5 Sonnet / Opus)
  • โ€”Music: AI-generated with Suno AI
  • โ€”Graphics: Created on Freepik and post-processed in Adobe Photoshop
  • โ€”Game Framework: Phaser 3

๐Ÿ™ 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