-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.js.map
1 lines (1 loc) · 37.5 KB
/
bundle.js.map
1
{"version":3,"sources":["webpack:///webpack/bootstrap 9c16f97245816bd01e76","webpack:///./streetdodger.js","webpack:///./lib/game.js","webpack:///./lib/hit_overlay.js","webpack:///./lib/dodge_key.js","webpack:///./lib/scrolling_object.js","webpack:///./lib/dodge_zone.js","webpack:///./lib/game_view.js","webpack:///./lib/game_over.js","webpack:///./lib/ground.js","webpack:///./lib/health_bar.js","webpack:///./lib/level_banner.js","webpack:///./lib/message.js","webpack:///./lib/miss_zone.js","webpack:///./lib/particle.js","webpack:///./lib/pedestrian.js","webpack:///./lib/player.js","webpack:///./lib/score_counter.js","webpack:///./lib/sky.js","webpack:///./lib/skyline.js","webpack:///./lib/landing_page.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,EAAC;;;;;;;ACfD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,yCAAwC,iCAAiC;AACzE,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,0BAAyB,2BAA2B;AACpD,0BAAyB,8BAA8B;AACvD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,8BAA6B,+CAA+C;AAC5E;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,uBAAsB,yBAAyB;AAC/C,uBAAsB,2BAA2B;AACjD;;AAEA;AACA,2BAA0B,2BAA2B;AACrD,2BAA0B,8BAA8B;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,QAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;;;;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACrBA;;AAEA;AACA,2BAA0B;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAmC,WAAW;AAC9C;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;;;;;;AC7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;ACpCA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;;;;;;;AC7GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL,uBAAsB,6BAA6B;AACnD;AACA;;AAEA;;;;;;;AClGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,8BAA6B,qBAAqB;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAkC,WAAW;;AAE7C;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvCA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;;;;;ACxCA;AACA;AACA;AACA,6BAA4B,sBAAsB;AAClD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,uCAAsC,kBAAkB;AACxD;;AAEA;AACA;AACA;AACA;;AAEA;;;;;;;AC9BA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;;;;;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,6BAA4B,SAAS,GAAG,aAAa;AACrD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;ACxCA;;AAEA;AACA,2BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB;;AAEnB;AACA;AACA,MAAK;AACL;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB;;AAEnB;AACA;AACA,MAAK;AACL;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;;;;;AC7EA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;ACrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvCA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAmB,qBAAqB;AACxC;AACA;;AAEA;AACA;AACA;AACA,+BAA8B,kBAAkB;AAChD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA","file":"./bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 9c16f97245816bd01e76\n **/","const Game = require(\"./lib/game\");\nconst LandingPage = require(\"./lib/landing_page\");\n\nwindow.Game = Game;\nwindow.Pedestrian = require('./lib/pedestrian');\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n const canvas = document.getElementById(\"sdCanvas\");\n canvas.width = Game.DIM_X;\n canvas.height = Game.DIM_Y;\n\n const ctx = canvas.getContext(\"2d\");\n const game = new Game();\n\n new LandingPage(game, ctx).display();\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./streetdodger.js\n ** module id = 0\n ** module chunks = 0\n **/","const DamageOverlay = require(\"./hit_overlay\");\nconst DodgeKey = require(\"./dodge_key\");\nconst DodgeZone = require(\"./dodge_zone\");\nconst GameOver = require(\"./game_over\");\nconst Ground = require(\"./ground\");\nconst HealthBar = require(\"./health_bar\");\nconst LevelBanner = require(\"./level_banner\");\nconst Message = require(\"./message\");\nconst MissZone = require(\"./miss_zone\");\nconst Particle = require(\"./particle\");\nconst Pedestrian = require(\"./pedestrian\");\nconst Player = require(\"./player\");\nconst ScoreCounter = require(\"./score_counter\");\nconst Sky = require(\"./sky\");\nconst Skyline = require(\"./skyline\");\n\nclass Game {\n constructor () {\n this.dodgeKeys = [];\n this.pedestrians = [];\n this.players = [];\n this.dodgeZone = [];\n this.dodgeKeys = [];\n this.scoreCounter = [];\n this.healthBar = [];\n this.damageOverlay = [];\n this.levelBanners = [];\n this.message = [];\n this.missZone = [];\n this.ground = [];\n this.particles = [];\n this.skyline = [];\n this.sky = [];\n this.pedestrianSpeed = 2;\n this.levelPedestrianCount = 0;\n this.levelNumber = 1;\n this.over = false;\n\n this.addPlayer();\n this.addMissZone();\n this.addScoreCounter();\n this.addGround();\n this.addSkyline();\n this.addSky();\n this.addHealthBar();\n }\n\n add (object) {\n if (object instanceof Pedestrian) {\n this.pedestrians.push(object);\n this.dodgeKeys.push(new DodgeKey({ game: this, pedestrian: object }));\n } else if (object instanceof Player) {\n this.players.push(object);\n } else if (object instanceof DodgeZone) {\n this.dodgeZone.push(object);\n } else if (object instanceof ScoreCounter) {\n this.scoreCounter.push(object);\n } else if (object instanceof HealthBar) {\n this.healthBar.push(object);\n } else if (object instanceof MissZone) {\n this.missZone.push(object);\n } else if (object instanceof Ground) {\n this.ground.push(object);\n } else if (object instanceof Skyline) {\n this.skyline.push(object);\n } else if (object instanceof Sky) {\n this.sky.push(object);\n } else if (object instanceof DamageOverlay) {\n this.damageOverlay.push(object);\n } else if (object instanceof Message) {\n this.message.push(object);\n } else if (object instanceof LevelBanner) {\n this.levelBanners.push(object);\n } else if (object instanceof Particle) {\n this.particles.push(object);\n }\n }\n\n addDodgeZone () {\n const dodgeZone = new DodgeZone(this);\n this.add(dodgeZone);\n return dodgeZone;\n }\n\n addGround () {\n this.add(new Ground({ game: this, pos: [0, 387]}));\n this.add(new Ground({ game: this, pos: [1536, 387]}));\n }\n\n addHealthBar () {\n this.add(new HealthBar(this));\n }\n\n addDamageOverlay () {\n this.add(new DamageOverlay(this));\n setTimeout(this.removeDamageOverlay.bind(this), 70);\n }\n\n addLevelBanner () {\n this.add(new LevelBanner(this));\n }\n\n addMessage (message) {\n clearTimeout(this.messageTimeout);\n this.add(new Message(message, this));\n this.messageTimeout = setTimeout(this.removeMessage.bind(this), 500);\n }\n\n addMissZone () {\n this.add(new MissZone(this));\n }\n\n addParticles () {\n clearTimeout(this.particlesTimeout);\n let particles = 0;\n\n while (particles < 50) {\n this.add(new Particle(this));\n particles ++;\n }\n\n this.particlesTimeout = setTimeout(this.removeParticles.bind(this), 1000);\n }\n\n addPedestrian (game) {\n this.add(new Pedestrian({ game: this, speed: this.pedestrianSpeed * -1 }));\n }\n\n addPlayer () {\n const player = new Player(this);\n this.add(player);\n return player;\n }\n\n addScoreCounter () {\n this.add(new ScoreCounter(this));\n }\n\n addSky () {\n this.add(new Sky({ game: this, pos: [0, 0]}));\n this.add(new Sky({ game: this, pos: [832, 0]}));\n }\n\n addSkyline () {\n this.add(new Skyline({ game: this, pos: [0, 300]}));\n this.add(new Skyline({ game: this, pos: [1664, 300]}));\n }\n\n allObjects () {\n return [].concat(\n this.sky,\n this.skyline,\n this.ground,\n this.levelBanners,\n this.dodgeKeys,\n this.pedestrians,\n this.players,\n this.particles,\n this.dodgeZone,\n this.dodgeKeys,\n this.scoreCounter,\n this.healthBar,\n this.missZone,\n this.message,\n this.damageOverlay\n );\n }\n\n checkCollisions () {\n this.dodgeZone[0].isCollidedWithDodgeKey(this.dodgeKeys);\n this.missZone[0].isCollidedWithDodgeKey(this.dodgeKeys);\n }\n\n destroyDodgeKey (dodgeKeyToDestroy) {\n this.dodgeKeys.forEach((dodgeKey, index, dodgeKeys) => {\n if (dodgeKey === dodgeKeyToDestroy) {\n dodgeKeys.splice(index, 1);\n }\n });\n }\n\n draw (ctx) {\n ctx.clearRect(0, 0, Game.DIM_X, Game.DIM_Y);\n\n if (this.over) {\n let newGame = new Game();\n new GameOver(newGame, this.scoreCounter[0].scoreCount).display();\n } else {\n this.allObjects().forEach((object) => {\n object.draw(ctx);\n });\n }\n }\n\n endGame () {\n this.over = true;\n }\n\n moveObjects (delta) {\n this.allObjects().forEach((object) => {\n object.move(delta);\n });\n }\n\n removeDamageOverlay () {\n this.damageOverlay = [];\n }\n\n removeMessage () {\n this.message.shift();\n }\n\n removeLevelBanner () {\n this.levelBanners.shift();\n }\n\n removeParticles () {\n this.particles = [];\n }\n\n spawnPedestrians () {\n let levelTransition = false;\n\n if (this.levelPedestrianCount > 20) {\n this.pedestrianSpeed++;\n this.levelPedestrianCount = 0;\n this.levelNumber++;\n levelTransition = true;\n this.addLevelBanner();\n }\n\n let delay;\n if (levelTransition) {\n delay = 10000 - (this.pedestrianSpeed * 300);\n } else {\n delay = (\n Game.INTERVALS[Math.floor(Math.random() * 4)]\n ) / this.pedestrianSpeed;\n }\n\n setTimeout(this.addPedestrian.bind(this), delay);\n clearTimeout();\n this.levelPedestrianCount++;\n if (!this.over) {\n setTimeout(this.spawnPedestrians.bind(this), delay);\n }\n }\n\n sendDamage (damage) {\n this.healthBar[0].registerDamage(damage);\n this.addDamageOverlay();\n }\n\n step (delta) {\n if (!this.over) {\n this.moveObjects(delta);\n this.checkCollisions();\n }\n }\n\n updateScore (points, message) {\n this.addMessage(message);\n this.addParticles();\n this.scoreCounter[0].addPoints(points);\n }\n}\n\nGame.DIM_X = 800;\nGame.DIM_Y = 500;\nGame.BG_COLOR = \"#ccc\";\nGame.INTERVALS = [1500, 2500, 3500, 4500];\n\nmodule.exports = Game;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/game.js\n ** module id = 1\n ** module chunks = 0\n **/","class DamageOverlay {\n constructor (game) {\n this.game = game;\n this.pos = [0, 0];\n this.width = 800;\n this.height = 500;\n this.image = new Image();\n this.image.src = \"lib/images/hit_overlay.png\";\n }\n\n move () {}\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.fillStyle = \"rgba(255,0,0,0.5)\";\n ctx.fill();\n ctx.closePath();\n }\n}\n\nmodule.exports = DamageOverlay;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/hit_overlay.js\n ** module id = 2\n ** module chunks = 0\n **/","const ScrollingObject = require('./scrolling_object');\n\nclass DodgeKey {\n constructor(options = {}) {\n let pedestrian = options.pedestrian;\n\n this.color = \"white\";\n this.pos = [pedestrian.pos[0] - 20, 220];\n this.speed = pedestrian.speed / 2;\n this.width = 50;\n this.height = 50;\n this.value = ['up', 'down', 'left', 'right'][Math.floor(Math.random() * 4)];\n this.image = new Image();\n this.image.src = `lib/images/${this.value}.png`;\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n\n ctx.fillStyle = this.color;\n ctx.fill();\n\n ctx.drawImage(\n this.image,\n 0,\n 0,\n this.width,\n this.height,\n this.pos[0],\n this.pos[1],\n this.width,\n this.height\n );\n\n ctx.strokeStyle = \"black\";\n ctx.stroke();\n ctx.closePath();\n }\n\n move() {\n this.pos = [this.pos[0] + this.speed, this.pos[1]];\n }\n}\n\nmodule.exports = DodgeKey;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/dodge_key.js\n ** module id = 3\n ** module chunks = 0\n **/","class ScrollingObject {\n constructor (options) {\n this.pos = options.pos;\n this.speed = options.speed;\n this.width = options.width;\n this.height = options.height;\n this.color = options.color;\n this.game = options.game;\n }\n\n draw (ctx) {\n let text = this.value ? this.value.toUpperCase() : \"\";\n\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n\n ctx.fillStyle = this.color;\n ctx.fill();\n\n ctx.font = \"25px arcade\";\n ctx.textAlign = 'right';\n ctx.fillStyle = \"black\";\n ctx.fillText(text, this.pos[0] + 39, this.pos[1] + 37);\n\n ctx.strokeStyle = \"black\";\n ctx.stroke();\n ctx.closePath();\n }\n\n move() {\n this.pos = [this.pos[0] + this.speed, this.pos[1]];\n }\n}\n\nconst NORMAL_FRAME_TIME_DELTA = 1000/60;\n\nmodule.exports = ScrollingObject;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/scrolling_object.js\n ** module id = 4\n ** module chunks = 0\n **/","const GameView = require('./game_view.js');\n\nclass DodgeZone {\n constructor (game) {\n this.game = game;\n this.pos = [150, 220];\n this.activated = false;\n this.collidedDodgeKey = null;\n }\n\n activate (key) {\n this.activated = true;\n this.checkHit(key);\n }\n\n checkHit (key) {\n if (this.isCollidedWithDodgeKey(this.game.dodgeKeys)) {\n if (this.collidedDodgeKey.value === key) {\n this.scoreHit();\n this.game.destroyDodgeKey(this.collidedDodgeKey);\n return true;\n } else {\n this.game.sendDamage(10);\n this.game.destroyDodgeKey(this.collidedDodgeKey);\n return false;\n }\n } else {\n this.game.sendDamage(5);\n return false;\n }\n }\n\n deactivate () {\n this.activated = false;\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], 50, 50);\n ctx.strokeStyle = this.strokeColor();\n ctx.stroke();\n ctx.closePath();\n }\n\n isCollidedWithDodgeKey (dodgeKeys) {\n let collision = false;\n let collidedDodgeKey;\n\n dodgeKeys.forEach((dodgeKey) => {\n if (\n this.pos[0] + 50 > dodgeKey.pos[0] &&\n this.pos[0] < (dodgeKey.pos[0] + 50)\n ) {\n collision = true;\n this.collidedDodgeKey = dodgeKey;\n }\n });\n\n if (collision) {\n return true;\n } else {\n this.collidedDodgeKey = null;\n return false;\n }\n }\n\n move () {\n }\n\n scoreHit () {\n let dodgeZoneMin = this.pos[0];\n let dodgeZoneMax = this.pos[0] + 50;\n let dodgeKeyMin = this.collidedDodgeKey.pos[0];\n let dodgeKeyMax = this.collidedDodgeKey.pos[0] + 50;\n let overlap;\n\n if (dodgeKeyMin >= dodgeZoneMin) {\n overlap = dodgeZoneMax - dodgeKeyMin;\n } else {\n overlap = dodgeKeyMax - dodgeZoneMin;\n }\n\n let points = overlap * 10;\n let message;\n\n if (points < 100) {\n message = \"LAME!\";\n } else if (points < 200) {\n message = \"OK!\";\n } else if (points < 300) {\n message = \"GOOD!\";\n } else if (points < 400) {\n message = \"GREAT!\";\n } else if (points <= 500) {\n message = \"EXCELLENT!\";\n }\n\n this.game.updateScore(points, message);\n }\n\n strokeColor () {\n if (this.activated) {\n return \"yellow\";\n } else {\n return \"blue\";\n }\n }\n}\n\nmodule.exports = DodgeZone;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/dodge_zone.js\n ** module id = 5\n ** module chunks = 0\n **/","class GameView {\n constructor(game, ctx) {\n this.ctx = ctx;\n this.game = game;\n this.dodgeZone = this.game.addDodgeZone();\n this.keyPresses = {\n q: false,\n w: false,\n e: false,\n r: false\n };\n }\n\n animate (time) {\n const timeDelta = time - this.lastTime;\n this.game.step(timeDelta);\n this.game.draw(this.ctx);\n this.lastTime = time;\n\n if (!this.game.over) {\n requestAnimationFrame(this.animate.bind(this));\n }\n }\n\n bindKeyHandlers () {\n document.addEventListener(\"keydown\", this.keyDownHandler.bind(this), false);\n document.addEventListener(\"keyup\", this.keyUpHandler.bind(this), false);\n }\n\n keyDownHandler (e) {\n switch (e.keyCode) {\n case 38:\n e.preventDefault();\n this.keyPresses[\"up\"] = true;\n this.game.players[0].dodge();\n break;\n case 40:\n e.preventDefault();\n this.keyPresses[\"down\"] = true;\n this.game.players[0].dodge();\n break;\n case 37:\n e.preventDefault();\n this.keyPresses[\"left\"] = true;\n this.game.players[0].dodge();\n break;\n case 39:\n e.preventDefault();\n this.keyPresses[\"right\"] = true;\n this.game.players[0].dodge();\n break;\n }\n this.updateDodgeZone();\n }\n\n keyUpHandler (e) {\n switch (e.keyCode) {\n case 38:\n e.preventDefault();\n this.keyPresses[\"up\"] = false;\n break;\n case 40:\n e.preventDefault();\n this.keyPresses[\"down\"] = false;\n break;\n case 37:\n e.preventDefault();\n this.keyPresses[\"left\"] = false;\n break;\n case 39:\n e.preventDefault();\n this.keyPresses[\"right\"] = false;\n break;\n }\n this.updateDodgeZone();\n\n }\n start () {\n this.bindKeyHandlers();\n this.lastTime = 0;\n this.game.spawnPedestrians();\n requestAnimationFrame(this.animate.bind(this));\n }\n\n updateDodgeZone () {\n let keyPressed = false;\n\n Object.keys(this.keyPresses).forEach( (key) => {\n if (this.keyPresses[key]) {\n this.dodgeZone.activate(key);\n keyPressed = true;\n }\n });\n\n if (!keyPressed) { this.dodgeZone.deactivate(); }\n }\n}\n\nmodule.exports = GameView;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/game_view.js\n ** module id = 6\n ** module chunks = 0\n **/","const GameView = require(\"./game_view\");\nconst Game = require(\"./game\");\n\nclass GameOver {\n constructor (newGame, score) {\n const canvas = document.getElementById(\"sdCanvas\");\n this.ctx = canvas.getContext(\"2d\");\n this.width = 800;\n this.height = 500;\n this.image = new Image();\n this.image.src = \"lib/images/game_over.png\";\n this.game = newGame;\n this.score = score;\n this.active = true;\n }\n\n bindKeyHandlers () {\n this.enterListener = document.addEventListener(\n \"keydown\", this.keyDownHandler.bind(this), false\n );\n }\n\n display () {\n this.bindKeyHandlers();\n setInterval(function () {this.draw(this.ctx);}.bind(this), 1);\n }\n\n draw (ctx) {\n if (this.active) {\n ctx.beginPath();\n ctx.rect(0, 0, this.width, this.height);\n ctx.fillStyle = \"white\";\n ctx.fill();\n\n ctx.font = \"50px arcade\";\n ctx.textAlign = 'center';\n ctx.fillStyle = \"RED\";\n ctx.fillText(\"GAME OVER\", 400, 200);\n\n ctx.font = \"25px arcade\";\n ctx.textAlign = 'center';\n ctx.fillStyle = \"black\";\n ctx.fillText(`YOUR SCORE: ${this.score}`, 400, 300);\n\n ctx.font = \"25px arcade\";\n ctx.textAlign = 'center';\n ctx.fillStyle = \"black\";\n ctx.fillText(\"PRESS ENTER TO PLAY AGAIN\", 400, 400);\n\n ctx.closePath();\n }\n }\n\n keyDownHandler (e) {\n switch (e.keyCode) {\n case 13:\n this.startGame();\n document.removeEventListener(\"keydown\", this.enterListener);\n break;\n }\n }\n\n startGame () {\n this.gameView = new GameView(this.game, this.ctx);\n this.gameView.start();\n this.active = false;\n }\n}\n\nmodule.exports = GameOver;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/game_over.js\n ** module id = 7\n ** module chunks = 0\n **/","class Ground {\n constructor (options) {\n this.game = options.game;\n this.pos = options.pos;\n this.width = 1536;\n this.height = 112;\n this.image = new Image();\n this.image.src = \"lib/images/ground-alt.png\";\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.drawImage(\n this.image,\n 0,\n 0,\n this.width,\n this.height,\n this.pos[0],\n this.pos[1],\n this.width,\n this.height\n );\n ctx.closePath();\n }\n\n move () {\n this.pos = [this.pos[0] - 1.0, this.pos[1]];\n this.wrap();\n }\n\n wrap () {\n if (this.pos[0] < -1536) {\n this.pos[0] += 3072;\n }\n }\n}\n\nmodule.exports = Ground;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/ground.js\n ** module id = 8\n ** module chunks = 0\n **/","class HealthBar {\n constructor (game) {\n this.game = game;\n this.health = 100;\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(20, 380, 30, -300);\n ctx.strokeStyle = \"black\";\n ctx.stroke();\n\n ctx.font = \"18px arcade\";\n ctx.textAlign = 'left';\n ctx.fillStyle = \"black\";\n ctx.fillText(\"PATIENCE\", 20, 70);\n\n ctx.closePath();\n\n ctx.beginPath();\n ctx.rect(20, 380, 30, (this.health * 3) * -1);\n ctx.fillStyle = \"rgba(255,45,28,0.8)\";\n ctx.fill();\n ctx.closePath();\n }\n\n registerDamage (damage) {\n this.health -= damage;\n\n if (this.health <= 0) {\n this.health = 0;\n this.game.endGame();\n }\n }\n\n move () {\n\n }\n}\n\nmodule.exports = HealthBar;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/health_bar.js\n ** module id = 9\n ** module chunks = 0\n **/","class LevelBanner {\n constructor (game) {\n this.game = game;\n this.message = `LEVEL ${this.game.levelNumber}`;\n this.pos = [2000, 100];\n this.width = 200;\n this.height = 70;\n }\n\n move () {\n this.pos[0] -= (this.game.pedestrianSpeed);\n }\n\n removeSelfIfOffscreen () {\n if (this.pos[0] < -800) {\n this.game.removeLevelBanner();\n }\n }\n\n draw (ctx) {\n this.removeSelfIfOffscreen();\n\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.fillStyle = \"#444\";\n ctx.fill();\n\n ctx.font = \"25px arcade\";\n ctx.textAlign = 'center';\n ctx.fillStyle = \"white\";\n ctx.fillText(this.message, this.pos[0] + 100, this.pos[1] + 40);\n\n ctx.strokeStyle = \"black\";\n ctx.stroke();\n ctx.closePath();\n }\n}\n\nmodule.exports = LevelBanner;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/level_banner.js\n ** module id = 10\n ** module chunks = 0\n **/","class Message {\n constructor (message, game) {\n this.game = game;\n this.message = message;\n this.pos = [0, 180];\n this.width = 100;\n this.height = 50;\n this.transparency = 1;\n }\n\n move () {\n this.pos[1] -= 1;\n }\n\n draw (ctx) {\n this.transparency = this.transparency - 0.04;\n\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n\n ctx.font = \"18px arcade\";\n ctx.fontStyle=\"bold\";\n ctx.fillStyle = `rgba(252,45,28,${this.transparency})`;\n ctx.fillText(this.message, this.pos[0] + 150, this.pos[1] + 20);\n\n ctx.strokeStyle = \"black\";\n ctx.closePath();\n }\n}\n\nmodule.exports = Message;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/message.js\n ** module id = 11\n ** module chunks = 0\n **/","const GameView = require('./game_view.js');\n\nclass MissZone {\n constructor (game) {\n this.game = game;\n this.pos = [35, 220];\n this.collidedDodgeKey = null;\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], 50, 50);\n // ctx.strokeStyle = \"red\";\n // ctx.stroke();\n ctx.closePath();\n }\n\n isCollidedWithDodgeKey (dodgeKeys) {\n let collision = false;\n let collidedDodgeKey;\n\n dodgeKeys.forEach((dodgeKey) => {\n if (\n this.pos[0] + 50 > dodgeKey.pos[0] &&\n this.pos[0] < (dodgeKey.pos[0] + 50)\n ) {\n collision = true;\n this.collidedDodgeKey = dodgeKey;\n }\n });\n\n if (collision) {\n this.game.destroyDodgeKey(this.collidedDodgeKey);\n this.game.sendDamage(10);\n return true;\n } else {\n this.collidedDodgeKey = null;\n return false;\n }\n }\n\n move () {\n }\n\n}\n\nmodule.exports = MissZone;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/miss_zone.js\n ** module id = 12\n ** module chunks = 0\n **/","class Particle {\n constructor (game) {\n this.game = game;\n this.opacity = 1;\n this.pos = [170, 240];\n this.size = Particle.SIZES[\n Math.floor(Math.random() * Particle.SIZES.length)\n ];\n this.rgb = Particle.RGBS[\n Math.floor(Math.random() * Particle.RGBS.length)\n ];\n this.vector = [\n Math.random() * 2 - 1,\n Math.random() * 2 - 1\n ];\n }\n\n draw (ctx) {\n this.opacity -= 0.05;\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.size[0], this.size[1]);\n ctx.fillStyle = `rgba(${this.rgb},${this.opacity})`;\n ctx.fill();\n ctx.closePath();\n }\n\n move () {\n this.pos[0] += 6 * this.vector[0];\n this.pos[1] += 6 * this.vector[1];\n }\n}\n\nParticle.RGBS = [\n `150,186,180`,\n `126,130,249`,\n `13,141,255`\n];\n\nParticle.SIZES = [[1, 1], [7, 7], [5, 5], [3, 3]];\n\nmodule.exports = Particle;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/particle.js\n ** module id = 13\n ** module chunks = 0\n **/","const ScrollingObject = require('./scrolling_object');\n\nclass Pedestrian extends ScrollingObject {\n constructor(options = {}) {\n options.color = \"red\";\n options.pos = options.pos || [820, 384];\n options.speed = options.speed;\n options.width = 60;\n options.height = 60;\n super(options);\n\n this.image = new Image();\n this.image.src = Pedestrian.randomImage();\n this.currentFrame = 0;\n this.frames = 7;\n this.frameOccurrences = 0;\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.drawImage(\n this.image, // source image object\n (this.width * this.currentFrame) + 4, // source x\n 0, // source y\n 60, // source width\n 60, // source height\n this.pos[0], // destination x\n this.pos[1], // destination y\n this.width, // destination width\n this.height); // destination height\n\n if (this.currentFrame === this.frames) {\n this.currentFrame = 0;\n } else {\n if (this.frameOccurrences < 3) {\n this.frameOccurrences++;\n } else {\n this.frameOccurrences = 0;\n this.currentFrame++;\n }\n }\n ctx.closePath();\n }\n}\n\nPedestrian.randomImage = () => {\n return [\n \"lib/images/pedestrian1_walking.png\",\n \"lib/images/pedestrian2_walking.png\",\n \"lib/images/pedestrian3_walking.png\",\n \"lib/images/pedestrian4_walking.png\",\n \"lib/images/pedestrian5_walking.png\",\n ][Math.floor(Math.random() * 5)];\n};\n\nmodule.exports = Pedestrian;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/pedestrian.js\n ** module id = 14\n ** module chunks = 0\n **/","class Player {\n constructor (game) {\n this.pos = [100, 384];\n this.game = game;\n this.width = 60;\n this.height = 60;\n this.image = new Image();\n this.image.src = \"lib/images/player_walking_alt.png\";\n this.currentFrame = 0;\n this.frames = 7;\n this.frameOccurences = 0;\n this.dodging = false;\n }\n\n checkDodging () {\n if (this.dodging === true) {\n if (this.width < 68) {\n this.width += 2;\n this.height += 2;\n this.pos[0] -= 2;\n this.pos[1] += 2;\n }\n } else {\n if (this.width > 60) {\n this.width -= 2;\n this.height -= 2;\n this.pos[0] += 2;\n this.pos[1] -= 2;\n }\n }\n }\n\n dodge () {\n window.clearTimeout(this.timeout);\n this.dodging = true;\n // debugger\n this.timeout = window.setTimeout(this.resetDodging.bind(this), 1000);\n }\n\n resetDodging () {\n this.dodging = false;\n }\n\n draw (ctx) {\n this.checkDodging();\n\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.drawImage(\n this.image, // source image object\n (60 * this.currentFrame) + 2, // source x\n 0, // source y\n 60, // source width\n 60, // source height\n this.pos[0], // destination x\n this.pos[1], // destination y\n this.width, // destination width\n this.height); // destination height\n\n if (this.currentFrame === this.frames) {\n this.currentFrame = 0;\n } else {\n if (this.frameOccurrences < 3) {\n this.frameOccurrences++;\n } else {\n this.frameOccurrences = 0;\n this.currentFrame++;\n }\n }\n ctx.closePath();\n }\n\n move () {\n\n }\n}\n\nmodule.exports = Player;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/player.js\n ** module id = 15\n ** module chunks = 0\n **/","class ScoreCounter {\n constructor (game) {\n this.scoreCount = 0;\n this.game = game;\n }\n\n addPoints (points) {\n this.scoreCount += points;\n }\n\n draw (ctx) {\n ctx.font = '20pt arcade';\n ctx.textAlign = 'right';\n ctx.fillStyle = \"#fc2d1c\";\n ctx.fillText(this.scoreCount, 790, 40);\n }\n\n move () {\n }\n}\n\nmodule.exports = ScoreCounter;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/score_counter.js\n ** module id = 16\n ** module chunks = 0\n **/","class Sky {\n constructor (options) {\n this.game = options.game;\n this.pos = options.pos;\n this.width = 832;\n this.height = 360;\n this.image = new Image();\n this.image.src = \"lib/images/sky.png\";\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.drawImage(\n this.image,\n 0,\n 0,\n this.width,\n this.height,\n this.pos[0],\n this.pos[1],\n this.width,\n this.height\n );\n ctx.closePath();\n }\n\n move () {\n this.pos = [this.pos[0] - 0.2, this.pos[1]];\n this.wrap();\n }\n\n wrap () {\n if (this.pos[0] < -832) {\n this.pos[0] += 1664;\n }\n }\n}\n\nmodule.exports = Sky;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/sky.js\n ** module id = 17\n ** module chunks = 0\n **/","class Skyline {\n constructor (options) {\n this.game = options.game;\n this.pos = options.pos;\n this.width = 1664;\n this.height = 128;\n this.image = new Image();\n this.image.src = \"lib/images/skyline.png\";\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(this.pos[0], this.pos[1], this.width, this.height);\n ctx.drawImage(\n this.image,\n 0,\n 0,\n this.width,\n this.height,\n this.pos[0],\n this.pos[1],\n this.width,\n this.height\n );\n ctx.closePath();\n }\n\n move () {\n this.pos = [this.pos[0] - 0.5, this.pos[1]];\n this.wrap();\n }\n\n wrap () {\n if (this.pos[0] < -1664) {\n this.pos[0] += 3328;\n }\n }\n}\n\nmodule.exports = Skyline;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/skyline.js\n ** module id = 18\n ** module chunks = 0\n **/","const GameView = require(\"./game_view\");\n\nclass LandingPage {\n constructor (game, ctx) {\n this.ctx = ctx;\n this.game = game;\n this.width = 800;\n this.height = 500;\n this.image = new Image();\n this.image.src = \"lib/images/landing_page.png\";\n this.gameStarted = false;\n }\n\n bindKeyHandlers () {\n document.addEventListener(\"keydown\", this.keyDownHandler.bind(this), false);\n }\n\n draw (ctx) {\n ctx.beginPath();\n ctx.rect(0, 0, this.width, this.height);\n ctx.drawImage(\n this.image,\n 0,\n 0,\n this.width,\n this.height,\n 0,\n 0,\n this.width,\n this.height\n );\n ctx.closePath();\n }\n\n display () {\n this.bindKeyHandlers();\n this.landingPageDisplay = setInterval(\n function () {this.draw(this.ctx);}.bind(this), 10\n );\n }\n\n keyDownHandler (e) {\n switch (e.keyCode) {\n case 13:\n if (!this.isRunning) { this.startGame(); }\n break;\n }\n }\n\n startGame () {\n if (!this.gameView) {\n this.gameView = new GameView(this.game, this.ctx);\n this.gameView.start();\n }\n window.clearInterval(this.landingPageDisplay);\n }\n}\n\nmodule.exports = LandingPage;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/landing_page.js\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""}