From af1c9149d282d34ac46c015e8906a82c28aec98c Mon Sep 17 00:00:00 2001 From: "PolicyChanges1@gmail.com" Date: Sun, 21 Feb 2021 23:01:28 -0500 Subject: [PATCH] add dt cannon --- dist/tetrion.js | 137 ++++++++++++++++++++++++++++++++++++++++++++---- index.html | 11 ++-- src/main.js | 14 ++--- src/openers.js | 123 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 258 insertions(+), 27 deletions(-) diff --git a/dist/tetrion.js b/dist/tetrion.js index 9374d4c..62af2ce 100644 --- a/dist/tetrion.js +++ b/dist/tetrion.js @@ -940,7 +940,7 @@ Tetris.prototype = { canvas.drawShape(this.shape); canvas.drawHoldShape(this.holdQueue); canvas.drawPreviewShape(this.shapeQueue); - //canvas.drawHintShape(this.hintMino); + canvas.drawHintShape(this.hintMino); if(this.shape != undefined) { let clone = Object.assign(Object.create(Object.getPrototypeOf(this.shape)), this.shape); @@ -963,12 +963,11 @@ Tetris.prototype = { var halfFrame = 5.0//5;//8.0; var halfFramePlus = 10.0;//10.0; - // TODO: put in web worker--limited to 60fps here - //if(deltaTime >= tenthOfFrame) { // needs to be 600hz // 16 / 10 - inputs.incDeciframes(); - inputs.incTickCounter(); - //} + inputs.incDeciframes(); + inputs.incTickCounter(); + + if(inputs.getTickCounter() >= tenthOfFrame) { inputs.updateGamepad(); inputs.processGamepadDPad(); @@ -1153,6 +1152,7 @@ Tetris.prototype = { if(!this.shape.isSameSRS(this.hintMino)) { + new Audio('./dist/Failed.ogg').play(); this._restartHandler(); } /*if(this.shape.y != this.hintMino.y || this.shape.x != this.hintMino.x) { @@ -1169,7 +1169,7 @@ Tetris.prototype = { this.canPullFromHoldQueue = true; this.shape.copyTo(this.matrix); this._check(); - //this._checkHint(); + this._checkHint(); this._fireShape(); new Audio('./dist/Blop2.ogg').play(); } @@ -1308,7 +1308,8 @@ TKI3FonzieVariation.prototype = { } */ -// L O Z T LR ZR I + +// L O Z T LR/J ZR/S I var OpenerGenerator = { shapeQueue: [], hintQueue: [], @@ -1319,12 +1320,28 @@ var OpenerGenerator = { init() { if(!this.isInit || this.shapeQueue == undefined) { this.shapeQueue = new Array( + /* shapes.getShape(0), shapes.getShape(6), shapes.getShape(1), shapes.getShape(5), shapes.getShape(2), shapes.getShape(4), + shapes.getShape(3));*/ + // O I L S J Z T O I L J T O T + shapes.getShape(1), + shapes.getShape(6), + shapes.getShape(0), + shapes.getShape(5), + shapes.getShape(4), + shapes.getShape(2), + shapes.getShape(3), + shapes.getShape(1), + shapes.getShape(6), + shapes.getShape(0), + shapes.getShape(4), + shapes.getShape(3), + shapes.getShape(1), shapes.getShape(3)); } this.isInit = 1; @@ -1336,7 +1353,7 @@ var OpenerGenerator = { this.init(); var mino = this.shapeQueue[this.idx]; this.idx++; - if(this.idx == 7) { + if(this.idx == this.shapeQueue.length) { this.idx = 0; this.isInit = 0; } @@ -1344,7 +1361,7 @@ var OpenerGenerator = { return mino; }, // L O Z T LR ZR I - initHint(matrix) { +/* initHint(matrix) { if(!this.isHintInit || this.hintQueue == undefined) { this.hintQueue = new Array( shapes.getShape(0), @@ -1387,13 +1404,111 @@ var OpenerGenerator = { this.isHintInit = 1; + return; + },*/ + // L O Z T LR ZR I + initHint(matrix) { + if(!this.isHintInit || this.hintQueue == undefined) { + this.hintQueue = new Array( + /*shapes.getShape(0), + shapes.getShape(6), + shapes.getShape(1), + shapes.getShape(5), + shapes.getShape(2), + shapes.getShape(4), + shapes.getShape(3) + */ + shapes.getShape(1), + shapes.getShape(6), + shapes.getShape(0), + shapes.getShape(5), + shapes.getShape(4), + shapes.getShape(2), + shapes.getShape(3), + shapes.getShape(1), + shapes.getShape(6), + shapes.getShape(0), + shapes.getShape(4), + shapes.getShape(3), + shapes.getShape(1), + shapes.getShape(3)); + + // O I L S J Z T O I L J T O T + + // O + this.hintQueue[0].x = -2; + this.hintQueue[0].y = 18; + + // I + this.hintQueue[1].x = 6; + this.hintQueue[1].y = 16; + //this.hintQueue[1].state = this.hintQueue[1].nextState(1); + // L + this.hintQueue[2].x = 6; + this.hintQueue[2].y = 17; + this.hintQueue[2].state = this.hintQueue[2].nextState(1); + // S + this.hintQueue[3].x = 7; + this.hintQueue[3].y = 17; + this.hintQueue[3].state = this.hintQueue[3].nextState(1); + // J + this.hintQueue[4].x = 4; + this.hintQueue[4].y = 17; + this.hintQueue[4].state = this.hintQueue[4].nextState(-1); + + // Z + this.hintQueue[5].x = 3; + this.hintQueue[5].y = 17; + this.hintQueue[5].state = this.hintQueue[5].nextState(2); + + // T + this.hintQueue[6].x = 3; + this.hintQueue[6].y = 15; + + // O + this.hintQueue[7].x = 5; + this.hintQueue[7].y = 15; + + // I + this.hintQueue[8].x = 9; + this.hintQueue[8].y = 14; + //this.hintQueue[8].state = this.hintQueue[8].nextState(1); + + // L + this.hintQueue[9].x = 2; + this.hintQueue[9].y = 13; + this.hintQueue[9].state = this.hintQueue[9].nextState(-1); + + // J + this.hintQueue[10].x = -1; + this.hintQueue[10].y = 15; + this.hintQueue[10].state = this.hintQueue[10].nextState(1); + + // T + this.hintQueue[11].x = 1; + this.hintQueue[11].y = 16; + this.hintQueue[11].state = this.hintQueue[11].nextState(2); + + // O + this.hintQueue[12].x = 3; + this.hintQueue[12].y = 16; + this.hintQueue[12].state = this.hintQueue[12].nextState(1); + + // T + this.hintQueue[13].x = 1; + this.hintQueue[13].y = 17; + this.hintQueue[13].state = this.hintQueue[13].nextState(-1); + } + + this.isHintInit = 1; + return; }, getNextHint(matrix) { this.initHint(matrix); var mino = this.hintQueue[this.hintIdx]; this.hintIdx++; - if(this.hintIdx == 7) { + if(this.hintIdx == this.hintQueue.length) { this.hintIdx = 0; this.isHintInit = 0; } diff --git a/index.html b/index.html index 9db07b1..5fe1694 100644 --- a/index.html +++ b/index.html @@ -39,6 +39,7 @@ +