From 51749cba47830947068a6a406fb111233baf9493 Mon Sep 17 00:00:00 2001 From: jclayborn Date: Mon, 5 Oct 2020 15:58:33 -0500 Subject: [PATCH 1/4] consolodate reset level logic into one place --- scripts/levels.js | 201 +++++++++++----------------------------------- 1 file changed, 49 insertions(+), 152 deletions(-) diff --git a/scripts/levels.js b/scripts/levels.js index 6b8aea5..bec8468 100644 --- a/scripts/levels.js +++ b/scripts/levels.js @@ -1,10 +1,10 @@ -var mirrors = []; -var CircMirrors = []; //n -var init = false; -var mirrorCount; -var CircMirrorCount = 0; //n -var mirrorDrag = []; -var CircMirrorDrag = []; //n +var mirrors = []; +var CircMirrors = []; +var init = false; +var mirrorCount; +var CircMirrorCount = 0; +var mirrorDrag = []; +var CircMirrorDrag = []; var minutes = 0; var seconds = 0; var runtime = 0; @@ -12,8 +12,8 @@ var mark = false; var ex; var ey = 100; var enemyDestroyed = false; -var a = []; -var a1 = []; +var a = []; +var a1 = []; var gameOver = false; var eh = 100; var fh; @@ -28,28 +28,31 @@ var v5 = 0.73; var v6 = 0.73; var v7 = 0.73; var v8 = 0.73; -var v10= 1.26;var v11= 0.3937;var v12= 0.3937;var v13= 1.26; -var v21= 1.2; var v22= 1.2; +var v10= 1.26;var v11= 0.3937;var v12= 0.3937;var v13= 1.26; +var v21= 1.2; var v22= 1.2; var ss = []; var epsilon = .01; +const resetLevel = () => { + mirrors = []; + mirrorDrag = []; + CircMirrors = []; + a1 = []; + CircMirrorDrag = []; + a = []; + ss = []; + minutes = 0; + seconds = 0; + runtime = 0; + enemyDestroyed = false; +} + function initialiseLevel() { if(levelNumber == 1) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - a1 = []; - CircMirrorDrag = []; - a = []; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; - //gameOver = false; + resetLevel(); ex = width-140*(width/1220); ey = 100*(width/1220); eh = 100; @@ -100,17 +103,7 @@ function initialiseLevel() } else if(levelNumber == 2) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); ex = 20*(width/1220); ey = 120*(width/1220); eh = 100*(width/1220); @@ -162,17 +155,8 @@ function initialiseLevel() } else if(levelNumber == 3) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = width-300*(width/1220); ey = 20*(width/1220); eh = 100; @@ -215,16 +199,8 @@ function initialiseLevel() } else if(levelNumber == 4) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; + resetLevel(); + enemyDestroyed = false; ex = midx-60*(width/1220); ey = 60*(width/1220); @@ -308,17 +284,8 @@ function initialiseLevel() } else if(levelNumber == 5) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss= []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = 10*(width/1220); ey = 90*(width/1220); eh = 100; @@ -387,17 +354,8 @@ function initialiseLevel() } else if(levelNumber == 6) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = 10*(width/1220); ey = 90*(width/1220); eh = 100; @@ -486,17 +444,8 @@ function initialiseLevel() else if(levelNumber == 7) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; //n - CircMirrorDrag = []; - a = []; - a1 =[]; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = (width/1220); // ex,ey is the position of enemytriangle ey = 250*(width/1220); eh = 100; @@ -574,17 +523,8 @@ function initialiseLevel() else if(levelNumber == 8) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 =[]; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = (width/1220); ey = 525*(width/1220); eh = 100; @@ -677,17 +617,8 @@ function initialiseLevel() } else if(levelNumber == 9) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - a1 = []; - CircMirrorDrag = []; - a = []; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = -15*(width/1220); ey = 520*(width/1220); eh = 100; @@ -762,17 +693,8 @@ function initialiseLevel() } else if(levelNumber == 10) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 = []; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = width-90*(width/1220); ey = 250*(width/1220); eh = 100; @@ -866,17 +788,8 @@ function initialiseLevel() } else if(levelNumber == 11) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - CircMirrorDrag = []; - a = []; - a1 = []; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = width-110*(width/1220); ey = 515*(width/1220); eh = 100; @@ -1018,17 +931,8 @@ function initialiseLevel() } else if(levelNumber == 12) { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - a1 = []; - CircMirrorDrag = []; - a = []; - ss =[]; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + ex = 450*(width/1220); ey = 250*(width/1220); eh = 100; @@ -1132,15 +1036,8 @@ function initialiseLevel() } else { - mirrors = []; - mirrorDrag = []; - a = []; - a1 =[]; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; + resetLevel(); + mirrorCount = mirrors.length; CircMirrorCount = CircMirrors.length; GC = true; From 6d27cc6245386895d6aed7c9233ef19b725d0175 Mon Sep 17 00:00:00 2001 From: jclayborn Date: Mon, 5 Oct 2020 16:39:10 -0500 Subject: [PATCH 2/4] consolidate build space ship and width calc that is the same everywhere for spaceships --- scripts/levels.js | 187 +++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 101 deletions(-) diff --git a/scripts/levels.js b/scripts/levels.js index bec8468..117ca0f 100644 --- a/scripts/levels.js +++ b/scripts/levels.js @@ -47,22 +47,30 @@ const resetLevel = () => { enemyDestroyed = false; } +const buildSpaceship = (x, y) => { + ss.push({ + x, + y, + fh: 100 + }) +} + function initialiseLevel() { + const basicSSWidthCalc = (width / 1220) + if(levelNumber == 1) { resetLevel(); ex = width-140*(width/1220); ey = 100*(width/1220); eh = 100; + + const ssx = midx - 70 * basicSSWidthCalc + const ssy = 100 * basicSSWidthCalc + buildSpaceship(ssx, ssy) - mySpacestation = { - x: midx-70*(width/1220), - y: 100*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); myMirror = { x: 200*(width/1220), width: 100*(width/1220), @@ -107,12 +115,11 @@ function initialiseLevel() ex = 20*(width/1220); ey = 120*(width/1220); eh = 100*(width/1220); - mySpacestation = { - x: midx+100*(width/1220), - y: 60*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = midx + 100 * basicSSWidthCalc + ssy = 60 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 200*(width/1220), width: 0*(width/1220), @@ -160,12 +167,11 @@ function initialiseLevel() ex = width-300*(width/1220); ey = 20*(width/1220); eh = 100; - mySpacestation = { - x: midx*(3/2)*(width/1220), - y: 200*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = midx * (3 / 2) * basicSSWidthCalc + ssy = 200 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 200*(width/1220), width: 0*(width/1220), @@ -205,12 +211,11 @@ function initialiseLevel() ex = midx-60*(width/1220); ey = 60*(width/1220); eh = 100; - mySpacestation = { - x: midx-20*(width/1220), - y: midy-40*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = midx - 20 * basicSSWidthCalc + ssy = midy - 40 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 200*(width/1220), width: 0*(width/1220), @@ -289,12 +294,11 @@ function initialiseLevel() ex = 10*(width/1220); ey = 90*(width/1220); eh = 100; - mySpacestation = { - x: 180*(width/1220), - y: midy-40*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = 180 * basicSSWidthCalc, + ssy = midy - 40 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 150*(width/1220), width: 100*(width/1220), @@ -359,12 +363,11 @@ function initialiseLevel() ex = 10*(width/1220); ey = 90*(width/1220); eh = 100; - mySpacestation = { - x: midx, - y: midy-230*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = midx + ssy - midy - 230 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 250*(width/1220), width: 100*(width/1220), @@ -448,13 +451,12 @@ function initialiseLevel() ex = (width/1220); // ex,ey is the position of enemytriangle ey = 250*(width/1220); - eh = 100; - mySpacestation = { - x: midx-400*(width/1220), - y: 55*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + eh = 100; + + ssx = midx - 400 * basicSSWidthCalc + ssy = 55 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 700*(width/1220), width: -15*(width/1220), @@ -528,12 +530,11 @@ function initialiseLevel() ex = (width/1220); ey = 525*(width/1220); eh = 100; - mySpacestation = { - x: midx-70*(width/1220), - y: 250*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + + ssx = midx - 70 * basicSSWidthCalc + ssy = 250 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 200*(width/1220), width: -18*(width/1220), @@ -622,19 +623,15 @@ function initialiseLevel() ex = -15*(width/1220); ey = 520*(width/1220); eh = 100; + + ssx = 13 * basicSSWidthCalc + ssy = 90 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + + ssx = 1067 * basicSSWidthCalc + ssy = 90 * basicSSWidthCalc + buildSpaceship(ssx, ssy) - mySpacestation = { - x: 13*(width/1220), - y: 90*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); - mySpacestation = { - x: 1067*(width/1220), - y: 90*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); myMirror = { x: 350*(width/1220), width: 17*(width/1220), @@ -697,20 +694,16 @@ function initialiseLevel() ex = width-90*(width/1220); ey = 250*(width/1220); - eh = 100; - mySpacestation = { - x: midx+370*(width/1220), - y: 200*(width/1220), - fh: 100 - }; - - ss.push(mySpacestation); - mySpacestation = { - x: 370*(width/1220), - y: 100*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); + eh = 100; + + ssx = midx + 370 * (width /1220) + ssy = 200 * (width / 122) + buildSpaceship(ssx, ssy) + + ssx = 370 * basicSSWidthCalc + ssy = 100 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + myMirror = { x: 380*(width/1220), width: 100*(width/1220), @@ -792,26 +785,20 @@ function initialiseLevel() ex = width-110*(width/1220); ey = 515*(width/1220); - eh = 100; + eh = 100; + + ssx = 1 * basicSSWidthCalc + ssy = 270 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + + ssx = 210 * basicSSWidthCalc + ssy = 30 * basicSSWidthCalc + buildSpaceship(ssx, ssy) + + ssx = (1080) * basicSSWidthCalc + ssy = 30 * basicSSWidthCalc + buildSpaceship(ssx, ssy) - mySpacestation = { - x: 1*(width/1220), - y: 270*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); - mySpacestation = { - x: 210*(width/1220), - y: 30*(width/1220), - fh: 100 - }; - ss.push(mySpacestation) - mySpacestation = { - x: (1080)*(width/1220), - y: 240*(width/1220), - fh: 100 - }; - ss.push(mySpacestation) myMirror = { x: 1135*(width/1220), width: 70*(width/1220), @@ -935,14 +922,12 @@ function initialiseLevel() ex = 450*(width/1220); ey = 250*(width/1220); - eh = 100; + eh = 100; + + ssx = 630 * basicSSWidthCalc + ssy = 335 * basicSSWidthCalc + buildSpaceship(ssx, ssy) - mySpacestation = { - x: 630*(width/1220), - y: 335*(width/1220), - fh: 100 - }; - ss.push(mySpacestation); myMirror = { x: 800*(width/1220), width: 11*(width/1220), From f933e0952f23d9f11651ae2cf3641b0688f67779 Mon Sep 17 00:00:00 2001 From: jclayborn Date: Tue, 6 Oct 2020 09:07:16 -0500 Subject: [PATCH 3/4] build asteroid function, and build mirror function --- scripts/levels.js | 1498 ++++++++++++++++++++------------------------- 1 file changed, 661 insertions(+), 837 deletions(-) diff --git a/scripts/levels.js b/scripts/levels.js index 117ca0f..884364e 100644 --- a/scripts/levels.js +++ b/scripts/levels.js @@ -33,174 +33,169 @@ var v21= 1.2; var v22= 1.2; var ss = []; var epsilon = .01; -const resetLevel = () => { - mirrors = []; - mirrorDrag = []; - CircMirrors = []; - a1 = []; - CircMirrorDrag = []; - a = []; - ss = []; - minutes = 0; - seconds = 0; - runtime = 0; - enemyDestroyed = false; -} - -const buildSpaceship = (x, y) => { - ss.push({ - x, - y, - fh: 100 - }) -} - - function initialiseLevel() { - const basicSSWidthCalc = (width / 1220) + const basicWidthCalc = (width / 1220) + const resetLevel = () => { + mirrors = []; + mirrorDrag = []; + CircMirrors = []; + a1 = []; + CircMirrorDrag = []; + a = []; + ss = []; + minutes = 0; + seconds = 0; + runtime = 0; + enemyDestroyed = false; + mirrorCount = 0; + CircMirrorCount = 0; + } + const buildSpaceship = (x, y) => { + ss.push({ + x: x, + y: y, + fh: 100 + }) + } + const buildMirror = (x, width, y, height, drag, dragBool) => { + const mirror = { + x: x, + width: width, + y: y, + height: height, + drag: drag + } + mirrors.push(mirror) + mirrorDrag.push(dragBool) + mirrorCount = mirrors.length; + } + + const buildAsteroid = (x, y, moving) => { + console.log('moving? ', moving) + moving ? a1.push({x1: x, y1: y}) : a.push({x, y}) + } if(levelNumber == 1) { resetLevel(); - ex = width-140*(width/1220); - ey = 100*(width/1220); + ex = width-140*basicWidthCalc; + ey = 100*basicWidthCalc; eh = 100; - const ssx = midx - 70 * basicSSWidthCalc - const ssy = 100 * basicSSWidthCalc + ssx = midx - 70 * basicWidthCalc + ssy = 100 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 200*(width/1220), - width: 100*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 100*(width/1220), - y: 400*(width/1220), - height: -100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 1000*(width/1220), - y: 100*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1000*(width/1220), - y: 200*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1100*(width/1220), - y: 240*(width/1220) - }; - a.push(myAsteroid); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + mX = 200*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 400*basicWidthCalc + mHeight = -100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 1000*basicWidthCalc + asteroidY = 100*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1000*basicWidthCalc + asteroidY = 200*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1100*basicWidthCalc + asteroidY = 240*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) init = true; } else if(levelNumber == 2) { resetLevel(); - ex = 20*(width/1220); - ey = 120*(width/1220); - eh = 100*(width/1220); + ex = 20*basicWidthCalc; + ey = 120*basicWidthCalc; + eh = 100*basicWidthCalc; - ssx = midx + 100 * basicSSWidthCalc - ssy = 60 * basicSSWidthCalc + ssx = midx + 100 * basicWidthCalc + ssy = 60 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 200*(width/1220), - width: 0*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 0*(width/1220), - y: 400*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 0*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 100*(width/1220), - width: 4*(width/1220), - y: 250*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + mX = 200*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 400*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 100*basicWidthCalc + mWidth = 4*basicWidthCalc + mY = 250*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + init = true; } else if(levelNumber == 3) { resetLevel(); - ex = width-300*(width/1220); - ey = 20*(width/1220); + ex = width-300*basicWidthCalc; + ey = 20*basicWidthCalc; eh = 100; - ssx = midx * (3 / 2) * basicSSWidthCalc - ssy = 200 * basicSSWidthCalc + ssx = midx * (3 / 2) * basicWidthCalc + ssy = 200 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 200*(width/1220), - width: 0*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 0*(width/1220), - y: 400*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 100*(width/1220), - width: 4*(width/1220), - y: 250*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + mX = 200*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 400*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 100*basicWidthCalc + mWidth = 4*basicWidthCalc + mY = 250*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + init = true; } else if(levelNumber == 4) @@ -208,240 +203,193 @@ function initialiseLevel() resetLevel(); enemyDestroyed = false; - ex = midx-60*(width/1220); - ey = 60*(width/1220); + ex = midx-60*basicWidthCalc; + ey = 60*basicWidthCalc; eh = 100; - ssx = midx - 20 * basicSSWidthCalc - ssy = midy - 40 * basicSSWidthCalc + ssx = midx - 20 * basicWidthCalc + ssy = midy - 40 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 200*(width/1220), - width: 0*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 0*(width/1220), - y: 420*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 700*(width/1220), - width: 0*(width/1220), - y: 150*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 100*(width/1220), - width: 4*(width/1220), - y: 250*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 1100*(width/1220), - y: 250*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 300*(width/1220), - y: 300*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1100*(width/1220), - y: 150*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 400*(width/1220), - y: 350*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 400*(width/1220), - y: 250*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 500*(width/1220), - y: 300*(width/1220) - }; - a.push(myAsteroid); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + mX = 200*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 420*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 700*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 100*basicWidthCalc + mWidth = 4*basicWidthCalc + mY = 250*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 1100*basicWidthCalc + asteroidY = 250*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 300*basicWidthCalc + asteroidY = 300*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1100*basicWidthCalc + asteroidY = 150*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 400*basicWidthCalc + asteroidY = 350*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 400*basicWidthCalc + asteroidY = 250*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 500*basicWidthCalc + asteroidY = 300*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) init = true; } else if(levelNumber == 5) { resetLevel(); - ex = 10*(width/1220); - ey = 90*(width/1220); + ex = 10*basicWidthCalc; + ey = 90*basicWidthCalc; eh = 100; - ssx = 180 * basicSSWidthCalc, - ssy = midy - 40 * basicSSWidthCalc + ssx = 180 * basicWidthCalc, + ssy = midy - 40 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 150*(width/1220), - width: 100*(width/1220), - y: midy+200*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 800*(width/1220), - width: 100*(width/1220), - y: midy-100*(width/1220), - height: -150*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 700*(width/1220), - width: 0*(width/1220), - y: 400*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 900*(width/1220), - width: 100*(width/1220), - y: 500*(width/1220), - height: 0*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 5*(width/1220), - y: 220*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 78*(width/1220), - y: 190*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 130*(width/1220), - y: 120*(width/1220) - }; - a.push(myAsteroid); + mX = 150*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy+200*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 800*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy-100*basicWidthCalc + mHeight = -150*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 700*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 400*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 900*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 500*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 5*basicWidthCalc + asteroidY = 220*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 78*basicWidthCalc + asteroidY = 190*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 130*basicWidthCalc + asteroidY = 120*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; init = true; } else if(levelNumber == 6) { resetLevel(); - ex = 10*(width/1220); - ey = 90*(width/1220); + ex = 10*basicWidthCalc; + ey = 90*basicWidthCalc; eh = 100; ssx = midx - ssy - midy - 230 * basicSSWidthCalc + ssy - midy - 230 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 250*(width/1220), - width: 100*(width/1220), - y: midy, - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 1000*(width/1220), - width: 100*(width/1220), - y: midy-100*(width/1220), - height: 70*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 10*(width/1220), - width: 16*(width/1220), - y: midy+200*(width/1220), - height: 90*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 500*(width/1220), - width: 100*(width/1220), - y: midy+290*(width/1220), - height: -100*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 450*(width/1220), - width: 100*(width/1220), - y: midy-250*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 5*(width/1220), - y: 220*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 85*(width/1220), - y: 210*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 110*(width/1220), - y: 130*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: midx+100*(width/1220), - y: 270*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: midx-200*(width/1220), - y: 270*(width/1220) - }; - a.push(myAsteroid); + mX = 250*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 1000*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy-100*basicWidthCalc + mHeight = 70*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 10*basicWidthCalc + mWidth = 16*basicWidthCalc + mY = midy+200*basicWidthCalc + mHeight = 90*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 500*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy+290*basicWidthCalc + mHeight = -100*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 450*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = midy-250*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 5*basicWidthCalc + asteroidY = 220*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 85*basicWidthCalc + asteroidY = 210*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 110*basicWidthCalc + asteroidY = 130*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = midx+100*basicWidthCalc + asteroidY = 270*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = midx-200*basicWidthCalc + asteroidY = 270*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; init = true; } else if(levelNumber == 7) @@ -449,77 +397,62 @@ function initialiseLevel() resetLevel(); - ex = (width/1220); // ex,ey is the position of enemytriangle - ey = 250*(width/1220); + ex = basicWidthCalc; // ex,ey is the position of enemytriangle + ey = 250*basicWidthCalc; eh = 100; - ssx = midx - 400 * basicSSWidthCalc - ssy = 55 * basicSSWidthCalc + ssx = midx - 400 * basicWidthCalc + ssy = 55 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 700*(width/1220), - width: -15*(width/1220), - y: 360*(width/1220), - height: 100*(width/1220), // increase the mirror by adding this - drag: 1 // drag is only for fixing the mirror. - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 30*(width/1220), - width: 13*(width/1220), - y: 500*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 900*(width/1220), - width: 100*(width/1220), - y: 200*(width/1220), - height: (width/1220), // increase the mirror by adding this - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 500*(width/1220), - width: 35*(width/1220), - y: 175*(width/1220), - height: (width/1220), // increase the mirror by adding this - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 80*(width/1220), - y: 180*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 115*(width/1220), - y: 250*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 110*(width/1220), - y: 335*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 50*(width/1220), - y: 385*(width/1220) - }; - a.push(myAsteroid); + mX = 700*basicWidthCalc + mWidth = -15*basicWidthCalc + mY = 360*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 30*basicWidthCalc + mWidth = 13*basicWidthCalc + mY = 500*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 900*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 200*basicWidthCalc + mHeight = basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 500*basicWidthCalc + mWidth = 35*basicWidthCalc + mY = 175*basicWidthCalc + mHeight = basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 80*basicWidthCalc + asteroidY = 180*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 115*basicWidthCalc + asteroidY = 250*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 110*basicWidthCalc + asteroidY = 335*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 50*basicWidthCalc + asteroidY = 385*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; init = true; } else if(levelNumber == 8) @@ -527,255 +460,209 @@ function initialiseLevel() resetLevel(); - ex = (width/1220); - ey = 525*(width/1220); + ex = basicWidthCalc; + ey = 525*basicWidthCalc; eh = 100; - ssx = midx - 70 * basicSSWidthCalc - ssy = 250 * basicSSWidthCalc + ssx = midx - 70 * basicWidthCalc + ssy = 250 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 200*(width/1220), - width: -18*(width/1220), - y: 510*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 270*(width/1220), - width: 100*(width/1220), - y: 620*(width/1220), - height: 0*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 1100*(width/1220), - width: 95*(width/1220), - y: 530*(width/1220), - height: -100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 1200*(width/1220), - width: -95*(width/1220), - y: 150*(width/1220), - height: -100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 20*(width/1220), - width: 50*(width/1220), - y: 130*(width/1220), - height: -90*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMirror = { - x: 450*(width/1220), - width: 50*(width/1220), - y: 420*(width/1220), - height: 0*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); + mX = 200*basicWidthCalc + mWidth = -18*basicWidthCalc + mY = 510*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 270*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 620*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 1100*basicWidthCalc + mWidth = 95*basicWidthCalc + mY = 530*basicWidthCalc + mHeight = -100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 1200*basicWidthCalc + mWidth = -95*basicWidthCalc + mY = 150*basicWidthCalc + mHeight = -100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 20*basicWidthCalc + mWidth = 50*basicWidthCalc + mY = 130*basicWidthCalc + mHeight = -90*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + mX = 450*basicWidthCalc + mWidth = 50*basicWidthCalc + mY = 420*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + - myAsteroid = { - x: (width/1220), - y: 430*(width/1220) - }; - a.push(myAsteroid); + asteroidX = basicWidthCalc + asteroidY = 430*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - myAsteroid = { - x: 70*(width/1220), - y: 440*(width/1220) - }; - a.push(myAsteroid); + asteroidX = 70*basicWidthCalc + asteroidY = 440*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - myAsteroid = { - x: 110*(width/1220), - y: 570*(width/1220) - }; - a.push(myAsteroid); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + asteroidX = 110*basicWidthCalc + asteroidY = 570*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) init = true; } else if(levelNumber == 9) { resetLevel(); - ex = -15*(width/1220); - ey = 520*(width/1220); + ex = -15*basicWidthCalc; + ey = 520*basicWidthCalc; eh = 100; - ssx = 13 * basicSSWidthCalc - ssy = 90 * basicSSWidthCalc + ssx = 13 * basicWidthCalc + ssy = 90 * basicWidthCalc buildSpaceship(ssx, ssy) - ssx = 1067 * basicSSWidthCalc - ssy = 90 * basicSSWidthCalc + ssx = 1067 * basicWidthCalc + ssy = 90 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 350*(width/1220), - width: 17*(width/1220), - y: 520*(width/1220), - height: 80*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 1040*(width/1220), - width: -100*(width/1220), - y: 320*(width/1220), - height: -80*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 910*(width/1220), - width: 100*(width/1220), - y: 480*(width/1220), - height: -50*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 250*(width/1220), - width: 47.8*(width/1220), - y: 170*(width/1220), - height: -100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myAsteroid = { - x: 95*(width/1220), - y: 545*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 105*(width/1220), - y: 465*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 37*(width/1220), - y: 430*(width/1220) - }; - a.push(myAsteroid); + mX = 350*basicWidthCalc + mWidth = 17*basicWidthCalc + mY = 520*basicWidthCalc + mHeight = 80*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 1040*basicWidthCalc + mWidth = -100*basicWidthCalc + mY = 320*basicWidthCalc + mHeight = -80*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 910*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 480*basicWidthCalc + mHeight = -50*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 250*basicWidthCalc + mWidth = 47.8*basicWidthCalc + mY = 170*basicWidthCalc + mHeight = -100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + asteroidX = 95*basicWidthCalc + asteroidY = 545*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 105*basicWidthCalc + asteroidY = 465*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 37*basicWidthCalc + asteroidY = 430*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; init = true; } else if(levelNumber == 10) { resetLevel(); - ex = width-90*(width/1220); - ey = 250*(width/1220); + ex = width-90*basicWidthCalc; + ey = 250*basicWidthCalc; eh = 100; ssx = midx + 370 * (width /1220) ssy = 200 * (width / 122) buildSpaceship(ssx, ssy) - ssx = 370 * basicSSWidthCalc - ssy = 100 * basicSSWidthCalc + ssx = 370 * basicWidthCalc + ssy = 100 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 380*(width/1220), - width: 100*(width/1220), - y: 520*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 600*(width/1220), - width: 100*(width/1220), - y: 400*(width/1220), - height: 0*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); + mX = 380*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 520*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 600*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 400*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + myCircMirror ={ - x: 200*(width/1220), - //width: 100*(width/1220), - y: 300*(width/1220), - //height: -100*(width/1220), + x: 200*basicWidthCalc, + y: 300*basicWidthCalc, + //height: -100*basicWidthCalc, drag: 1 }; CircMirrors.push(myCircMirror); CircMirrorDrag.push(false); - myAsteroid = { - x: 900*(width/1220), - y: 150*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 900*(width/1220), - y: 250*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 900*(width/1220), - y: 350*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 900*(width/1220), - y: 50*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 900*(width/1220), - y: 1*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1090*(width/1220), - y: 170*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1095*(width/1220), - y: 350*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1150*(width/1220), - y: 390*(width/1220) - }; - a.push(myAsteroid); - - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + asteroidX = 900*basicWidthCalc + asteroidY = 150*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 900*basicWidthCalc + asteroidY = 250*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 900*basicWidthCalc + asteroidY = 350*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 900*basicWidthCalc + asteroidY = 50*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 900*basicWidthCalc + asteroidY = 1*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1090*basicWidthCalc + asteroidY = 170*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1095*basicWidthCalc + asteroidY = 350*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1150*basicWidthCalc + asteroidY = 390*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + + CircMirrorCount = CircMirrors.length; init = true; } @@ -783,248 +670,185 @@ function initialiseLevel() { resetLevel(); - ex = width-110*(width/1220); - ey = 515*(width/1220); + ex = width-110*basicWidthCalc; + ey = 515*basicWidthCalc; eh = 100; - ssx = 1 * basicSSWidthCalc - ssy = 270 * basicSSWidthCalc + ssx = 1 * basicWidthCalc + ssy = 270 * basicWidthCalc buildSpaceship(ssx, ssy) - ssx = 210 * basicSSWidthCalc - ssy = 30 * basicSSWidthCalc + ssx = 210 * basicWidthCalc + ssy = 30 * basicWidthCalc buildSpaceship(ssx, ssy) - ssx = (1080) * basicSSWidthCalc - ssy = 30 * basicSSWidthCalc + ssx = (1080) * basicWidthCalc + ssy = 30 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 1135*(width/1220), - width: 70*(width/1220), - y: 360*(width/1220), - height: 0*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 1135*(width/1220), - width: 50*(width/1220), - y: 390*(width/1220), - height: 50*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 700*(width/1220), - width: 50*(width/1220), - y: 550*(width/1220), - height: 50*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 750*(width/1220), - width: -50*(width/1220), - y: 380*(width/1220), - height: 50*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myAsteroid = { - x: 1152*(width/1220), - y: 425*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1082*(width/1220), - y: 435*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1007*(width/1220), - y: 480*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 1005*(width/1220), - y: 580*(width/1220) - }; - a.push(myAsteroid); - myMovingAsteroid = { - x1: 230*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 300*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 370*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 440*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 510*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 580*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 650*(width/1220), - y1: 283*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 720*(width/1220), - y1: 285*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 790*(width/1220), - y1: 285*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 860*(width/1220), - y1: 285*(width/1220), - }; - a1.push(myMovingAsteroid); - myMovingAsteroid = { - x1: 930*(width/1220), - y1: 287*(width/1220), - }; - a1.push(myMovingAsteroid); + mX = 1135*basicWidthCalc + mWidth = 70*basicWidthCalc + mY = 360*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 1135*basicWidthCalc + mWidth = 50*basicWidthCalc + mY = 390*basicWidthCalc + mHeight = 50*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 700*basicWidthCalc + mWidth = 50*basicWidthCalc + mY = 550*basicWidthCalc + mHeight = 50*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 750*basicWidthCalc + mWidth = -50*basicWidthCalc + mY = 380*basicWidthCalc + mHeight = 50*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + + asteroidX = 1152*basicWidthCalc + asteroidY = 425*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1082*basicWidthCalc + asteroidY = 435*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1007*basicWidthCalc + asteroidY = 480*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 1005*basicWidthCalc + asteroidY = 580*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 230*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 300*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 370*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 440*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 510*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 580*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 650*basicWidthCalc + asteroidY = 283*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 720*basicWidthCalc + asteroidY = 285*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 790*basicWidthCalc + asteroidY = 285*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 860*basicWidthCalc + asteroidY = 285*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 930*basicWidthCalc + asteroidY = 287*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; init = true; } else if(levelNumber == 12) { resetLevel(); - ex = 450*(width/1220); - ey = 250*(width/1220); + ex = 450*basicWidthCalc; + ey = 250*basicWidthCalc; eh = 100; - ssx = 630 * basicSSWidthCalc - ssy = 335 * basicSSWidthCalc + ssx = 630 * basicWidthCalc + ssy = 335 * basicWidthCalc buildSpaceship(ssx, ssy) - myMirror = { - x: 800*(width/1220), - width: 11*(width/1220), - y: 530*(width/1220), - height: 70*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 830*(width/1220), - width: 0*(width/1220), - y: 395*(width/1220), - height: 50*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 900*(width/1220), - width: 0*(width/1220), - y: 370*(width/1220), - height: 100*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 90*(width/1220), - width: 100*(width/1220), - y: 60*(width/1220), - height: 0*(width/1220), - drag: 0 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - myMirror = { - x: 200*(width/1220), - width: -4*(width/1220), - y: 260*(width/1220), - height: -60*(width/1220), - drag: 1 - }; - mirrors.push(myMirror); - mirrorDrag.push(false); - - myMovingAsteroid = { - x1: 380*(width/1220), - y1: 190*(width/1220), - }; - a1.push(myMovingAsteroid); - - myAsteroid = { - x: 450*(width/1220), - y: 170*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 520*(width/1220), - y: 185*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 580*(width/1220), - y: 215*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 565*(width/1220), - y: 450*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 475*(width/1220), - y: 370*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 410*(width/1220), - y: 345*(width/1220) - }; - a.push(myAsteroid); - myAsteroid = { - x: 380*(width/1220), - y: 270*(width/1220) - }; - a.push(myAsteroid); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; + mX = 800*basicWidthCalc + mWidth = 11*basicWidthCalc + mY = 530*basicWidthCalc + mHeight = 70*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 830*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 395*basicWidthCalc + mHeight = 50*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 900*basicWidthCalc + mWidth = 0*basicWidthCalc + mY = 370*basicWidthCalc + mHeight = 100*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 90*basicWidthCalc + mWidth = 100*basicWidthCalc + mY = 60*basicWidthCalc + mHeight = 0*basicWidthCalc + mDrag = 0 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + mX = 200*basicWidthCalc + mWidth = -4*basicWidthCalc + mY = 260*basicWidthCalc + mHeight = -60*basicWidthCalc + mDrag = 1 + mDragBool = false + buildMirror(mX, mWidth, mY, mHeight, mDrag, mDragBool) + + asteroidX = 380*basicWidthCalc + asteroidY = 190*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, true) + asteroidX = 450*basicWidthCalc + asteroidY = 170*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 520*basicWidthCalc + asteroidY = 185*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 580*basicWidthCalc + asteroidY = 215*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 565*basicWidthCalc + asteroidY = 450*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 475*basicWidthCalc + asteroidY = 370*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 410*basicWidthCalc + asteroidY = 345*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) + asteroidX = 380*basicWidthCalc + asteroidY = 270*basicWidthCalc + buildAsteroid(asteroidX, asteroidY, false) init = true; } else { resetLevel(); - mirrorCount = mirrors.length; - CircMirrorCount = CircMirrors.length; GC = true; } } From a4b0f09a1247a48058fdde675b2cc97d9291d44f Mon Sep 17 00:00:00 2001 From: jclayborn Date: Tue, 6 Oct 2020 09:14:42 -0500 Subject: [PATCH 4/4] remove comment --- scripts/levels.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/levels.js b/scripts/levels.js index 884364e..c8d4a55 100644 --- a/scripts/levels.js +++ b/scripts/levels.js @@ -72,7 +72,6 @@ function initialiseLevel() } const buildAsteroid = (x, y, moving) => { - console.log('moving? ', moving) moving ? a1.push({x1: x, y1: y}) : a.push({x, y}) }