Skip to content

Add Camera Tetris game with pose detection and keyboard controls#2

Open
mrfeixiang wants to merge 2 commits intomainfrom
claude/camera-tetris-webpage-lN2cZ
Open

Add Camera Tetris game with pose detection and keyboard controls#2
mrfeixiang wants to merge 2 commits intomainfrom
claude/camera-tetris-webpage-lN2cZ

Conversation

@mrfeixiang
Copy link
Copy Markdown
Owner

Summary

This PR introduces a new interactive Tetris game that combines camera-based gesture recognition with traditional keyboard controls. Players can control the game using hand gestures detected via MediaPipe Pose Landmarker or fall back to keyboard-only mode.

Key Changes

  • New Game File: Added camera-tetris.html - a complete, self-contained Tetris implementation
  • Gesture Recognition: Integrated MediaPipe Pose Landmarker for real-time pose detection with gesture mapping:
    • Raise left hand to move left
    • Raise right hand to move right
    • Raise both hands to rotate
    • Squat down to hard drop
  • Dual Control Modes: Players can select between camera+keyboard mode or keyboard-only mode at startup
  • Full Tetris Implementation:
    • Standard 10x20 game board with 7 tetromino pieces
    • Score and level progression system
    • Line clearing with increasing difficulty
    • Ghost piece preview and next piece display
    • Soft drop, hard drop, and rotation with wall kick mechanics
  • Visual Features:
    • Real-time pose skeleton overlay on camera feed
    • Animated tetromino blocks with lighting effects
    • Gesture feedback display
    • Game over and restart screens
    • Responsive UI with game controls legend
  • Fallback Handling: Gracefully degrades to keyboard-only mode if camera access is unavailable or pose model fails to load

Notable Implementation Details

  • Uses MediaPipe's GPU-accelerated pose detection for smooth 60fps gesture recognition
  • Implements gesture cooldown (300ms) to prevent accidental repeated inputs
  • Includes wall kick system for piece rotation near boundaries
  • Dynamic difficulty scaling: drop speed increases with level progression
  • Mirrored camera display with proper coordinate transformation for intuitive gesture mapping

https://claude.ai/code/session_013WPDpQAFbJ5CycF2VcsBkN

Single HTML file that uses laptop webcam + MediaPipe Pose to play Tetris
with body gestures: raise left/right hand to move, both hands to rotate,
squat to hard drop. Also supports full keyboard controls as fallback.

https://claude.ai/code/session_013WPDpQAFbJ5CycF2VcsBkN
Previously getUserMedia failures were silent when opened via file://.
Now displays a clear banner explaining the secure-context requirement
and specific error (denied, not found, etc).

https://claude.ai/code/session_013WPDpQAFbJ5CycF2VcsBkN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants