Overview

All 2-player games now support automatic fullscreen mode that activates when the game starts, providing an immersive full-screen experience perfect for face-to-face gameplay.

Features

Automatic Activation

Manual Control

Visual Design

Implementation

Files Created/Modified

New Files:

Modified Files:

CSS Classes

.btn-fullscreen

.game-container.fullscreen-mode

JavaScript API

// Initialize fullscreen for a game
GameFullscreen.init('.game-container', { 
  autoEnterOnStart: true 
});

// Trigger fullscreen on game start
GameFullscreen.onGameStart();

// Manual control
GameFullscreen.enter();
GameFullscreen.exit();
GameFullscreen.toggle();

// Button visibility
GameFullscreen.showButton();
GameFullscreen.hideButton();

// Check state
GameFullscreen.isFullscreen();

Usage Pattern

Standard Implementation

<!-- Include fullscreen script -->
<script src="/assets/js/games/fullscreen.js"></script>

<script>
(function() {
  var gameStarted = false;
  
  // Initialize fullscreen
  GameFullscreen.init('.game-container', { 
    autoEnterOnStart: true 
  });
  
  function startGame() {
    // Trigger fullscreen when game starts
    GameFullscreen.onGameStart();
    // ... rest of game logic
  }
  
  // Or trigger on first interaction
  function handleFirstMove() {
    if (!gameStarted) {
      gameStarted = true;
      GameFullscreen.onGameStart();
    }
    // ... handle move
  }
})();
</script>

Browser Compatibility

Fullscreen API Support

Fallback Behavior

User Experience

Desktop

  1. User clicks “Start Game”
  2. Game automatically enters fullscreen (300ms delay)
  3. Fullscreen button appears in top-right
  4. User can exit with ESC or button click

Mobile

  1. User taps “Start Game”
  2. Game enters fullscreen mode
  3. Fullscreen button visible for manual control
  4. Optimized for portrait and landscape

Face-to-Face Play

Accessibility

Performance

Customization Options

Disable Auto-Enter

GameFullscreen.init('.game-container', { 
  autoEnterOnStart: false 
});

Custom Delay

function startGame() {
  setTimeout(function() {
    GameFullscreen.enter();
  }, 500); // Custom delay
}

Hide Button

GameFullscreen.init('.game-container');
GameFullscreen.hideButton(); // Hide toggle button

Testing Checklist

Known Limitations

  1. iOS Safari: Requires user gesture for fullscreen
  2. Some Android browsers: May show notification bar
  3. Older browsers: Falls back to CSS fullscreen only
  4. Picture-in-Picture: May conflict with fullscreen

Future Enhancements

Games with Fullscreen

Implemented

To Be Implemented

Support

For issues or questions about fullscreen functionality:

  1. Check browser console for errors
  2. Verify Fullscreen API support
  3. Test with different browsers
  4. Check mobile device compatibility