diff --git a/index.html b/index.html index 7af116c..9064a47 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + diff --git a/lib/bundle.js b/lib/bundle.js index 76311c7..befb98a 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -78,7 +78,7 @@ document.addEventListener("DOMContentLoaded", function(){ const fgCtx = fgCanvas.getContext("2d"); var imeg = new Image(); imeg.src = "assets/shooter_background.jpg"; - fgCtx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650); + fgCtx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620); //lets initialize a new game const game = new Game(); new GameView(game, fgCtx).start(); @@ -179,19 +179,19 @@ class Game { switch (stage) { case 1: - this.addsmallEnemies(3); + this.addsmallEnemies(5); this.addbigEnemies(1); this.addmediumEnemies(1); break; case 2: - this.addsmallEnemies(4); + this.addsmallEnemies(6); this.addbigEnemies(1); this.addmediumEnemies(2); break; case 3: - this.addsmallEnemies(6); + this.addsmallEnemies(7); this.addbigEnemies(2); - this.addmediumEnemies(2); + this.addmediumEnemies(1); break; case 4: this.addboss(); @@ -207,7 +207,7 @@ class Game { sry: 0, pos: [0,0], mag: 1.8, - vel: Util.scale([4*Math.random() - 2,0], 1.8), + vel: [0,0], width: 294, height: 282, game: this, @@ -227,14 +227,14 @@ class Game { srx: 530, sry: 1998, pos: this.enemyrandomPosition(), - mag: 2.3, - vel: Util.scale([2*Math.random(),2*Math.random()], 2.3), + mag: 1.9, + vel: Util.scale([2*Math.random(),2*Math.random()], 1.9), width: 60, height: 46, game: this, image: enemyImage, type: "enemy_ship", - lifebar: 3, + lifebar: 5, bullettype: 1, isWrappable: true })); @@ -273,14 +273,14 @@ class Game { srx: 4, sry: 2, pos: this.enemyrandomPosition(), - mag: 2, - vel: Util.scale([2*Math.random(),2*Math.random()], 2), + mag: 1.8, + vel: Util.scale([2*Math.random(),2*Math.random()], 1.8), width: 166, height: 100, game: this, image: enemy_num3, type: "enemy_ship", - lifebar: 10, + lifebar: 15, bullettype: 2, isWrappable: true })); @@ -332,7 +332,7 @@ class Game { //THIS DOES ALL THE WORK OF MOVING ALL THE OBJECTS BEFORE THE NEXT RENDER moveObjects(delta, animationFrame) { this.allObjects().forEach((object) => { - object.move(delta, animationFrame); + object.move(delta, animationFrame, this.ships[0].pos); }); } @@ -354,7 +354,7 @@ class Game { x: 370, y: 320, size: "50px", - font: "PixelEmulator", + font: "Sans-Serif", color: "red" } ctx.font = finished.size + " " + finished.font; @@ -368,7 +368,7 @@ class Game { x: 370, y: 320, size: "50px", - font: "PixelEmulator", + font: "Sans-Serif", color: "white" } ctx.font = nxstage.size + " " + nxstage.font; @@ -383,7 +383,7 @@ class Game { this.clearScreen(ctx); var imeg = new Image(); imeg.src = "assets/shooter_background.jpg"; - ctx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650); + ctx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620); this.drawText(this.ships[0].score, ctx); // ctx.setTransform(0,1,1,0,1,1) this.allObjects().forEach((object) => { @@ -450,8 +450,8 @@ class Game { } Game.BG_COLOR = "#000000"; -Game.DIM_X = 1250; -Game.DIM_Y = 650; +Game.DIM_X = 1240; +Game.DIM_Y = 620; Game.FPS = 32; Game.NUM_ENEMIES = 4; @@ -485,22 +485,22 @@ class GameView { drawPaused(){ this.game.draw(this.ctx); - this.ctx.font = "70px PixelEmulator"; + this.ctx.font = "70px Sans-Serif"; this.ctx.fillStyle = "yellow"; this.ctx.fillText("Tyranny", 520, 240); - this.ctx.font = "50px PixelEmulator"; + this.ctx.font = "50px Sans-Serif"; this.ctx.fillStyle = "white"; this.ctx.fillText("Controls:", 550, 310); - this.ctx.font = "30px PixelEmulator"; + this.ctx.font = "30px Sans-Serif"; this.ctx.fillText(`Space to shoot`, 550, 350); this.ctx.fillText(`LUDR Arrows to steer`, 500, 390); this.ctx.fillText(`Esc / Enter to pause`, 520, 430); - this.ctx.fillText(`ctrl + r to restart`, 540, 470) + this.ctx.fillText(`cmd + r to restart`, 540, 470) } drawVictory(){ this.game.draw(this.ctx); - this.ctx.font = "60px PixelEmulator"; + this.ctx.font = "60px Sans-Serif"; this.ctx.fillStyle = "white"; this.ctx.fillText("Congratulations You Win!", 280, 360); } @@ -531,7 +531,10 @@ class GameView { else { this.paused = false; this.game.enemies.forEach((enemy) => { - enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + if ( enemy.bullettype !== 4 ) + { + enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + } }); } this.requestId = requestAnimationFrame(this.animate.bind(this)); @@ -548,7 +551,10 @@ class GameView { else { this.paused = false; this.game.enemies.forEach((enemy) => { - enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + if ( enemy.bullettype !== 4 ) + { + enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + } }); } this.requestId = requestAnimationFrame(this.animate.bind(this)); @@ -736,6 +742,12 @@ const Util = { norm (vec) { return Util.dist([0, 0], vec); }, + + bossMove(bosspos, playerpos){ + let vector = [playerpos[0] - bosspos[0], 0]; + var normal = Util.norm(vector); + return Util.scale(vector, 1.7 / normal); + }, // Return a randomly oriented vector with the given length. randomVec (length) { var deg = 2 * Math.PI * Math.random(); @@ -791,7 +803,7 @@ class MovingObject { //Since each object inherits from moving_object, they will all move a certain way //that comes from this move method. They can all run the move method. This will come //from the step method. - move(timeDelta, animationFrame) { + move(timeDelta, animationFrame, playerpos) { //timeDelta is number of milliseconds since last move //if the computer is busy the time delta will be larger //in this case the MovingObject should move farther in this frame @@ -809,13 +821,18 @@ class MovingObject { //lets check if the x and y coords plus the offset will take us out of bounds //or not and if they do then we won't allow this. This is good to prevent the ship from goibg //across the screen - if ( !this.bullettype === 4 && this.type === "enemy_ship" && animationFrame % 80 === 0 ) + if ( this.bullettype !== 4 && this.type === "enemy_ship" && animationFrame % 80 === 0 ) + { + console.log('hi'); + this.vel = Util.scale([4*Math.random()-2,2*Math.random()], this.mag); + } + if ( this.bullettype === 4 && animationFrame % 400 === 0 ) { - this.vel = Util.scale([2*Math.random(),2*Math.random()], this.mag); + this.vel = Util.bossMove(this.pos, playerpos); } - if ( this.bullettype === 4 && animationFrame % 40 === 0 ) + if ( this.bullettype === 4 && animationFrame % 193 === 0 ) { - this.vel = Util.scale([4*Math.random() - 2, 0], this.mag); + this.vel = Util.scale([4*Math.random() - 2, 0], 2); } if (this.game.isOutOfBounds(this.pos)) { if (this.isWrappable) { @@ -842,8 +859,7 @@ class MovingObject { this.grabAnimation(); } ctx.drawImage(this.image, this.srx, this.sry, this.width, this.height, this.pos[0], this.pos[1], this.width, this.height); - // ctx.arc( - // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true + // ctx.arc( // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true // ); ctx.fill(); } @@ -920,10 +936,10 @@ class Ship extends MovingObject { scorevalue: 0, lifevalue: 4, health: 100, - x: 850, + x: 800, y: 50, size: "25px", - font: "PixelEmulator", + font: "Sans-Serif", color: "#42f445" } this.direction = "flat"; @@ -1134,7 +1150,7 @@ class Tyran extends MovingObject { if (this.lifebar <= 0){ this.game.ships[0].score.scorevalue += 100; this.remove(); - if (this.game.enemies.length % 3 === 0){ + if (this.game.enemies.length % 4 === 0){ this.game.addPowerUp(); } } diff --git a/lib/bundle.js.map b/lib/bundle.js.map index 88e9f44..0f8a021 100644 --- a/lib/bundle.js.map +++ b/lib/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap c2e1bfa707b4474f2c66","webpack:///./lib/tyranny.js","webpack:///./lib/game.js","webpack:///./lib/game_view.js","webpack:///./lib/util.js","webpack:///./lib/moving_object.js","webpack:///./lib/bullet.js","webpack:///./lib/ship.js","webpack:///./lib/tyran.js","webpack:///./lib/powerup.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;AC7DA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;ACfD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,+CAA+C;AACpE;;AAEA;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,uBAAuB;AAC1C,qBAAqB,uBAAuB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,2BAA2B,gBAAgB,cAAc,YAAY,aAAa,eAAe;AACjG;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,MAAM;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AC9WA;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;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yBAAyB,EAAE;AAC3B,KAAK;;AAEL,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;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;;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AC3PA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;;;;;;;ACpCA;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;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,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;;;AAGA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;AC1GA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;;;;;;AClBA;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AClLA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvOA;;AAEA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA","file":"./lib/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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c2e1bfa707b4474f2c66","const Game = require(\"./game\");\nconst GameView = require(\"./game_view\");\n\ndocument.addEventListener(\"DOMContentLoaded\", function(){\n // const bgCanvas = document.getElementById(\"bg-canvas\");\n const fgCanvas = document.getElementById(\"fg-canvas\");\n\n // const bgCtx = bgCanvas.getContext(\"2d\");\n const fgCtx = fgCanvas.getContext(\"2d\");\n var imeg = new Image();\n imeg.src = \"assets/shooter_background.jpg\";\n fgCtx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650);\n //lets initialize a new game\n const game = new Game();\n new GameView(game, fgCtx).start();\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/tyranny.js\n// module id = 0\n// module chunks = 0","const Tyran = require(\"./tyran\");\nconst Bullet = require(\"./bullet\");\nconst Ship = require(\"./ship\");\nconst Util = require(\"./util\");\nconst PowerUp = require(\"./powerup\");\n// this contains all the objects in the game that we are going to change before we\n// re-render them all\n\nclass Game {\n constructor() {\n this.bullets = [];\n this.ships = [];\n this.enemies = [];\n this.powerups = [];\n //lets add the enemies now\n this.drawText = this.drawText.bind(this);\n this.clearScreen = this.clearScreen.bind(this);\n this.addEnemies = this.addEnemies.bind(this);\n this.addEnemies(1);\n }\n\n add(object) {\n if (object instanceof Bullet) {\n this.bullets.push(object);\n }\n else if (object instanceof Tyran) {\n this.enemies.push(object);\n }\n else if (object instanceof Ship) {\n this.ships.push(object);\n }\n else if (object instanceof PowerUp){\n this.powerups.push(object);\n }\n else {\n throw \"wtf?\";\n }\n }\n\n addPowerUp(){\n var powerupImage = new Image();\n powerupImage.src = \"assets/spaced_out_again.gif\"\n let powerupPos = Math.floor(3*Math.random());\n let allpowerups = [\n {\n srx: 23,\n sry: 3861,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"more_health\",\n isWrappable: true\n },\n {\n srx: 23,\n sry: 3950,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"upgrade_weapon\",\n isWrappable: true\n },\n {\n srx: 23,\n sry: 3906,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"more_lives\",\n isWrappable: true\n }\n ]\n // console.log(allpowerups[]);\n this.add(new PowerUp(allpowerups[powerupPos]));\n setTimeout(()=> {this.powerups[this.powerups.length-1].remove()}, 11000)\n }\n\n addEnemies(stage) {\n\n switch (stage) {\n case 1:\n this.addsmallEnemies(3);\n this.addbigEnemies(1);\n this.addmediumEnemies(1);\n break;\n case 2:\n this.addsmallEnemies(4);\n this.addbigEnemies(1);\n this.addmediumEnemies(2);\n break;\n case 3:\n this.addsmallEnemies(6);\n this.addbigEnemies(2);\n this.addmediumEnemies(2);\n break;\n case 4:\n this.addboss();\n break;\n }\n }\n\n addboss(){\n var bossimage = new Image();\n bossimage.src = \"assets/tyrianboss.gif\";\n this.add(new Tyran({\n srx: 0,\n sry: 0,\n pos: [0,0],\n mag: 1.8,\n vel: Util.scale([4*Math.random() - 2,0], 1.8),\n width: 294,\n height: 282,\n game: this,\n image: bossimage,\n type: \"enemy_ship\",\n lifebar: 100,\n bullettype: 4,\n isWrappable: true\n }));\n }\n\n addsmallEnemies(num){\n var enemyImage = new Image();\n enemyImage.src = \"assets/spaced_out_again_reverse.gif\";\n for (let i = 0; i < num; i++) {\n this.add(new Tyran({\n srx: 530,\n sry: 1998,\n pos: this.enemyrandomPosition(),\n mag: 2.3,\n vel: Util.scale([2*Math.random(),2*Math.random()], 2.3),\n width: 60,\n height: 46,\n game: this,\n image: enemyImage,\n type: \"enemy_ship\",\n lifebar: 3,\n bullettype: 1,\n isWrappable: true\n }));\n }\n }\n\n addbigEnemies(num){\n var enemy_num2 = new Image();\n enemy_num2.src = \"assets/enemy2.png\";\n for (let i = 0; i < num; i++)\n {\n this.add(new Tyran({\n srx: 0,\n sry: 0,\n pos: this.enemyrandomPosition(),\n mag: 1.5,\n vel: Util.scale([2*Math.random(),2*Math.random()], 1.5),\n width: 142,\n height: 117,\n game: this,\n image: enemy_num2,\n type: \"enemy_ship\",\n lifebar: 20,\n bullettype: 3,\n isWrappable: true\n }));\n }\n }\n\n addmediumEnemies(num){\n var enemy_num3 = new Image();\n enemy_num3.src = \"assets/6.png\";\n for (let i = 0; i < num; i++)\n {\n this.add(new Tyran({\n srx: 4,\n sry: 2,\n pos: this.enemyrandomPosition(),\n mag: 2,\n vel: Util.scale([2*Math.random(),2*Math.random()], 2),\n width: 166,\n height: 100,\n game: this,\n image: enemy_num3,\n type: \"enemy_ship\",\n lifebar: 10,\n bullettype: 2,\n isWrappable: true\n }));\n }\n }\n\n addShip(shiptype) {\n var shipImage = new Image();\n shipImage.src = \"assets/spaced_out_again.gif\";\n\n const ship = new Ship({\n srx: 28,\n sry: 2212,\n pos: [500, 500],\n vel: [0, 0],\n width: 48,\n height: 46,\n game: this,\n image: shipImage,\n type: shiptype,\n isWrappable: false\n });\n\n this.add(ship);\n\n return ship;\n }\n\n allObjects() {\n return [].concat(this.ships, this.bullets, this.enemies, this.powerups);\n }\n\n checkCollisions() {\n const allObjects = this.allObjects();\n for (let i = 0; i < allObjects.length; i++) {\n for (let j = 0; j < allObjects.length; j++) {\n const obj1 = allObjects[i];\n const obj2 = allObjects[j];\n //Everything depends on what type of object it is.\n if (obj1.isCollidedWith(obj2)) {\n //This is a way to end this early because their is only one collision per animation frame.\n const collision = obj1.collideWith(obj2);\n if (collision) return;\n }\n }\n }\n }\n\n //THIS DOES ALL THE WORK OF MOVING ALL THE OBJECTS BEFORE THE NEXT RENDER\n moveObjects(delta, animationFrame) {\n this.allObjects().forEach((object) => {\n object.move(delta, animationFrame);\n });\n }\n\n drawText(text, ctx){\n ctx.font = text.size + \" \" + text.font;\n ctx.fillStyle = text.color;\n ctx.fillText(`Score: ${text.scorevalue} Health: ${text.health} Lives: ${text.lifevalue}`, text.x, text.y);\n }\n\n clearScreen(ctx){\n ctx.clearRect(0, 0, Game.DIM_X, Game.DIM_Y);\n ctx.fillStyle = Game.BG_COLOR;\n ctx.fillRect(0, 0, Game.DIM_X, Game.DIM_Y);\n }\n\n drawGameOver(ctx){\n this.clearScreen(ctx);\n let finished ={\n x: 370,\n y: 320,\n size: \"50px\",\n font: \"PixelEmulator\",\n color: \"red\"\n }\n ctx.font = finished.size + \" \" + finished.font;\n ctx.fillStyle = finished.color;\n ctx.fillText(\"GAME OVER YOU LOSE\", finished.x, finished.y);\n }\n\n drawNextStage(ctx, stage){\n this.clearScreen(ctx);\n let nxstage ={\n x: 370,\n y: 320,\n size: \"50px\",\n font: \"PixelEmulator\",\n color: \"white\"\n }\n ctx.font = nxstage.size + \" \" + nxstage.font;\n ctx.fillStyle = nxstage.color;\n ctx.fillText(`Stage ${stage} Get Ready`, nxstage.x, nxstage.y);\n }\n\n //We use clear Rect and fillrect to draw over again\n //lets draw up all of the objects on the screen again before we render them again.\n draw(ctx) {\n //canvas clear and fill rect will allow us to clear and re-render.\n this.clearScreen(ctx);\n var imeg = new Image();\n imeg.src = \"assets/shooter_background.jpg\";\n ctx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650);\n this.drawText(this.ships[0].score, ctx);\n // ctx.setTransform(0,1,1,0,1,1)\n this.allObjects().forEach((object) => {\n object.draw(ctx);\n });\n }\n\n isOutOfBounds(pos) {\n return (pos[0] < 0) || (pos[1] < 0) ||\n (pos[0] > Game.DIM_X) || (pos[1] > Game.DIM_Y);\n }\n //Lets take all of our objects and move them based on how they should move and how far\n //they should move\n\n enemyrandomPosition() {\n return [\n Game.DIM_X * Math.random(),\n 0\n ];\n }\n\n poweruprandomPosition() {\n return [\n Game.DIM_X * Math.random(),\n Game.DIM_Y * Math.random()\n ];\n }\n\n randomPosition() {\n return [\n 1200 * Math.random(),\n 500\n ];\n }\n\n remove(object) {\n if (object instanceof Bullet) {\n this.bullets.splice(this.bullets.indexOf(object), 1);\n } else if (object instanceof Tyran) {\n this.enemies.splice(this.enemies.indexOf(object), 1);\n } else if (object instanceof Ship) {\n this.ships.splice(this.ships.indexOf(object), 1);\n }\n else if(object instanceof PowerUp){\n this.powerups.splice(this.powerups.indexOf(object), 1)\n }\n else {\n throw \"wtf?\";\n }\n }\n //Lets hand the animation, then the movement, then the physics to check for collisions.\n step(delta, animationFrame) {\n // this.animateObjects();\n this.animationFrame = animationFrame;\n this.moveObjects(delta, animationFrame);\n this.checkCollisions();\n }\n\n wrap(pos) {\n return [\n Math.random()*Game.DIM_X, 0\n ];\n }\n}\n\nGame.BG_COLOR = \"#000000\";\nGame.DIM_X = 1250;\nGame.DIM_Y = 650;\nGame.FPS = 32;\nGame.NUM_ENEMIES = 4;\n\nmodule.exports = Game;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/game.js\n// module id = 1\n// module chunks = 0","//This contains all the logic for rendering the game\nconst Util = require(\"./util\");\nclass GameView {\n constructor(game, ctx) {\n this.ctx = ctx;\n this.game = game;\n this.animationFrame = 0;\n //We add the ship as soon as the game starts.\n this.ship = this.game.addShip(\"player_ship\");\n // this.animating = this.animating.bind(this);\n this.requestId = undefined;\n // this.stopping = this.stopping.bind(this);\n this.start = this.start.bind(this);\n this.stage = 1;\n this.paused = false;\n this.startmenu = true;\n this.bosslaser = true;\n this.bossmissile = false;\n this.bossorange = false;\n }\n\n drawPaused(){\n this.game.draw(this.ctx);\n this.ctx.font = \"70px PixelEmulator\";\n this.ctx.fillStyle = \"yellow\";\n this.ctx.fillText(\"Tyranny\", 520, 240);\n this.ctx.font = \"50px PixelEmulator\";\n this.ctx.fillStyle = \"white\";\n this.ctx.fillText(\"Controls:\", 550, 310);\n this.ctx.font = \"30px PixelEmulator\";\n this.ctx.fillText(`Space to shoot`, 550, 350);\n this.ctx.fillText(`LUDR Arrows to steer`, 500, 390);\n this.ctx.fillText(`Esc / Enter to pause`, 520, 430);\n this.ctx.fillText(`ctrl + r to restart`, 540, 470)\n }\n\n drawVictory(){\n this.game.draw(this.ctx);\n this.ctx.font = \"60px PixelEmulator\";\n this.ctx.fillStyle = \"white\";\n this.ctx.fillText(\"Congratulations You Win!\", 280, 360);\n }\n\n //Lets bind the key handlers that are going to let us handle input from the user.\n bindKeyHandlers() {\n const ship = this.ship;\n let that = this;\n\n Object.keys(GameView.MOVES).forEach((k) => {\n let move = GameView.MOVES[k];\n key(k, () => {\n // console.log(key.isPressed(k));\n ship.direction = k;\n ship.power(move); });\n });\n\n key(\"space\", () => { ship.fireBullet() });\n key(\"esc\", () => {\n if ( !this.paused )\n {\n this.paused = true;\n this.drawPaused();\n this.game.enemies.forEach((enemy) => {\n enemy.vel = [0,0];\n });\n }\n else {\n this.paused = false;\n this.game.enemies.forEach((enemy) => {\n enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag);\n });\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n })\n key(\"enter\", () => {\n if ( !this.paused )\n {\n this.paused = true;\n this.drawPaused();\n this.game.enemies.forEach((enemy) => {\n enemy.vel = [0,0];\n });\n }\n else {\n this.paused = false;\n this.game.enemies.forEach((enemy) => {\n enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag);\n });\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n })\n }\n\n // togglepause(){\n // if ( this.requestId )\n // {\n // this.stop();\n // }\n // else\n // {\n // this.requestId = requestAnimationFrame(this.animate.bind(this));\n // }\n // }\n start() {\n this.bindKeyHandlers();\n this.lastTime = 0;\n //start the animation\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }\n\n // stopping(){\n // if ( this.requestId )\n // {\n // console.log(this.requestId);\n // console.log(this.animationFrame);\n // window.cancelAnimationFrame(this.requestId);\n // // key.deleteScope(\"player\");\n // //or null???\n // this.requestId = 0;\n // }\n // else\n // {\n // this.requestId = window.requestAnimationFrame(this.animate.bind(this));\n // // this.setScope(\"player\");\n // }\n // }\n\n // animating(frame){\n // if (!this.paused){\n // window.requestAnimationFrame(this.animate.bind(this));\n // }\n // else{\n // window.cancelAnimationFrame(frame - 1);\n // }\n // }\n\n //This is doing a lot of things. It is determining all the new positions, checking for collisions.\n //Come back here when you are thinking about what is going on.\n //this is a recursive call contantly being made\n\n //animate refers to animating the entire game here.\n animate(time) {\n // if ( this.game.enemies.length === 0 )\n // {\n // this.game.addEnemies(this.stage);\n // }\n if ( this.paused )\n {\n return;\n }\n // window.cancelAnimationFrame(this.requestId);\n // return;\n // // console.log('hi');\n // // return;\n // // window.cancelAnimationFrame(this.requestId);\n // // this.requestId = 0;\n // // this.requestId = window.requestAnimationFrame(this.animate.bind(this));\n // }\n const timeDelta = time - this.lastTime;\n let pressed_keys = key.getPressedKeyCodes()\n if ( pressed_keys.length === 0 )\n {\n this.ship.srx = 28;\n this.ship.sry = 2212;\n this.ship.direction = \"flat\";\n this.ship.flyingFrame = 0;\n this.ship.rightindex = -1;\n this.ship.leftindex = -1;\n this.ship.vel = [0,0];\n }\n if ( this.animationFrame % 277 === 0 )\n {\n this.bosslaser = !this.bosslaser;\n }\n if ( this.animationFrame % 347 === 0 )\n {\n this.bossorange = !this.bossorange;\n }\n if ( this.animationFrame % 67 === 0 )\n {\n this.bossmissile = !this.bossmissile;\n }\n this.game.enemies.forEach((enemy) => {\n if ( enemy.bullettype === 1 && ((this.animationFrame + 30) % 80) === 0 )\n {\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 2 && ((this.animationFrame + 50) % 100) === 0){\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 3){\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 4 && this.bosslaser){\n enemy.fireBullet(\"laser\");\n }\n else if (enemy.bullettype === 4 && this.bossmissile && this.animationFrame % 20 === 0){\n enemy.fireBullet(\"missile\");\n }\n else if (enemy.bullettype === 4 && this.bossorange && this.animationFrame % 20 === 0){\n enemy.fireBullet(\"orange\");\n }\n })\n this.game.step(timeDelta, this.animationFrame);\n this.game.draw(this.ctx);\n //lets reset the time.\n this.lastTime = time;\n this.animationFrame++;\n if ( this.game.ships[0].score.lifevalue === 0 )\n {\n this.game.drawGameOver(this.ctx);\n return;\n }\n //every call to animate requests causes another call to animate\n //repetitive callback\n if ( this.startmenu )\n {\n this.paused = true;\n this.drawPaused();\n this.startmenu = false;\n }\n if ( this.game.enemies.length === 0 )\n {\n this.paused = true;\n this.stage += 1;\n if ( this.stage === 5 )\n {\n this.drawVictory();\n // cancelAnimationFrame(this.requestId);\n return;\n }\n this.game.drawNextStage(this.ctx, this.stage);\n this.game.ships[0].pos = this.game.randomPosition();\n setTimeout(()=> {\n this.paused = false;\n this.game.addEnemies(this.stage);\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }, 4000);\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }\n}\n\n\nGameView.MOVES = {\n \"up\": [ 0, -9],\n \"left\": [-9, 0],\n \"down\": [ 0, 9],\n \"right\": [ 9, 0]\n};\n\nmodule.exports = GameView;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/game_view.js\n// module id = 2\n// module chunks = 0","const Util = {\n // Normalize the length of the vector to 1, maintaining direction.\n dir (vec) {\n var norm = Util.norm(vec);\n return Util.scale(vec, 1 / norm);\n },\n // Find distance between two points.\n dist (pos1, pos2) {\n return Math.sqrt(\n Math.pow(pos1[0] - pos2[0], 2) + Math.pow(pos1[1] - pos2[1], 2)\n );\n },\n // Find the length of the vector.\n norm (vec) {\n return Util.dist([0, 0], vec);\n },\n // Return a randomly oriented vector with the given length.\n randomVec (length) {\n var deg = 2 * Math.PI * Math.random();\n return Util.scale([Math.sin(deg), Math.cos(deg)], length);\n },\n // Scale the length of a vector by the given amount.\n scale (vec, m) {\n return [vec[0] * m, vec[1] * m];\n },\n //This will help the wrapping of objects and will let cetain things go off screen and\n //return back to the screen.\n // wrap (coord, max) {\n // if (coord > max) {\n // return coord % max;\n // } else {\n // return coord;\n // }\n // }\n};\n\nmodule.exports = Util;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/util.js\n// module id = 3\n// module chunks = 0","const Util = require(\"./util\");\n// const PowerUp = require(\"./powerup\");\n\nclass MovingObject {\n constructor(options) {\n this.vel = options.vel;\n this.pos = options.pos;\n this.width = options.width;\n this.height = options.height;\n this.game = options.game;\n this.image = options.image;\n this.type = options.type;\n this.srx = options.srx;\n this.sry = options.sry;\n this.isWrappable = options.isWrappable;\n this.bullettype = options.bullettype;\n //everything this wrappable except for bullets which are not.\n // this.isWrappable = true;\n }\n\n //Basically the handle collision function that will be run if there is a collision.\n collideWith(otherObject) {\n // default do nothing\n }\n\n //Since each object inherits from moving_object, they will all move a certain way\n //that comes from this move method. They can all run the move method. This will come\n //from the step method.\n move(timeDelta, animationFrame) {\n //timeDelta is number of milliseconds since last move\n //if the computer is busy the time delta will be larger\n //in this case the MovingObject should move farther in this frame\n //velocity of object is how far it should move in 1/60th of a second\n\n //We should normally move 60 frames in a second, so we are taking a time proportionality\n //of the amount of time delta it took to reach this frame and multiplying by our nomal\n //frame rate so we get movement that is proporitional.\n const velocityScale = timeDelta / NORMAL_FRAME_TIME_DELTA,\n offsetX = this.vel[0] * velocityScale,\n offsetY = this.vel[1] * velocityScale;\n let prevpos = this.pos.slice(0);\n this.pos = [this.pos[0] + offsetX, this.pos[1] + offsetY];\n //This is used to change the direction of the ships randomly\n //lets check if the x and y coords plus the offset will take us out of bounds\n //or not and if they do then we won't allow this. This is good to prevent the ship from goibg\n //across the screen\n if ( !this.bullettype === 4 && this.type === \"enemy_ship\" && animationFrame % 80 === 0 )\n {\n this.vel = Util.scale([2*Math.random(),2*Math.random()], this.mag);\n }\n if ( this.bullettype === 4 && animationFrame % 40 === 0 )\n {\n this.vel = Util.scale([4*Math.random() - 2, 0], this.mag);\n }\n if (this.game.isOutOfBounds(this.pos)) {\n if (this.isWrappable) {\n this.pos = this.game.wrap(this.pos);\n } else if (!this.isWrappable && (this.type === \"player_ship\"))\n {\n this.pos = prevpos;\n }\n else\n {\n this.remove();\n }\n }\n\n }\n //MOVE AND THEN DRAW\n //This draw method will help to draw a circle to the screen.\n draw(ctx) {\n ctx.fillStyle = this.color;\n //beginpath pretty much just lets us start the canvas drawing.\n ctx.beginPath();\n if ( [\"player_ship\", \"more_health\", \"upgrade_weapon\", \"more_lives\"].includes(this.type) )\n {\n this.grabAnimation();\n }\n ctx.drawImage(this.image, this.srx, this.sry, this.width, this.height, this.pos[0], this.pos[1], this.width, this.height);\n // ctx.arc(\n // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true\n // );\n ctx.fill();\n }\n\n //A better thing to do is to check for box collision since we won't be using circles.\n isCollidedWith(otherObject) {\n let x1 = this.pos[0];\n let y1 = this.pos[1];\n let w1 = this.width;\n let h1 = this.height;\n let x2 = otherObject.pos[0];\n let y2 = otherObject.pos[1];\n let w2 = otherObject.width;\n let h2 = otherObject.height;\n return !(x1 + w1 < x2 || x1 > x2 + w2 || y1 > y2 + h2 || y1 + h1 < y2);\n }\n\n\n remove() {\n this.game.remove(this);\n }\n}\n\nconst NORMAL_FRAME_TIME_DELTA = 1000/60;\n\nmodule.exports = MovingObject;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/moving_object.js\n// module id = 4\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\n\nclass Bullet extends MovingObject {\n constructor(options) {\n options.image = options.image;\n options.type = options.type;\n options.width = options.width;\n options.height = options.height;\n super(options);\n //Everything else will be the same as moving object\n //we don't want it to go offscreen and come back on screen.\n\n this.power = options.power;\n }\n}\n\nBullet.SPEED = 15;\n\nmodule.exports = Bullet;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/bullet.js\n// module id = 5\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\nconst Bullet = require(\"./bullet\");\nconst Util = require(\"./util\");\n\nclass Ship extends MovingObject {\n constructor(options) {\n // start with velocity of 0\n options.pos = options.pos;\n options.vel = options.vel;\n options.width = options.width;\n options.height = options.height;\n options.game = options.game;\n options.type = options.type;\n options.image = options.image;\n super(options);\n this.score = {\n scorevalue: 0,\n lifevalue: 4,\n health: 100,\n x: 850,\n y: 50,\n size: \"25px\",\n font: \"PixelEmulator\",\n color: \"#42f445\"\n }\n this.direction = \"flat\";\n this.flyingFrame = 0;\n this.rightFrames = [[192,2255], [247, 2256], [303,2257], [468,2258]];\n this.leftFrames = [[200,2208], [305, 2207], [416,2208], [523,2207]];\n this.rightindex = -1;\n this.leftindex = -1;\n this.grabAnimation = this.grabAnimation.bind(this);\n this.bulletpower = 1;\n this.bullettype = 1;\n }\n\n grabAnimation(){\n let that = this;\n if ( that.direction === \"right\" )\n {\n if (that.flyingFrame % 3 === 0){\n that.rightindex += 1;\n if ( that.rightindex >= that.rightFrames.length ){\n return;\n }\n that.srx = that.rightFrames[that.rightindex][0];\n that.sry = that.rightFrames[that.rightindex][1];\n }\n that.flyingFrame += 1;\n }\n else if (that.direction === \"left\")\n {\n if (that.flyingFrame % 3 === 0){\n that.leftindex += 1;\n if ( that.leftindex >= that.leftFrames.length )\n {\n return;\n }\n that.srx = that.leftFrames[that.leftindex][0];\n that.sry = that.leftFrames[that.leftindex][1];\n }\n that.flyingFrame++;\n }\n // this.direction = \"flat\";\n }\n\n collideWith(otherObject) {\n if (otherObject.type === \"enemy_bullet\") {\n // otherObject.takeDamage();\n this.score.health -= otherObject.power;\n if ( this.score.health <= 0 )\n {\n this.score.lifevalue -= 1;\n this.score.health = 100;\n this.bullettype = 1;\n this.bulletpower = 1;\n this.relocate();\n }\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"more_health\"){\n this.score.health += 50;\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"upgrade_weapon\"){\n this.bulletpower += 1;\n this.bullettype += 1;\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"more_lives\"){\n this.score.lifevalue += 1;\n otherObject.remove();\n return true;\n }\n }\n\n fireBullet() {\n // const norm = Util.norm([0,this.vel[1]]);\n //change this in your game because you will be able to fire even if you are moving\n // if (norm == 0) {\n // // Can't fire unless moving.\n // return;\n // }\n //GET THE RELATIVE VELOCITY TO THE SHIP FROM THE DIRECTION AND THE SPEED\n const relVel = Util.scale(\n Util.dir([0, -1]),\n Bullet.SPEED\n );\n\n const bulletVel = [\n 0, relVel[1] + this.vel[1]\n ];\n //MOVE THIS\n var bullet_image = new Image();\n bullet_image.src = \"assets/spaced_out_again_reverse.gif\";\n var second = new Image();\n let bullet;\n second.src = \"assets/spaced_out_again.gif\";\n if (this.bullettype === 1){\n bullet = new Bullet({\n srx: 449,\n sry: 1270,\n pos: [this.pos[0] + 14, this.pos[1] - 63],\n vel: bulletVel,\n width: 21,\n height: 77,\n game: this.game,\n image: bullet_image,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n else if (this.bullettype === 2){\n bullet = new Bullet({\n srx: 113,\n sry: 3520,\n pos: [this.pos[0] + 14, this.pos[1] - 53],\n vel: bulletVel,\n width: 45,\n height: 66,\n game: this.game,\n image: second,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n else if (this.bullettype >= 3){\n bullet = new Bullet({\n srx: 539,\n sry: 2986,\n pos: [this.pos[0] + 14, this.pos[1] - 53],\n vel: bulletVel,\n width: 31,\n height: 97,\n game: this.game,\n image: second,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n\n this.game.add(bullet);\n }\n//Power and then move the object\n power(impulse) {\n this.vel[0] = impulse[0];\n this.vel[1] = impulse[1];\n }\n\n relocate() {\n this.pos = this.game.randomPosition();\n this.vel = [0, 0];\n }\n}\n\nmodule.exports = Ship;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/ship.js\n// module id = 6\n// module chunks = 0","const Util = require(\"./util\");\nconst MovingObject = require(\"./moving_object\");\nconst Ship = require(\"./ship\");\nconst Bullet = require(\"./bullet\");\n\nconst DEFAULTS = {\n\tSPEED: 1\n};\n\nclass Tyran extends MovingObject {\n constructor(options = {}) {\n options.game = options.game;\n options.width = options.width;\n options.height = options.height;\n options.pos = options.pos;\n options.vel = options.vel;\n options.image = options.image;\n options.type = options.type;\n super(options);\n this.lifebar = options.lifebar;\n\t\t\tthis.mag = options.mag;\n\t\t\t// this.bullettype = options.bullettype;\n }\n //Make the logic for getting hurt by bullets here.\n //Our ship is currently just relocating when it gets hit\n collideWith(otherObject) {\n if (otherObject instanceof Ship) {\n // otherObject.takeDamage();\n\t\t\t\totherObject.score.health -= 50;\n\t\t\t\tthis.pos = this.game.enemyrandomPosition();\n\t if ( otherObject.score.health <= 0 )\n\t {\n\t otherObject.score.lifevalue -= 1;\n\t otherObject.score.health = 100;\n\t otherObject.bullettype = 1;\n\t otherObject.bulletpower = 1;\n\t otherObject.relocate();\n\t }\n\t\t\t\t// otherObject.bullettype = 1;\n\t\t\t\t// otherObject.bulletpower = 1;\n // otherObject.relocate();\n return true;\n } else if (otherObject.type === \"bullet\") {\n\t\t\t\t\t\tthis.lifebar -= otherObject.power;\n\t\t\t\t\t\totherObject.remove();\n\t\t\t\t\t\tif (this.lifebar <= 0){\n\t this.game.ships[0].score.scorevalue += 100;\n\t this.remove();\n\t\t\t\t\t\t\tif (this.game.enemies.length % 3 === 0){\n\t\t\t\t\t\t\t\tthis.game.addPowerUp();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n return true;\n }\n }\n\n fireBullet(firetype) {\n // const norm = Util.norm([0,this.vel[1]]);\n //change this in your game because you will be able to fire even if you are moving\n // if (norm == 0) {\n // // Can't fire unless moving.\n // return;\n // }\n //GET THE RELATIVE VELOCITY TO THE SHIP FROM THE DIRECTION AND THE SPEED\n const relVel = Util.scale(\n Util.dir([0, 1]),\n 2\n );\n\n const bulletVel = [\n 0, relVel[1] + this.vel[1]\n ];\n //MOVE THIS\n var enemy_bullet_image = new Image();\n enemy_bullet_image.src = \"assets/spaced_out_again_reverse.gif\";\n\t\t\tvar big_enemy_bullet_image = new Image();\n\t\t\tbig_enemy_bullet_image.src = \"assets/laserbeam.gif\";\n\t\t\tswitch(this.bullettype){\n\t\t\t\tcase 1:\n\t\t this.game.add(new Bullet({\n\t\t srx: 425,\n\t\t sry: 1103,\n\t\t pos: [this.pos[0] + 14, this.pos[1] + 40],\n\t\t width: 28,\n\t\t height: 30,\n\t\t vel: bulletVel,\n\t\t game: this.game,\n\t\t type: \"enemy_bullet\",\n\t\t image: enemy_bullet_image,\n\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\tisWrappable: false\n\t\t }))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\tpos: [this.pos[0] + 24, this.pos[1] + 40],\n\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\tpos: [this.pos[0] + 150, this.pos[1] + 40],\n\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 83,\n\t\t\t\t\t\tsry: 55,\n\t\t\t\t\t\tpos: [this.pos[0] + 48, this.pos[1] + 80],\n\t\t\t\t\t\twidth: 42,\n\t\t\t\t\t\theight: 20,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: big_enemy_bullet_image,\n\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tif ( firetype === \"laser\" )\n\t\t\t\t\t{\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 83,\n\t\t\t\t\t\t\tsry: 55,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 120, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 42,\n\t\t\t\t\t\t\theight: 20,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: big_enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if( firetype === \"missile\"){\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 70, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 250, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if( firetype === \"orange\"){\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 70, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 120, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 250, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t}\n //You want the game to have knowledge of this bullet\n // this.game.add(bullet);\n }\n}\n\nmodule.exports = Tyran;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/tyran.js\n// module id = 7\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\n\nclass PowerUp extends MovingObject {\n constructor(options = {}){\n super(options);\n this.isWrappable = true;\n this.spinFrame = 0;\n this.animationstates = [];\n for (let i = 0; i < 16; i++)\n {\n this.animationstates.push([this.srx + this.width * i, this.sry]);\n }\n this.animindex = 0;\n }\n\n grabAnimation(){\n let that = this;\n if (that.spinFrame % 4 === 0){\n if ( that.animindex === 16 ){\n that.animindex = 0;\n }\n that.srx = that.animationstates[that.animindex][0];\n that.sry = that.animationstates[that.animindex][1];\n that.animindex += 1;\n }\n that.spinFrame++;\n }\n}\n\n\nmodule.exports = PowerUp;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/powerup.js\n// module id = 8\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 84a94c275f0795cf8fab","webpack:///./lib/tyranny.js","webpack:///./lib/game.js","webpack:///./lib/game_view.js","webpack:///./lib/util.js","webpack:///./lib/moving_object.js","webpack:///./lib/bullet.js","webpack:///./lib/ship.js","webpack:///./lib/tyran.js","webpack:///./lib/powerup.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;AC7DA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;ACfD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,+CAA+C;AACpE;;AAEA;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,uBAAuB;AAC1C,qBAAqB,uBAAuB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,2BAA2B,gBAAgB,cAAc,YAAY,aAAa,eAAe;AACjG;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,MAAM;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AC9WA;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;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yBAAyB,EAAE;AAC3B,KAAK;;AAEL,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;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;;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACjQA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;;;;;;;AC1CA;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;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;AACA;AACA;AACA;AACA,OAAO;AACP;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;AC9GA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;;;;;;AClBA;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AClLA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACvOA;;AAEA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA","file":"./lib/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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 84a94c275f0795cf8fab","const Game = require(\"./game\");\nconst GameView = require(\"./game_view\");\n\ndocument.addEventListener(\"DOMContentLoaded\", function(){\n // const bgCanvas = document.getElementById(\"bg-canvas\");\n const fgCanvas = document.getElementById(\"fg-canvas\");\n\n // const bgCtx = bgCanvas.getContext(\"2d\");\n const fgCtx = fgCanvas.getContext(\"2d\");\n var imeg = new Image();\n imeg.src = \"assets/shooter_background.jpg\";\n fgCtx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620);\n //lets initialize a new game\n const game = new Game();\n new GameView(game, fgCtx).start();\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/tyranny.js\n// module id = 0\n// module chunks = 0","const Tyran = require(\"./tyran\");\nconst Bullet = require(\"./bullet\");\nconst Ship = require(\"./ship\");\nconst Util = require(\"./util\");\nconst PowerUp = require(\"./powerup\");\n// this contains all the objects in the game that we are going to change before we\n// re-render them all\n\nclass Game {\n constructor() {\n this.bullets = [];\n this.ships = [];\n this.enemies = [];\n this.powerups = [];\n //lets add the enemies now\n this.drawText = this.drawText.bind(this);\n this.clearScreen = this.clearScreen.bind(this);\n this.addEnemies = this.addEnemies.bind(this);\n this.addEnemies(1);\n }\n\n add(object) {\n if (object instanceof Bullet) {\n this.bullets.push(object);\n }\n else if (object instanceof Tyran) {\n this.enemies.push(object);\n }\n else if (object instanceof Ship) {\n this.ships.push(object);\n }\n else if (object instanceof PowerUp){\n this.powerups.push(object);\n }\n else {\n throw \"wtf?\";\n }\n }\n\n addPowerUp(){\n var powerupImage = new Image();\n powerupImage.src = \"assets/spaced_out_again.gif\"\n let powerupPos = Math.floor(3*Math.random());\n let allpowerups = [\n {\n srx: 23,\n sry: 3861,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"more_health\",\n isWrappable: true\n },\n {\n srx: 23,\n sry: 3950,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"upgrade_weapon\",\n isWrappable: true\n },\n {\n srx: 23,\n sry: 3906,\n pos: this.poweruprandomPosition(),\n vel: Util.scale([2*Math.random(),2*Math.random()], 1),\n width: 34,\n height: 30,\n game: this,\n image: powerupImage,\n type: \"more_lives\",\n isWrappable: true\n }\n ]\n // console.log(allpowerups[]);\n this.add(new PowerUp(allpowerups[powerupPos]));\n setTimeout(()=> {this.powerups[this.powerups.length-1].remove()}, 11000)\n }\n\n addEnemies(stage) {\n\n switch (stage) {\n case 1:\n this.addsmallEnemies(5);\n this.addbigEnemies(1);\n this.addmediumEnemies(1);\n break;\n case 2:\n this.addsmallEnemies(6);\n this.addbigEnemies(1);\n this.addmediumEnemies(2);\n break;\n case 3:\n this.addsmallEnemies(7);\n this.addbigEnemies(2);\n this.addmediumEnemies(1);\n break;\n case 4:\n this.addboss();\n break;\n }\n }\n\n addboss(){\n var bossimage = new Image();\n bossimage.src = \"assets/tyrianboss.gif\";\n this.add(new Tyran({\n srx: 0,\n sry: 0,\n pos: [0,0],\n mag: 1.8,\n vel: [0,0],\n width: 294,\n height: 282,\n game: this,\n image: bossimage,\n type: \"enemy_ship\",\n lifebar: 100,\n bullettype: 4,\n isWrappable: true\n }));\n }\n\n addsmallEnemies(num){\n var enemyImage = new Image();\n enemyImage.src = \"assets/spaced_out_again_reverse.gif\";\n for (let i = 0; i < num; i++) {\n this.add(new Tyran({\n srx: 530,\n sry: 1998,\n pos: this.enemyrandomPosition(),\n mag: 1.9,\n vel: Util.scale([2*Math.random(),2*Math.random()], 1.9),\n width: 60,\n height: 46,\n game: this,\n image: enemyImage,\n type: \"enemy_ship\",\n lifebar: 5,\n bullettype: 1,\n isWrappable: true\n }));\n }\n }\n\n addbigEnemies(num){\n var enemy_num2 = new Image();\n enemy_num2.src = \"assets/enemy2.png\";\n for (let i = 0; i < num; i++)\n {\n this.add(new Tyran({\n srx: 0,\n sry: 0,\n pos: this.enemyrandomPosition(),\n mag: 1.5,\n vel: Util.scale([2*Math.random(),2*Math.random()], 1.5),\n width: 142,\n height: 117,\n game: this,\n image: enemy_num2,\n type: \"enemy_ship\",\n lifebar: 20,\n bullettype: 3,\n isWrappable: true\n }));\n }\n }\n\n addmediumEnemies(num){\n var enemy_num3 = new Image();\n enemy_num3.src = \"assets/6.png\";\n for (let i = 0; i < num; i++)\n {\n this.add(new Tyran({\n srx: 4,\n sry: 2,\n pos: this.enemyrandomPosition(),\n mag: 1.8,\n vel: Util.scale([2*Math.random(),2*Math.random()], 1.8),\n width: 166,\n height: 100,\n game: this,\n image: enemy_num3,\n type: \"enemy_ship\",\n lifebar: 15,\n bullettype: 2,\n isWrappable: true\n }));\n }\n }\n\n addShip(shiptype) {\n var shipImage = new Image();\n shipImage.src = \"assets/spaced_out_again.gif\";\n\n const ship = new Ship({\n srx: 28,\n sry: 2212,\n pos: [500, 500],\n vel: [0, 0],\n width: 48,\n height: 46,\n game: this,\n image: shipImage,\n type: shiptype,\n isWrappable: false\n });\n\n this.add(ship);\n\n return ship;\n }\n\n allObjects() {\n return [].concat(this.ships, this.bullets, this.enemies, this.powerups);\n }\n\n checkCollisions() {\n const allObjects = this.allObjects();\n for (let i = 0; i < allObjects.length; i++) {\n for (let j = 0; j < allObjects.length; j++) {\n const obj1 = allObjects[i];\n const obj2 = allObjects[j];\n //Everything depends on what type of object it is.\n if (obj1.isCollidedWith(obj2)) {\n //This is a way to end this early because their is only one collision per animation frame.\n const collision = obj1.collideWith(obj2);\n if (collision) return;\n }\n }\n }\n }\n\n //THIS DOES ALL THE WORK OF MOVING ALL THE OBJECTS BEFORE THE NEXT RENDER\n moveObjects(delta, animationFrame) {\n this.allObjects().forEach((object) => {\n object.move(delta, animationFrame, this.ships[0].pos);\n });\n }\n\n drawText(text, ctx){\n ctx.font = text.size + \" \" + text.font;\n ctx.fillStyle = text.color;\n ctx.fillText(`Score: ${text.scorevalue} Health: ${text.health} Lives: ${text.lifevalue}`, text.x, text.y);\n }\n\n clearScreen(ctx){\n ctx.clearRect(0, 0, Game.DIM_X, Game.DIM_Y);\n ctx.fillStyle = Game.BG_COLOR;\n ctx.fillRect(0, 0, Game.DIM_X, Game.DIM_Y);\n }\n\n drawGameOver(ctx){\n this.clearScreen(ctx);\n let finished ={\n x: 370,\n y: 320,\n size: \"50px\",\n font: \"Sans-Serif\",\n color: \"red\"\n }\n ctx.font = finished.size + \" \" + finished.font;\n ctx.fillStyle = finished.color;\n ctx.fillText(\"GAME OVER YOU LOSE\", finished.x, finished.y);\n }\n\n drawNextStage(ctx, stage){\n this.clearScreen(ctx);\n let nxstage ={\n x: 370,\n y: 320,\n size: \"50px\",\n font: \"Sans-Serif\",\n color: \"white\"\n }\n ctx.font = nxstage.size + \" \" + nxstage.font;\n ctx.fillStyle = nxstage.color;\n ctx.fillText(`Stage ${stage} Get Ready`, nxstage.x, nxstage.y);\n }\n\n //We use clear Rect and fillrect to draw over again\n //lets draw up all of the objects on the screen again before we render them again.\n draw(ctx) {\n //canvas clear and fill rect will allow us to clear and re-render.\n this.clearScreen(ctx);\n var imeg = new Image();\n imeg.src = \"assets/shooter_background.jpg\";\n ctx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620);\n this.drawText(this.ships[0].score, ctx);\n // ctx.setTransform(0,1,1,0,1,1)\n this.allObjects().forEach((object) => {\n object.draw(ctx);\n });\n }\n\n isOutOfBounds(pos) {\n return (pos[0] < 0) || (pos[1] < 0) ||\n (pos[0] > Game.DIM_X) || (pos[1] > Game.DIM_Y);\n }\n //Lets take all of our objects and move them based on how they should move and how far\n //they should move\n\n enemyrandomPosition() {\n return [\n Game.DIM_X * Math.random(),\n 0\n ];\n }\n\n poweruprandomPosition() {\n return [\n Game.DIM_X * Math.random(),\n Game.DIM_Y * Math.random()\n ];\n }\n\n randomPosition() {\n return [\n 1200 * Math.random(),\n 500\n ];\n }\n\n remove(object) {\n if (object instanceof Bullet) {\n this.bullets.splice(this.bullets.indexOf(object), 1);\n } else if (object instanceof Tyran) {\n this.enemies.splice(this.enemies.indexOf(object), 1);\n } else if (object instanceof Ship) {\n this.ships.splice(this.ships.indexOf(object), 1);\n }\n else if(object instanceof PowerUp){\n this.powerups.splice(this.powerups.indexOf(object), 1)\n }\n else {\n throw \"wtf?\";\n }\n }\n //Lets hand the animation, then the movement, then the physics to check for collisions.\n step(delta, animationFrame) {\n // this.animateObjects();\n this.animationFrame = animationFrame;\n this.moveObjects(delta, animationFrame);\n this.checkCollisions();\n }\n\n wrap(pos) {\n return [\n Math.random()*Game.DIM_X, 0\n ];\n }\n}\n\nGame.BG_COLOR = \"#000000\";\nGame.DIM_X = 1240;\nGame.DIM_Y = 620;\nGame.FPS = 32;\nGame.NUM_ENEMIES = 4;\n\nmodule.exports = Game;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/game.js\n// module id = 1\n// module chunks = 0","//This contains all the logic for rendering the game\nconst Util = require(\"./util\");\nclass GameView {\n constructor(game, ctx) {\n this.ctx = ctx;\n this.game = game;\n this.animationFrame = 0;\n //We add the ship as soon as the game starts.\n this.ship = this.game.addShip(\"player_ship\");\n // this.animating = this.animating.bind(this);\n this.requestId = undefined;\n // this.stopping = this.stopping.bind(this);\n this.start = this.start.bind(this);\n this.stage = 1;\n this.paused = false;\n this.startmenu = true;\n this.bosslaser = true;\n this.bossmissile = false;\n this.bossorange = false;\n }\n\n drawPaused(){\n this.game.draw(this.ctx);\n this.ctx.font = \"70px Sans-Serif\";\n this.ctx.fillStyle = \"yellow\";\n this.ctx.fillText(\"Tyranny\", 520, 240);\n this.ctx.font = \"50px Sans-Serif\";\n this.ctx.fillStyle = \"white\";\n this.ctx.fillText(\"Controls:\", 550, 310);\n this.ctx.font = \"30px Sans-Serif\";\n this.ctx.fillText(`Space to shoot`, 550, 350);\n this.ctx.fillText(`LUDR Arrows to steer`, 500, 390);\n this.ctx.fillText(`Esc / Enter to pause`, 520, 430);\n this.ctx.fillText(`cmd + r to restart`, 540, 470)\n }\n\n drawVictory(){\n this.game.draw(this.ctx);\n this.ctx.font = \"60px Sans-Serif\";\n this.ctx.fillStyle = \"white\";\n this.ctx.fillText(\"Congratulations You Win!\", 280, 360);\n }\n\n //Lets bind the key handlers that are going to let us handle input from the user.\n bindKeyHandlers() {\n const ship = this.ship;\n let that = this;\n\n Object.keys(GameView.MOVES).forEach((k) => {\n let move = GameView.MOVES[k];\n key(k, () => {\n // console.log(key.isPressed(k));\n ship.direction = k;\n ship.power(move); });\n });\n\n key(\"space\", () => { ship.fireBullet() });\n key(\"esc\", () => {\n if ( !this.paused )\n {\n this.paused = true;\n this.drawPaused();\n this.game.enemies.forEach((enemy) => {\n enemy.vel = [0,0];\n });\n }\n else {\n this.paused = false;\n this.game.enemies.forEach((enemy) => {\n if ( enemy.bullettype !== 4 )\n {\n enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag);\n }\n });\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n })\n key(\"enter\", () => {\n if ( !this.paused )\n {\n this.paused = true;\n this.drawPaused();\n this.game.enemies.forEach((enemy) => {\n enemy.vel = [0,0];\n });\n }\n else {\n this.paused = false;\n this.game.enemies.forEach((enemy) => {\n if ( enemy.bullettype !== 4 )\n {\n enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag);\n }\n });\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n })\n }\n\n // togglepause(){\n // if ( this.requestId )\n // {\n // this.stop();\n // }\n // else\n // {\n // this.requestId = requestAnimationFrame(this.animate.bind(this));\n // }\n // }\n start() {\n this.bindKeyHandlers();\n this.lastTime = 0;\n //start the animation\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }\n\n // stopping(){\n // if ( this.requestId )\n // {\n // console.log(this.requestId);\n // console.log(this.animationFrame);\n // window.cancelAnimationFrame(this.requestId);\n // // key.deleteScope(\"player\");\n // //or null???\n // this.requestId = 0;\n // }\n // else\n // {\n // this.requestId = window.requestAnimationFrame(this.animate.bind(this));\n // // this.setScope(\"player\");\n // }\n // }\n\n // animating(frame){\n // if (!this.paused){\n // window.requestAnimationFrame(this.animate.bind(this));\n // }\n // else{\n // window.cancelAnimationFrame(frame - 1);\n // }\n // }\n\n //This is doing a lot of things. It is determining all the new positions, checking for collisions.\n //Come back here when you are thinking about what is going on.\n //this is a recursive call contantly being made\n\n //animate refers to animating the entire game here.\n animate(time) {\n // if ( this.game.enemies.length === 0 )\n // {\n // this.game.addEnemies(this.stage);\n // }\n if ( this.paused )\n {\n return;\n }\n // window.cancelAnimationFrame(this.requestId);\n // return;\n // // console.log('hi');\n // // return;\n // // window.cancelAnimationFrame(this.requestId);\n // // this.requestId = 0;\n // // this.requestId = window.requestAnimationFrame(this.animate.bind(this));\n // }\n const timeDelta = time - this.lastTime;\n let pressed_keys = key.getPressedKeyCodes()\n if ( pressed_keys.length === 0 )\n {\n this.ship.srx = 28;\n this.ship.sry = 2212;\n this.ship.direction = \"flat\";\n this.ship.flyingFrame = 0;\n this.ship.rightindex = -1;\n this.ship.leftindex = -1;\n this.ship.vel = [0,0];\n }\n if ( this.animationFrame % 277 === 0 )\n {\n this.bosslaser = !this.bosslaser;\n }\n if ( this.animationFrame % 347 === 0 )\n {\n this.bossorange = !this.bossorange;\n }\n if ( this.animationFrame % 67 === 0 )\n {\n this.bossmissile = !this.bossmissile;\n }\n this.game.enemies.forEach((enemy) => {\n if ( enemy.bullettype === 1 && ((this.animationFrame + 30) % 80) === 0 )\n {\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 2 && ((this.animationFrame + 50) % 100) === 0){\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 3){\n enemy.fireBullet();\n }\n else if (enemy.bullettype === 4 && this.bosslaser){\n enemy.fireBullet(\"laser\");\n }\n else if (enemy.bullettype === 4 && this.bossmissile && this.animationFrame % 20 === 0){\n enemy.fireBullet(\"missile\");\n }\n else if (enemy.bullettype === 4 && this.bossorange && this.animationFrame % 20 === 0){\n enemy.fireBullet(\"orange\");\n }\n })\n this.game.step(timeDelta, this.animationFrame);\n this.game.draw(this.ctx);\n //lets reset the time.\n this.lastTime = time;\n this.animationFrame++;\n if ( this.game.ships[0].score.lifevalue === 0 )\n {\n this.game.drawGameOver(this.ctx);\n return;\n }\n //every call to animate requests causes another call to animate\n //repetitive callback\n if ( this.startmenu )\n {\n this.paused = true;\n this.drawPaused();\n this.startmenu = false;\n }\n if ( this.game.enemies.length === 0 )\n {\n this.paused = true;\n this.stage += 1;\n if ( this.stage === 5 )\n {\n this.drawVictory();\n // cancelAnimationFrame(this.requestId);\n return;\n }\n this.game.drawNextStage(this.ctx, this.stage);\n this.game.ships[0].pos = this.game.randomPosition();\n setTimeout(()=> {\n this.paused = false;\n this.game.addEnemies(this.stage);\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }, 4000);\n }\n this.requestId = requestAnimationFrame(this.animate.bind(this));\n }\n}\n\n\nGameView.MOVES = {\n \"up\": [ 0, -9],\n \"left\": [-9, 0],\n \"down\": [ 0, 9],\n \"right\": [ 9, 0]\n};\n\nmodule.exports = GameView;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/game_view.js\n// module id = 2\n// module chunks = 0","const Util = {\n // Normalize the length of the vector to 1, maintaining direction.\n dir (vec) {\n var norm = Util.norm(vec);\n return Util.scale(vec, 1 / norm);\n },\n // Find distance between two points.\n dist (pos1, pos2) {\n return Math.sqrt(\n Math.pow(pos1[0] - pos2[0], 2) + Math.pow(pos1[1] - pos2[1], 2)\n );\n },\n // Find the length of the vector.\n norm (vec) {\n return Util.dist([0, 0], vec);\n },\n\n bossMove(bosspos, playerpos){\n let vector = [playerpos[0] - bosspos[0], 0];\n var normal = Util.norm(vector);\n return Util.scale(vector, 1.7 / normal);\n },\n // Return a randomly oriented vector with the given length.\n randomVec (length) {\n var deg = 2 * Math.PI * Math.random();\n return Util.scale([Math.sin(deg), Math.cos(deg)], length);\n },\n // Scale the length of a vector by the given amount.\n scale (vec, m) {\n return [vec[0] * m, vec[1] * m];\n },\n //This will help the wrapping of objects and will let cetain things go off screen and\n //return back to the screen.\n // wrap (coord, max) {\n // if (coord > max) {\n // return coord % max;\n // } else {\n // return coord;\n // }\n // }\n};\n\nmodule.exports = Util;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/util.js\n// module id = 3\n// module chunks = 0","const Util = require(\"./util\");\n// const PowerUp = require(\"./powerup\");\n\nclass MovingObject {\n constructor(options) {\n this.vel = options.vel;\n this.pos = options.pos;\n this.width = options.width;\n this.height = options.height;\n this.game = options.game;\n this.image = options.image;\n this.type = options.type;\n this.srx = options.srx;\n this.sry = options.sry;\n this.isWrappable = options.isWrappable;\n this.bullettype = options.bullettype;\n //everything this wrappable except for bullets which are not.\n // this.isWrappable = true;\n }\n\n //Basically the handle collision function that will be run if there is a collision.\n collideWith(otherObject) {\n // default do nothing\n }\n\n //Since each object inherits from moving_object, they will all move a certain way\n //that comes from this move method. They can all run the move method. This will come\n //from the step method.\n move(timeDelta, animationFrame, playerpos) {\n //timeDelta is number of milliseconds since last move\n //if the computer is busy the time delta will be larger\n //in this case the MovingObject should move farther in this frame\n //velocity of object is how far it should move in 1/60th of a second\n\n //We should normally move 60 frames in a second, so we are taking a time proportionality\n //of the amount of time delta it took to reach this frame and multiplying by our nomal\n //frame rate so we get movement that is proporitional.\n const velocityScale = timeDelta / NORMAL_FRAME_TIME_DELTA,\n offsetX = this.vel[0] * velocityScale,\n offsetY = this.vel[1] * velocityScale;\n let prevpos = this.pos.slice(0);\n this.pos = [this.pos[0] + offsetX, this.pos[1] + offsetY];\n //This is used to change the direction of the ships randomly\n //lets check if the x and y coords plus the offset will take us out of bounds\n //or not and if they do then we won't allow this. This is good to prevent the ship from goibg\n //across the screen\n if ( this.bullettype !== 4 && this.type === \"enemy_ship\" && animationFrame % 80 === 0 )\n {\n console.log('hi');\n this.vel = Util.scale([4*Math.random()-2,2*Math.random()], this.mag);\n }\n if ( this.bullettype === 4 && animationFrame % 400 === 0 )\n {\n this.vel = Util.bossMove(this.pos, playerpos);\n }\n if ( this.bullettype === 4 && animationFrame % 193 === 0 )\n {\n this.vel = Util.scale([4*Math.random() - 2, 0], 2);\n }\n if (this.game.isOutOfBounds(this.pos)) {\n if (this.isWrappable) {\n this.pos = this.game.wrap(this.pos);\n } else if (!this.isWrappable && (this.type === \"player_ship\"))\n {\n this.pos = prevpos;\n }\n else\n {\n this.remove();\n }\n }\n\n }\n //MOVE AND THEN DRAW\n //This draw method will help to draw a circle to the screen.\n draw(ctx) {\n ctx.fillStyle = this.color;\n //beginpath pretty much just lets us start the canvas drawing.\n ctx.beginPath();\n if ( [\"player_ship\", \"more_health\", \"upgrade_weapon\", \"more_lives\"].includes(this.type) )\n {\n this.grabAnimation();\n }\n ctx.drawImage(this.image, this.srx, this.sry, this.width, this.height, this.pos[0], this.pos[1], this.width, this.height);\n // ctx.arc( // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true\n // );\n ctx.fill();\n }\n\n //A better thing to do is to check for box collision since we won't be using circles.\n isCollidedWith(otherObject) {\n let x1 = this.pos[0];\n let y1 = this.pos[1];\n let w1 = this.width;\n let h1 = this.height;\n let x2 = otherObject.pos[0];\n let y2 = otherObject.pos[1];\n let w2 = otherObject.width;\n let h2 = otherObject.height;\n return !(x1 + w1 < x2 || x1 > x2 + w2 || y1 > y2 + h2 || y1 + h1 < y2);\n }\n\n\n remove() {\n this.game.remove(this);\n }\n}\n\nconst NORMAL_FRAME_TIME_DELTA = 1000/60;\n\nmodule.exports = MovingObject;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/moving_object.js\n// module id = 4\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\n\nclass Bullet extends MovingObject {\n constructor(options) {\n options.image = options.image;\n options.type = options.type;\n options.width = options.width;\n options.height = options.height;\n super(options);\n //Everything else will be the same as moving object\n //we don't want it to go offscreen and come back on screen.\n\n this.power = options.power;\n }\n}\n\nBullet.SPEED = 15;\n\nmodule.exports = Bullet;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/bullet.js\n// module id = 5\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\nconst Bullet = require(\"./bullet\");\nconst Util = require(\"./util\");\n\nclass Ship extends MovingObject {\n constructor(options) {\n // start with velocity of 0\n options.pos = options.pos;\n options.vel = options.vel;\n options.width = options.width;\n options.height = options.height;\n options.game = options.game;\n options.type = options.type;\n options.image = options.image;\n super(options);\n this.score = {\n scorevalue: 0,\n lifevalue: 4,\n health: 100,\n x: 800,\n y: 50,\n size: \"25px\",\n font: \"Sans-Serif\",\n color: \"#42f445\"\n }\n this.direction = \"flat\";\n this.flyingFrame = 0;\n this.rightFrames = [[192,2255], [247, 2256], [303,2257], [468,2258]];\n this.leftFrames = [[200,2208], [305, 2207], [416,2208], [523,2207]];\n this.rightindex = -1;\n this.leftindex = -1;\n this.grabAnimation = this.grabAnimation.bind(this);\n this.bulletpower = 1;\n this.bullettype = 1;\n }\n\n grabAnimation(){\n let that = this;\n if ( that.direction === \"right\" )\n {\n if (that.flyingFrame % 3 === 0){\n that.rightindex += 1;\n if ( that.rightindex >= that.rightFrames.length ){\n return;\n }\n that.srx = that.rightFrames[that.rightindex][0];\n that.sry = that.rightFrames[that.rightindex][1];\n }\n that.flyingFrame += 1;\n }\n else if (that.direction === \"left\")\n {\n if (that.flyingFrame % 3 === 0){\n that.leftindex += 1;\n if ( that.leftindex >= that.leftFrames.length )\n {\n return;\n }\n that.srx = that.leftFrames[that.leftindex][0];\n that.sry = that.leftFrames[that.leftindex][1];\n }\n that.flyingFrame++;\n }\n // this.direction = \"flat\";\n }\n\n collideWith(otherObject) {\n if (otherObject.type === \"enemy_bullet\") {\n // otherObject.takeDamage();\n this.score.health -= otherObject.power;\n if ( this.score.health <= 0 )\n {\n this.score.lifevalue -= 1;\n this.score.health = 100;\n this.bullettype = 1;\n this.bulletpower = 1;\n this.relocate();\n }\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"more_health\"){\n this.score.health += 50;\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"upgrade_weapon\"){\n this.bulletpower += 1;\n this.bullettype += 1;\n otherObject.remove();\n return true;\n }\n else if (otherObject.type === \"more_lives\"){\n this.score.lifevalue += 1;\n otherObject.remove();\n return true;\n }\n }\n\n fireBullet() {\n // const norm = Util.norm([0,this.vel[1]]);\n //change this in your game because you will be able to fire even if you are moving\n // if (norm == 0) {\n // // Can't fire unless moving.\n // return;\n // }\n //GET THE RELATIVE VELOCITY TO THE SHIP FROM THE DIRECTION AND THE SPEED\n const relVel = Util.scale(\n Util.dir([0, -1]),\n Bullet.SPEED\n );\n\n const bulletVel = [\n 0, relVel[1] + this.vel[1]\n ];\n //MOVE THIS\n var bullet_image = new Image();\n bullet_image.src = \"assets/spaced_out_again_reverse.gif\";\n var second = new Image();\n let bullet;\n second.src = \"assets/spaced_out_again.gif\";\n if (this.bullettype === 1){\n bullet = new Bullet({\n srx: 449,\n sry: 1270,\n pos: [this.pos[0] + 14, this.pos[1] - 63],\n vel: bulletVel,\n width: 21,\n height: 77,\n game: this.game,\n image: bullet_image,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n else if (this.bullettype === 2){\n bullet = new Bullet({\n srx: 113,\n sry: 3520,\n pos: [this.pos[0] + 14, this.pos[1] - 53],\n vel: bulletVel,\n width: 45,\n height: 66,\n game: this.game,\n image: second,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n else if (this.bullettype >= 3){\n bullet = new Bullet({\n srx: 539,\n sry: 2986,\n pos: [this.pos[0] + 14, this.pos[1] - 53],\n vel: bulletVel,\n width: 31,\n height: 97,\n game: this.game,\n image: second,\n type: \"bullet\",\n power: this.bulletpower\n });\n }\n\n this.game.add(bullet);\n }\n//Power and then move the object\n power(impulse) {\n this.vel[0] = impulse[0];\n this.vel[1] = impulse[1];\n }\n\n relocate() {\n this.pos = this.game.randomPosition();\n this.vel = [0, 0];\n }\n}\n\nmodule.exports = Ship;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/ship.js\n// module id = 6\n// module chunks = 0","const Util = require(\"./util\");\nconst MovingObject = require(\"./moving_object\");\nconst Ship = require(\"./ship\");\nconst Bullet = require(\"./bullet\");\n\nconst DEFAULTS = {\n\tSPEED: 1\n};\n\nclass Tyran extends MovingObject {\n constructor(options = {}) {\n options.game = options.game;\n options.width = options.width;\n options.height = options.height;\n options.pos = options.pos;\n options.vel = options.vel;\n options.image = options.image;\n options.type = options.type;\n super(options);\n this.lifebar = options.lifebar;\n\t\t\tthis.mag = options.mag;\n\t\t\t// this.bullettype = options.bullettype;\n }\n //Make the logic for getting hurt by bullets here.\n //Our ship is currently just relocating when it gets hit\n collideWith(otherObject) {\n if (otherObject instanceof Ship) {\n // otherObject.takeDamage();\n\t\t\t\totherObject.score.health -= 50;\n\t\t\t\tthis.pos = this.game.enemyrandomPosition();\n\t if ( otherObject.score.health <= 0 )\n\t {\n\t otherObject.score.lifevalue -= 1;\n\t otherObject.score.health = 100;\n\t otherObject.bullettype = 1;\n\t otherObject.bulletpower = 1;\n\t otherObject.relocate();\n\t }\n\t\t\t\t// otherObject.bullettype = 1;\n\t\t\t\t// otherObject.bulletpower = 1;\n // otherObject.relocate();\n return true;\n } else if (otherObject.type === \"bullet\") {\n\t\t\t\t\t\tthis.lifebar -= otherObject.power;\n\t\t\t\t\t\totherObject.remove();\n\t\t\t\t\t\tif (this.lifebar <= 0){\n\t this.game.ships[0].score.scorevalue += 100;\n\t this.remove();\n\t\t\t\t\t\t\tif (this.game.enemies.length % 4 === 0){\n\t\t\t\t\t\t\t\tthis.game.addPowerUp();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n return true;\n }\n }\n\n fireBullet(firetype) {\n // const norm = Util.norm([0,this.vel[1]]);\n //change this in your game because you will be able to fire even if you are moving\n // if (norm == 0) {\n // // Can't fire unless moving.\n // return;\n // }\n //GET THE RELATIVE VELOCITY TO THE SHIP FROM THE DIRECTION AND THE SPEED\n const relVel = Util.scale(\n Util.dir([0, 1]),\n 2\n );\n\n const bulletVel = [\n 0, relVel[1] + this.vel[1]\n ];\n //MOVE THIS\n var enemy_bullet_image = new Image();\n enemy_bullet_image.src = \"assets/spaced_out_again_reverse.gif\";\n\t\t\tvar big_enemy_bullet_image = new Image();\n\t\t\tbig_enemy_bullet_image.src = \"assets/laserbeam.gif\";\n\t\t\tswitch(this.bullettype){\n\t\t\t\tcase 1:\n\t\t this.game.add(new Bullet({\n\t\t srx: 425,\n\t\t sry: 1103,\n\t\t pos: [this.pos[0] + 14, this.pos[1] + 40],\n\t\t width: 28,\n\t\t height: 30,\n\t\t vel: bulletVel,\n\t\t game: this.game,\n\t\t type: \"enemy_bullet\",\n\t\t image: enemy_bullet_image,\n\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\tisWrappable: false\n\t\t }))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\tpos: [this.pos[0] + 24, this.pos[1] + 40],\n\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\tpos: [this.pos[0] + 150, this.pos[1] + 40],\n\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\tsrx: 83,\n\t\t\t\t\t\tsry: 55,\n\t\t\t\t\t\tpos: [this.pos[0] + 48, this.pos[1] + 80],\n\t\t\t\t\t\twidth: 42,\n\t\t\t\t\t\theight: 20,\n\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\timage: big_enemy_bullet_image,\n\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t}))\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tif ( firetype === \"laser\" )\n\t\t\t\t\t{\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 83,\n\t\t\t\t\t\t\tsry: 55,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 120, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 42,\n\t\t\t\t\t\t\theight: 20,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: big_enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 20,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if( firetype === \"missile\"){\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 70, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 141,\n\t\t\t\t\t\t\tsry: 1552,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 250, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 27,\n\t\t\t\t\t\t\theight: 69,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 30,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if( firetype === \"orange\"){\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 70, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 120, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tthis.game.add(new Bullet({\n\t\t\t\t\t\t\tsrx: 425,\n\t\t\t\t\t\t\tsry: 1103,\n\t\t\t\t\t\t\tpos: [this.pos[0] + 250, this.pos[1] + 240],\n\t\t\t\t\t\t\twidth: 28,\n\t\t\t\t\t\t\theight: 30,\n\t\t\t\t\t\t\tvel: bulletVel,\n\t\t\t\t\t\t\tgame: this.game,\n\t\t\t\t\t\t\ttype: \"enemy_bullet\",\n\t\t\t\t\t\t\timage: enemy_bullet_image,\n\t\t\t\t\t\t\tpower: 10,\n\t\t\t\t\t\t\tisWrappable: false\n\t\t\t\t\t\t}))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t}\n //You want the game to have knowledge of this bullet\n // this.game.add(bullet);\n }\n}\n\nmodule.exports = Tyran;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/tyran.js\n// module id = 7\n// module chunks = 0","const MovingObject = require(\"./moving_object\");\n\nclass PowerUp extends MovingObject {\n constructor(options = {}){\n super(options);\n this.isWrappable = true;\n this.spinFrame = 0;\n this.animationstates = [];\n for (let i = 0; i < 16; i++)\n {\n this.animationstates.push([this.srx + this.width * i, this.sry]);\n }\n this.animindex = 0;\n }\n\n grabAnimation(){\n let that = this;\n if (that.spinFrame % 4 === 0){\n if ( that.animindex === 16 ){\n that.animindex = 0;\n }\n that.srx = that.animationstates[that.animindex][0];\n that.sry = that.animationstates[that.animindex][1];\n that.animindex += 1;\n }\n that.spinFrame++;\n }\n}\n\n\nmodule.exports = PowerUp;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/powerup.js\n// module id = 8\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/lib/game.js b/lib/game.js index f9080c0..b4ed9a8 100644 --- a/lib/game.js +++ b/lib/game.js @@ -88,19 +88,19 @@ class Game { switch (stage) { case 1: - this.addsmallEnemies(3); + this.addsmallEnemies(5); this.addbigEnemies(1); this.addmediumEnemies(1); break; case 2: - this.addsmallEnemies(4); + this.addsmallEnemies(6); this.addbigEnemies(1); this.addmediumEnemies(2); break; case 3: - this.addsmallEnemies(6); + this.addsmallEnemies(7); this.addbigEnemies(2); - this.addmediumEnemies(2); + this.addmediumEnemies(1); break; case 4: this.addboss(); @@ -116,7 +116,7 @@ class Game { sry: 0, pos: [0,0], mag: 1.8, - vel: Util.scale([4*Math.random() - 2,0], 1.8), + vel: [0,0], width: 294, height: 282, game: this, @@ -136,14 +136,14 @@ class Game { srx: 530, sry: 1998, pos: this.enemyrandomPosition(), - mag: 2.3, - vel: Util.scale([2*Math.random(),2*Math.random()], 2.3), + mag: 1.9, + vel: Util.scale([2*Math.random(),2*Math.random()], 1.9), width: 60, height: 46, game: this, image: enemyImage, type: "enemy_ship", - lifebar: 3, + lifebar: 5, bullettype: 1, isWrappable: true })); @@ -182,14 +182,14 @@ class Game { srx: 4, sry: 2, pos: this.enemyrandomPosition(), - mag: 2, - vel: Util.scale([2*Math.random(),2*Math.random()], 2), + mag: 1.8, + vel: Util.scale([2*Math.random(),2*Math.random()], 1.8), width: 166, height: 100, game: this, image: enemy_num3, type: "enemy_ship", - lifebar: 10, + lifebar: 15, bullettype: 2, isWrappable: true })); @@ -241,7 +241,7 @@ class Game { //THIS DOES ALL THE WORK OF MOVING ALL THE OBJECTS BEFORE THE NEXT RENDER moveObjects(delta, animationFrame) { this.allObjects().forEach((object) => { - object.move(delta, animationFrame); + object.move(delta, animationFrame, this.ships[0].pos); }); } @@ -263,7 +263,7 @@ class Game { x: 370, y: 320, size: "50px", - font: "PixelEmulator", + font: "Sans-Serif", color: "red" } ctx.font = finished.size + " " + finished.font; @@ -277,7 +277,7 @@ class Game { x: 370, y: 320, size: "50px", - font: "PixelEmulator", + font: "Sans-Serif", color: "white" } ctx.font = nxstage.size + " " + nxstage.font; @@ -292,7 +292,7 @@ class Game { this.clearScreen(ctx); var imeg = new Image(); imeg.src = "assets/shooter_background.jpg"; - ctx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650); + ctx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620); this.drawText(this.ships[0].score, ctx); // ctx.setTransform(0,1,1,0,1,1) this.allObjects().forEach((object) => { @@ -359,8 +359,8 @@ class Game { } Game.BG_COLOR = "#000000"; -Game.DIM_X = 1250; -Game.DIM_Y = 650; +Game.DIM_X = 1240; +Game.DIM_Y = 620; Game.FPS = 32; Game.NUM_ENEMIES = 4; diff --git a/lib/game_view.js b/lib/game_view.js index 78e7417..415a671 100644 --- a/lib/game_view.js +++ b/lib/game_view.js @@ -21,22 +21,22 @@ class GameView { drawPaused(){ this.game.draw(this.ctx); - this.ctx.font = "70px PixelEmulator"; + this.ctx.font = "70px Sans-Serif"; this.ctx.fillStyle = "yellow"; this.ctx.fillText("Tyranny", 520, 240); - this.ctx.font = "50px PixelEmulator"; + this.ctx.font = "50px Sans-Serif"; this.ctx.fillStyle = "white"; this.ctx.fillText("Controls:", 550, 310); - this.ctx.font = "30px PixelEmulator"; + this.ctx.font = "30px Sans-Serif"; this.ctx.fillText(`Space to shoot`, 550, 350); this.ctx.fillText(`LUDR Arrows to steer`, 500, 390); this.ctx.fillText(`Esc / Enter to pause`, 520, 430); - this.ctx.fillText(`ctrl + r to restart`, 540, 470) + this.ctx.fillText(`cmd + r to restart`, 540, 470) } drawVictory(){ this.game.draw(this.ctx); - this.ctx.font = "60px PixelEmulator"; + this.ctx.font = "60px Sans-Serif"; this.ctx.fillStyle = "white"; this.ctx.fillText("Congratulations You Win!", 280, 360); } @@ -67,7 +67,10 @@ class GameView { else { this.paused = false; this.game.enemies.forEach((enemy) => { - enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + if ( enemy.bullettype !== 4 ) + { + enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + } }); } this.requestId = requestAnimationFrame(this.animate.bind(this)); @@ -84,7 +87,10 @@ class GameView { else { this.paused = false; this.game.enemies.forEach((enemy) => { - enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + if ( enemy.bullettype !== 4 ) + { + enemy.vel = Util.scale([2*Math.random(),2*Math.random()], enemy.mag); + } }); } this.requestId = requestAnimationFrame(this.animate.bind(this)); diff --git a/lib/moving_object.js b/lib/moving_object.js index 057df2e..f03f2ca 100644 --- a/lib/moving_object.js +++ b/lib/moving_object.js @@ -26,7 +26,7 @@ class MovingObject { //Since each object inherits from moving_object, they will all move a certain way //that comes from this move method. They can all run the move method. This will come //from the step method. - move(timeDelta, animationFrame) { + move(timeDelta, animationFrame, playerpos) { //timeDelta is number of milliseconds since last move //if the computer is busy the time delta will be larger //in this case the MovingObject should move farther in this frame @@ -44,13 +44,18 @@ class MovingObject { //lets check if the x and y coords plus the offset will take us out of bounds //or not and if they do then we won't allow this. This is good to prevent the ship from goibg //across the screen - if ( !this.bullettype === 4 && this.type === "enemy_ship" && animationFrame % 80 === 0 ) + if ( this.bullettype !== 4 && this.type === "enemy_ship" && animationFrame % 80 === 0 ) { - this.vel = Util.scale([2*Math.random(),2*Math.random()], this.mag); + console.log('hi'); + this.vel = Util.scale([4*Math.random()-2,2*Math.random()], this.mag); } - if ( this.bullettype === 4 && animationFrame % 40 === 0 ) + if ( this.bullettype === 4 && animationFrame % 400 === 0 ) { - this.vel = Util.scale([4*Math.random() - 2, 0], this.mag); + this.vel = Util.bossMove(this.pos, playerpos); + } + if ( this.bullettype === 4 && animationFrame % 193 === 0 ) + { + this.vel = Util.scale([4*Math.random() - 2, 0], 2); } if (this.game.isOutOfBounds(this.pos)) { if (this.isWrappable) { @@ -77,8 +82,7 @@ class MovingObject { this.grabAnimation(); } ctx.drawImage(this.image, this.srx, this.sry, this.width, this.height, this.pos[0], this.pos[1], this.width, this.height); - // ctx.arc( - // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true + // ctx.arc( // this.pos[0], this.pos[1], this.radius, 0, 2 * Math.PI, true // ); ctx.fill(); } diff --git a/lib/ship.js b/lib/ship.js index 73cfc84..0e67a69 100644 --- a/lib/ship.js +++ b/lib/ship.js @@ -17,10 +17,10 @@ class Ship extends MovingObject { scorevalue: 0, lifevalue: 4, health: 100, - x: 850, + x: 800, y: 50, size: "25px", - font: "PixelEmulator", + font: "Sans-Serif", color: "#42f445" } this.direction = "flat"; diff --git a/lib/tyran.js b/lib/tyran.js index e939974..3fe99ac 100644 --- a/lib/tyran.js +++ b/lib/tyran.js @@ -46,7 +46,7 @@ class Tyran extends MovingObject { if (this.lifebar <= 0){ this.game.ships[0].score.scorevalue += 100; this.remove(); - if (this.game.enemies.length % 3 === 0){ + if (this.game.enemies.length % 4 === 0){ this.game.addPowerUp(); } } diff --git a/lib/tyranny.js b/lib/tyranny.js index f01955d..40f9d7a 100644 --- a/lib/tyranny.js +++ b/lib/tyranny.js @@ -9,7 +9,7 @@ document.addEventListener("DOMContentLoaded", function(){ const fgCtx = fgCanvas.getContext("2d"); var imeg = new Image(); imeg.src = "assets/shooter_background.jpg"; - fgCtx.drawImage(imeg,0,0,1250,650,0, 0,1250, 650); + fgCtx.drawImage(imeg,0,0,1240,620,0, 0,1240, 620); //lets initialize a new game const game = new Game(); new GameView(game, fgCtx).start(); diff --git a/lib/util.js b/lib/util.js index e122dc5..7e74902 100644 --- a/lib/util.js +++ b/lib/util.js @@ -14,6 +14,12 @@ const Util = { norm (vec) { return Util.dist([0, 0], vec); }, + + bossMove(bosspos, playerpos){ + let vector = [playerpos[0] - bosspos[0], 0]; + var normal = Util.norm(vector); + return Util.scale(vector, 1.7 / normal); + }, // Return a randomly oriented vector with the given length. randomVec (length) { var deg = 2 * Math.PI * Math.random();