"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunkgame_server"] = self["webpackChunkgame_server"] || []).push([["src_levels_jump_mjs"],{

/***/ "./src/collisions.mjs":
/*!****************************!*\
  !*** ./src/collisions.mjs ***!
  \****************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"rectanglesOverlap\": () => (/* binding */ rectanglesOverlap)\n/* harmony export */ });\nconst rectanglesOverlap = (rect, rect2) => {\n  return (\n    rect.x + rect.width >= rect2.x &&\n    rect.x < rect2.x + rect2.width &&\n    rect.y + rect.height >= rect2.y &&\n    rect.y < rect2.y + rect2.height\n  )\n}\n\n\n//# sourceURL=webpack://game-server/./src/collisions.mjs?");

/***/ }),

/***/ "./src/levels/jump.mjs":
/*!*****************************!*\
  !*** ./src/levels/jump.mjs ***!
  \*****************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _controller_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../controller.mjs */ \"./src/controller.mjs\");\n/* harmony import */ var _textures_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../textures.mjs */ \"./src/textures.mjs\");\n/* harmony import */ var _entities_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../entities.mjs */ \"./src/entities.mjs\");\n/* harmony import */ var _player_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../player.mjs */ \"./src/player.mjs\");\n/* harmony import */ var _texture_data_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../texture-data.mjs */ \"./src/texture-data.mjs\");\n/* harmony import */ var _collision_map_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../collision-map.mjs */ \"./src/collision-map.mjs\");\n/* harmony import */ var _spikes_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../spikes.mjs */ \"./src/spikes.mjs\");\n/* harmony import */ var _collisions_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../collisions.mjs */ \"./src/collisions.mjs\");\n\n\n\n\n// import {\n//   loadAudio,\n//   getAudioByName,\n// } from './audio.mjs'\n\n\n\n\n\nconst $ = (id) => document.getElementById(id)\n\n// const startButton = $('start-btn')\n\nconst canvas = $('game')\nconst ctx = canvas.getContext('2d')\nctx.fillStyle = 'rgb(33, 35, 47)'\n\nctx.mozImageSmoothingEnabled = false;\nctx.webkitImageSmoothingEnabled = false;\nctx.msImageSmoothingEnabled = false;\nctx.imageSmoothingEnabled = false;\n\nconst texturesData = [\n  ..._texture_data_mjs__WEBPACK_IMPORTED_MODULE_4__.playerTextures,\n  // {\n  //   src: 'ground.png',\n  //   name: 'ground',\n  // },\n  {\n    src: 'ground2.png',\n    name: 'ground2',\n  },\n  {\n    src: 'ground3.png',\n    name: 'ground3',\n  },\n  {\n    src: 'lava.png',\n    name: 'lava',\n  },\n  {\n    src: 'background.png',\n    name: 'background',\n  },\n  // {\n  //   src: 'shadow.png',\n  //   name: 'shadow',\n  // },\n  // {\n  //   src: 'chains.png',\n  //   name: 'chains',\n  // },\n  {\n    src: 'spikes.png',\n    name: 'spikes',\n  },\n  {\n    src: 'collision-map-jump.png',\n    name: 'collision-map',\n  },\n  // {\n  //   src: 'avatar.png',\n  //   name: 'avatar',\n  // },\n  // {\n  //   src: 'afk.png',\n  //   name: 'afk',\n  // },\n  // {\n  //   src: 'boss.png',\n  //   name: 'boss',\n  // },\n  // {\n  //   src: 'pumpkin.png',\n  //   name: 'pumpkin',\n  // },\n  // {\n  //   src: 'red-gem.png',\n  //   name: 'red-gem',\n  // },\n  // {\n  //   src: 'purple-gem.png',\n  //   name: 'green-gem',\n  // },\n  // {\n  //   src: 'green-gem.png',\n  //   name: 'purple-gem',\n  // },\n  // {\n  //   src: 'man.png',\n  //   name: 'man',\n  // },\n  // {\n  //   src: 'man2.png',\n  //   name: 'man2',\n  // },\n  // {\n  //   src: 'mage3.png',\n  //   name: 'mage',\n  // },\n  // {\n  //   src: 'mage2.png',\n  //   name: 'mage2',\n  // },\n  // {\n  //   src: 'slime.png',\n  //   name: 'slime',\n  // },\n  // {\n  //   src: 'squid.png',\n  //   name: 'squid',\n  // },\n  // {\n  //   src: 'boss2.png',\n  //   name: 'boss2',\n  // },\n  // {\n  //   src: 'blast.png',\n  //   name: 'blast',\n  // },\n  // {\n  //   src: 'blast-left.png',\n  //   name: 'blast-left',\n  // },\n  // {\n  //   src: 'leaf.png',\n  //   name: 'leaf',\n  // },\n]\n\n// const soundsData = [\n//   {\n//     src: 'music.wav',\n//     name: 'music',\n//   },\n// ]\n\n// let running = false\n\n// const AVATAR_WIDTH = 40\n// const AVATAR_HEIGHT = 40\n\n// const FRAMES_AVATAR = 15\n\nlet lastTime = (new Date()).getTime()\nlet currentTime = 0\nlet dt = 0\n\n// const AFK_TIME = 10\n// let afkAccumulator = 0\n\nconst player = (0,_player_mjs__WEBPACK_IMPORTED_MODULE_3__.createPlayer)(64, canvas.height - 245)\n;(0,_entities_mjs__WEBPACK_IMPORTED_MODULE_2__.addEntity)(player)\n\nconst spikes = (0,_spikes_mjs__WEBPACK_IMPORTED_MODULE_6__.createSpikes)(128, canvas.height - 168)\nconst spikes2 = (0,_spikes_mjs__WEBPACK_IMPORTED_MODULE_6__.createSpikes)(256, canvas.height - 168)\n;(0,_entities_mjs__WEBPACK_IMPORTED_MODULE_2__.addEntity)(spikes)\n;(0,_entities_mjs__WEBPACK_IMPORTED_MODULE_2__.addEntity)(spikes2)\n\n// const player = {\n//   x: PLAYER_WIDTH * 2,\n//   y: START_Y,\n//   facing: RIGHT,\n//   xSpeed: 0,\n//   ySpeed: 0,\n//   frame: 0,\n//   accumulator: 0,\n//   fps: 8,\n//   frameAvatar: 0,\n//   accumulatorAvatar: 0,\n//   fpsAvatar: 8,\n//   grounded: false,\n//   sprite: 'running',\n//   spriteAvatar: 'avatar',\n// }\n\n// const blasts = []\n//\n// const createBlast = (x, y) => {\n//   const blast = {\n//     x,\n//     y,\n//     xSpeed: player.facing * 300,\n//     facing: player.facing,\n//   }\n//   blasts.push(blast)\n//   return blast\n// }\n\ndocument.addEventListener('keydown', (e) => {\n  ;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.handleKeyDown)(e)\n}, false)\n\ndocument.addEventListener('keyup', e => {\n  ;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.handleKeyUp)(e)\n}, false)\n\n;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.registerActions)([\n  {\n    name: 'jump',\n    keycode: '32',\n  },\n  // {\n  //   name: 'left',\n  //   keycode: '65',\n  // },\n  // {\n  //   name: 'right',\n  //   keycode: '68',\n  // },\n  // {\n  //   name: 'down',\n  //   keycode: '83',\n  // },\n  {\n    name: 'left',\n    keycode: '74',\n  },\n  {\n    name: 'right',\n    keycode: '76',\n  },\n  {\n    name: 'down',\n    keycode: '75',\n  },\n  {\n    name: 'restart',\n    keycode: '82',\n  },\n  // {\n  //   name: 'shoot',\n  //   keycode: '75',\n  // },\n])\n\n;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.addActionDownListener)('jump', () => {\n  player.jump()\n})\n\n;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.addActionDownListener)(('restart'), () => {\n  player.respawn()\n})\n\n// addActionDownListener('shoot', () => {\n  // afkAccumulator = 0\n  // createBlast(player.x + PLAYER_WIDTH, player.y + PLAYER_HEIGHT)\n// })\n\nconst init = async () => {\n  await (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.loadTextures)(texturesData)\n  ;(0,_collision_map_mjs__WEBPACK_IMPORTED_MODULE_5__.setCollisionMap)((0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.getTextureByName)('collision-map'))\n\n  // Just know that any lag will make the player fall through the floor.\n  lastTime = (new Date()).getTime()\n  currentTime = 0\n  dt = 0\n\n  // sounds = await loadAudio(soundsData)\n\n  // const music = getAudioByName('music')\n\n  // music.addEventListener('ended', function () {\n  //   this.currentTime = 0\n  //   this.play()\n  // }, false)\n  // music.play()\n\n  window.requestAnimationFrame(update)\n}\n\nconst update = () => {\n  window.requestAnimationFrame(update)\n\n  currentTime = (new Date()).getTime()\n  dt = (currentTime - lastTime) / 1000\n\n  // afkAccumulator += dt\n\n  // player.accumulatorAvatar += dt\n  // while (player.accumulatorAvatar >= (1 / player.fpsAvatar)) {\n  //   player.accumulatorAvatar -= (1 / player.fpsAvatar)\n  //   player.frameAvatar++\n  // }\n  // if (player.spriteAvatar === 'avatar') {\n  //   player.frameAvatar = player.frameAvatar % FRAMES_AVATAR\n  // } else {\n  //   if (player.frameAvatar > 7) {\n  //     player.frameAvatar = 7\n  //   }\n  // }\n\n  // blasts.forEach(blast => {\n  //   blast.x += blast.xSpeed * dt\n  // })\n  //\n  // if (afkAccumulator > AFK_TIME && player.spriteAvatar === 'avatar') {\n  //   player.frameAvatar = 0\n  //   player.spriteAvatar = 'afk'\n  // }\n  ;(0,_entities_mjs__WEBPACK_IMPORTED_MODULE_2__.updateEntities)(dt)\n\n  if (player.x + 32 < 0) {\n    window.location.href = '/'\n  } else if (player.x + 32 > canvas.width) {\n    window.location.href = '/pillars'\n  }\n\n  if ((0,_collisions_mjs__WEBPACK_IMPORTED_MODULE_7__.rectanglesOverlap)(player.getCollider(), spikes.getCollider())) {\n    player.respawn()\n  }\n\n  if ((0,_collisions_mjs__WEBPACK_IMPORTED_MODULE_7__.rectanglesOverlap)(player.getCollider(), spikes2.getCollider())) {\n    player.respawn()\n  }\n\n  render()\n\n  lastTime = currentTime\n}\n\nwindow.onpageshow = () => {\n  player.x = player.startX\n  player.y = player.startY\n  player.setSprite('idle')\n  player.xSpeed = 0\n  player.ySpeed = 0\n  currentTime = (new Date()).getTime()\n  dt = (currentTime - lastTime) / 1000\n  lastTime = currentTime\n  ;(0,_controller_mjs__WEBPACK_IMPORTED_MODULE_0__.clearKeys)()\n}\n\nconst render = () => {\n  // const ground = getTextureByName('ground')\n  const ground2 = (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.getTextureByName)('ground2')\n  const ground3 = (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.getTextureByName)('ground3')\n  const lava = (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.getTextureByName)('lava')\n  const background = (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_1__.getTextureByName)('background')\n  // const shadow = getTextureByName('shadow')\n  // const chains = getTextureByName('chains')\n  // const avatar = getTextureByName(player.spriteAvatar)\n  // const boss = getTextureByName('boss')\n  // const pumpkin = getTextureByName('pumpkin')\n  // const redGem = getTextureByName('red-gem')\n  // const greenGem = getTextureByName('green-gem')\n  // const man = getTextureByName('man')\n  // const man2 = getTextureByName('man2')\n  // const mage = getTextureByName('mage')\n  // const mage2 = getTextureByName('mage2')\n  // const squid = getTextureByName('squid')\n  // const slime = getTextureByName('slime')\n  // const boss2 = getTextureByName('boss2')\n  // const shot = getTextureByName('blast')\n  // const shotLeft = getTextureByName('blast-left')\n  // const leaf = getTextureByName('leaf')\n\n  ctx.clearRect(0, 0, canvas.width, canvas.height)\n  ctx.fillRect(0, 0, canvas.width, canvas.height)\n\n  ctx.drawImage(\n    background,\n    0,\n    0,\n    canvas.width,\n    canvas.height * 0.75,\n  )\n\n  // ctx.drawImage(\n  //   avatar,\n  //   player.frameAvatar * AVATAR_WIDTH,\n  //   0,\n  //   AVATAR_WIDTH,\n  //   AVATAR_HEIGHT,\n  //   8,\n  //   8,\n  //   AVATAR_WIDTH * 2,\n  //   AVATAR_HEIGHT * 2,\n  // )\n\n  // ctx.drawImage(\n  //   redGem,\n  //   (canvas.width * 0.5) - redGem.width * 2,\n  //   canvas.height - ground.height * 2 - redGem.height,\n  //   redGem.width * 2,\n  //   redGem.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   slime,\n  //   (canvas.width * 0.5) - slime.width * 2,\n  //   canvas.height - ground.height * 2 - slime.height,\n  //   slime.width * 2,\n  //   slime.height * 2,\n  // )\n  //\n  // ctx.drawImage(\n  //   squid,\n  //   (canvas.width * 0.5) - squid.width * 4,\n  //   canvas.height - ground.height * 2 - squid.height,\n  //   squid.width * 2,\n  //   squid.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   boss2,\n  //   canvas.width * 0.5 - boss2.width,\n  //   canvas.height - ground.height * 2 - boss2.height * 2 + 50,\n  //   boss2.width * 2,\n  //   boss2.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   man,\n  //   canvas.width - man.width * 3,\n  //   canvas.height - ground.height * 2 - man.height * 1.6,\n  //   man.width * 2,\n  //   man.height * 2,\n  // )\n  //\n  // ctx.drawImage(\n  //   man2,\n  //   canvas.width - man2.width * 6,\n  //   canvas.height - ground.height * 2 - man2.height * 1.6,\n  //   man2.width * 2,\n  //   man2.height * 2,\n  // )\n\n  // blasts.forEach(blast => {\n  //   ctx.drawImage(\n  //     blast.facing === LEFT ? shotLeft : shot,\n  //     blast.x - shot.width * 0.5,\n  //     blast.y - shot.height * 0.5,\n  //     shot.width,\n  //     shot.height,\n  //   )\n  // })\n\n  // ctx.drawImage(\n  //   pumpkin,\n  //   canvas.width - pumpkin.width * 2,\n  //   canvas.height - ground.height * 2 - pumpkin.height * 0.75,\n  //   pumpkin.width * 2,\n  //   pumpkin.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   leaf,\n  //   canvas.width - leaf.width * 6,\n  //   canvas.height - ground.height * 2 - leaf.height * 1.6,\n  //   leaf.width,\n  //   leaf.height,\n  // )\n\n  ctx.drawImage(\n    lava,\n    ground2.width + 128,\n    canvas.height - lava.height * 2,\n    lava.width * 2,\n    lava.height * 2,\n  )\n\n  // ctx.drawImage(\n  //   shadow,\n  //   canvas.width - shadow.width * 3,\n  //   canvas.height - ground3.height * 2 - shadow.height * 2 + 15,\n  //   shadow.width * 2,\n  //   shadow.height * 2,\n  // )\n\n  ;(0,_entities_mjs__WEBPACK_IMPORTED_MODULE_2__.renderEntities)(ctx, canvas)\n  // debugRenderEntities(ctx, canvas)\n\n  // ctx.drawImage(\n  //   chains,\n  //   canvas.width * 0.5 - chains.width,\n  //   0,\n  //   chains.width * 2,\n  //   chains.height * 2,\n  // )\n\n  ctx.drawImage(\n    ground2,\n    0,\n    canvas.height - ground2.height * 2,\n    ground2.width * 2,\n    ground2.height * 2,\n  )\n\n  ctx.drawImage(\n    ground3,\n    ground2.width + 256,\n    canvas.height - ground3.height * 2,\n    ground3.width * 2,\n    ground3.height * 2,\n  )\n\n  // ctx.drawImage(\n  //   greenGem,\n  //   (canvas.width * 0.5) + greenGem.width,\n  //   canvas.height - ground.height * 2 - greenGem.height,\n  //   greenGem.width * 2,\n  //   greenGem.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   mage,\n  //   (canvas.width * 0.5) + mage.width * 2,\n  //   canvas.height - ground.height * 2 - mage.height,\n  //   mage.width * 2,\n  //   mage.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   mage2,\n  //   (canvas.width * 0.5),\n  //   canvas.height - ground.height * 2 - mage2.height,\n  //   mage2.width * 2,\n  //   mage2.height * 2,\n  // )\n\n  // ctx.drawImage(\n  //   boss,\n  //   canvas.width - boss.width * 2,\n  //   canvas.height - ground.height * 2 - boss.height * 2,\n  //   boss.width * 2,\n  //   boss.height * 2,\n  // )\n}\n\n// startButton.onclick = async () => {\n//   if (!running) {\n//     running = true\n//     await init()\n//   }\n// }\ninit().then(() => {\n\n}).catch(() => {\n\n})\n\n\n//# sourceURL=webpack://game-server/./src/levels/jump.mjs?");

/***/ }),

/***/ "./src/spikes.mjs":
/*!************************!*\
  !*** ./src/spikes.mjs ***!
  \************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"createSpikes\": () => (/* binding */ createSpikes)\n/* harmony export */ });\n/* harmony import */ var _textures_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./textures.mjs */ \"./src/textures.mjs\");\n\n\nconst SPIKES_WIDTH = 32\nconst SPIKES_HEIGHT = 11\n\nconst createSpikes = (x, y) => {\n  const spikes = {\n    x,\n    y,\n    sprite: 'spikes',\n    collider: {\n      x: 8,\n      y: 0,\n      width: SPIKES_WIDTH * 2 - 16,\n      height: SPIKES_HEIGHT * 2,\n    }\n  }\n\n  spikes.getCollider = () => ({\n    x: spikes.x + spikes.collider.x,\n    y: spikes.y + spikes.collider.y,\n    width: spikes.collider.width,\n    height: spikes.collider.height,\n  })\n\n  spikes.update = (dt) => {}\n\n  spikes.render = (ctx, canvas) => {\n    const sprite = (0,_textures_mjs__WEBPACK_IMPORTED_MODULE_0__.getTextureByName)(spikes.sprite)\n    ctx.drawImage(\n      sprite,\n      spikes.x,\n      spikes.y,\n      SPIKES_WIDTH * 2,\n      SPIKES_HEIGHT * 2,\n    )\n  }\n\n  spikes.debugRender = (ctx, canvas) => {\n    ctx.beginPath()\n    const spikesCollider = spikes.getCollider()\n    ctx.rect(spikesCollider.x, spikesCollider.y, spikesCollider.width, spikesCollider.height)\n    ctx.stroke()\n  }\n\n  return spikes\n}\n\n\n//# sourceURL=webpack://game-server/./src/spikes.mjs?");

/***/ })

}]);