"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _phaser = require("phaser");
var _Boot = _interopRequireDefault(require("./scenes/Boot"));
var _Preloader = _interopRequireDefault(require("./scenes/Preloader"));
var _StartPosition = _interopRequireDefault(require("./plugins/StartPosition"));
var _SimplePlatformerControls = _interopRequireDefault(require("./plugins/SimplePlatformerControls"));
var _MazePlugin = _interopRequireDefault(require("./plugins/MazePlugin"));
var _MazeLevel = _interopRequireDefault(require("./scenes/MazeLevel"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
window.fadeColor = {
  r: 5,
  g: 4,
  b: 4
};

// this controls how much the pixels are scaled, try changing it and have fun
window.maxSize = 960;
// window.maxSize = 640;
// window.maxSize = 320;

const StartGame = parent => {
  const parentElem = document.getElementById(parent);
  const grandParent = parentElem === null || parentElem === void 0 ? void 0 : parentElem.parentElement;
  const grandParentWidth = grandParent === null || grandParent === void 0 ? void 0 : grandParent.clientWidth;
  const grandParentHeight = grandParent === null || grandParent === void 0 ? void 0 : grandParent.clientHeight;
  if (!grandParentWidth || !grandParentHeight) {
    return;
  }
  const longestSide = Math.max(grandParentWidth, grandParentHeight);
  const zoom = 2 * Math.max(1, Math.floor(longestSide / window.maxSize));
  const config = {
    type: Phaser.AUTO,
    parent: 'phaser-game',
    width: grandParentWidth / zoom,
    height: grandParentHeight / zoom,
    pixelArt: true,
    transparent: true,
    zoom: zoom,
    physics: {
      default: 'arcade',
      arcade: {
        gravity: {
          x: 0,
          y: 0
        },
        debug: false
      }
    },
    plugins: {
      scene: [{
        key: 'simplePlatformerControls',
        plugin: _SimplePlatformerControls.default,
        mapping: 'controls'
      }, {
        key: 'startPosition',
        plugin: _StartPosition.default,
        mapping: 'startPosition',
        start: true
      }, {
        key: 'MazePlugin',
        plugin: _MazePlugin.default,
        mapping: 'maze',
        start: true
      }],
      global: []
    },
    input: {
      gamepad: true
    },
    scene: [_Boot.default, _Preloader.default, _MazeLevel.default]
  };
  return new _phaser.Game(_objectSpread(_objectSpread({}, config), {}, {
    parent
  }));
};
var _default = exports.default = StartGame;