mwg API
    Preparing search index...

    Function splitScreenHalves

    • The two even halves of width×height a two-player split screen typically wants - side by side for a landscape screen, stacked for a portrait one - as plain rectangles a game hands straight to two Viewports (or to resize on a resize event). Not the only reasonable split, so not baked into Viewport itself: a game wanting an L-shaped, uneven, or three/four-player layout lays out its own rectangles the same way.

      Parameters

      • width: number
      • height: number

      Returns [
          { height: number; width: number; x: number; y: number },
          { height: number; width: number; x: number; y: number },
      ]

      import { splitScreenHalves } from '@datamoc/mw_games/two-d/render';

      const [top, bottom] = splitScreenHalves(400, 600); // taller than wide: stacks vertically
      console.log(top); // { x: 0, y: 0, width: 400, height: 300 }
      console.log(bottom); // { x: 0, y: 300, width: 400, height: 300 }