buggy but better
This commit is contained in:
parent
6f27db0588
commit
bfee51eff4
1
deploy.sh.bat
Normal file
1
deploy.sh.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
browserify ./src/main.js -o ./dist/tetrion.js
|
26
dist/tetrion.js
vendored
26
dist/tetrion.js
vendored
@ -993,6 +993,7 @@ Tetris.prototype = {
|
|||||||
this.levelTime = this.startTime;
|
this.levelTime = this.startTime;
|
||||||
this.prevInputTime = this.startTime;
|
this.prevInputTime = this.startTime;
|
||||||
// current tetrino index gets set to 0 at the end of opener sequence
|
// current tetrino index gets set to 0 at the end of opener sequence
|
||||||
|
//if(this.currentMinoInx == undefined || this.currentMinoInx < 1000) // todo: refactor -- seppuku worthy
|
||||||
this.currentMinoInx = 0;
|
this.currentMinoInx = 0;
|
||||||
this.shapeQueue = [];
|
this.shapeQueue = [];
|
||||||
this.hintQueue = [];
|
this.hintQueue = [];
|
||||||
@ -1041,7 +1042,7 @@ Tetris.prototype = {
|
|||||||
if(this.holdStack.length > 0) {
|
if(this.holdStack.length > 0) {
|
||||||
this.canPopFromHoldStack = false;
|
this.canPopFromHoldStack = false;
|
||||||
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
||||||
this.shape = this.holdStack.pop();
|
this.shape = utils.deepClone(this.holdStack.pop());
|
||||||
this.shape.resetOrigin();
|
this.shape.resetOrigin();
|
||||||
this._draw();
|
this._draw();
|
||||||
}else if(this.holdStack.length < 4) {
|
}else if(this.holdStack.length < 4) {
|
||||||
@ -1070,7 +1071,7 @@ Tetris.prototype = {
|
|||||||
if(this.shape.canDown(this.matrix)) return;
|
if(this.shape.canDown(this.matrix)) return;
|
||||||
this.shape.copyTo(this.matrix);
|
this.shape.copyTo(this.matrix);
|
||||||
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
||||||
this.shape = this.holdStack.pop();
|
this.shape = utils.deepClone(this.holdStack.pop());
|
||||||
this._check();
|
this._check();
|
||||||
this._draw();
|
this._draw();
|
||||||
return;
|
return;
|
||||||
@ -1114,12 +1115,12 @@ Tetris.prototype = {
|
|||||||
_processOpenerTrainerQueue: function() {
|
_processOpenerTrainerQueue: function() {
|
||||||
while(this.shapeQueue.length <= 4)
|
while(this.shapeQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = openers.getNextMino(this.currentOpener);
|
this.preparedShape = utils.deepClone(openers.getNextMino(this.currentOpener));
|
||||||
this.shapeQueue.push(this.preparedShape);
|
this.shapeQueue.push(this.preparedShape);
|
||||||
}
|
}
|
||||||
while(this.hintQueue.length <= 4)
|
while(this.hintQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = openers.getNextHint(this.currentOpener);
|
this.preparedShape = utils.deepClone(openers.getNextHint(this.currentOpener));
|
||||||
this.hintQueue.push(this.preparedShape);
|
this.hintQueue.push(this.preparedShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,8 +1138,6 @@ Tetris.prototype = {
|
|||||||
if(besttime == "" || deltaTime/1000.0 < parseFloat(besttime)) {
|
if(besttime == "" || deltaTime/1000.0 < parseFloat(besttime)) {
|
||||||
document.getElementById("besttime").value = (deltaTime/1000.0).toString();
|
document.getElementById("besttime").value = (deltaTime/1000.0).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hintQueue = [];
|
this.hintQueue = [];
|
||||||
@ -1539,7 +1538,8 @@ var openerGenerator = {
|
|||||||
hintIdx: 0,
|
hintIdx: 0,
|
||||||
isInit: 0,
|
isInit: 0,
|
||||||
isHintInit: 0,
|
isHintInit: 0,
|
||||||
|
customShapeQueue: [],
|
||||||
|
customHintQueue: [],
|
||||||
// O - 1, I - 6, L - 0, S - 5, J - 4, Z - 2, T - 3
|
// O - 1, I - 6, L - 0, S - 5, J - 4, Z - 2, T - 3
|
||||||
// Current Tetriminos
|
// Current Tetriminos
|
||||||
init(opener) {
|
init(opener) {
|
||||||
@ -1710,10 +1710,11 @@ var openerGenerator = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getNextMino(opener) {
|
getNextMino(opener) {
|
||||||
|
if(this.customShapeQueue.length > 0) return this.customShapeQueue[this.idx++%this.customShapeQueue.length];
|
||||||
this.init(opener);
|
this.init(opener);
|
||||||
var mino = this.shapeQueue[this.idx];
|
var mino = this.shapeQueue[this.idx];
|
||||||
this.idx++;
|
this.idx++;
|
||||||
if(this.idx == this.shapeQueue.length) {
|
if(this.idx >= this.shapeQueue.length) {
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
if(opener < 1000)
|
if(opener < 1000)
|
||||||
this.isInit = 0;
|
this.isInit = 0;
|
||||||
@ -1986,10 +1987,11 @@ var openerGenerator = {
|
|||||||
// End initHint
|
// End initHint
|
||||||
|
|
||||||
getNextHint(opener) {
|
getNextHint(opener) {
|
||||||
|
if(this.customHintQueue.length > 0) return this.customHintQueue[this.hintIdx++%this.customHintQueue.length];
|
||||||
this.initHint(opener);
|
this.initHint(opener);
|
||||||
var mino = this.hintQueue[this.hintIdx];
|
var mino = this.hintQueue[this.hintIdx];
|
||||||
this.hintIdx++;
|
this.hintIdx++;
|
||||||
if(this.hintIdx == this.hintQueue.length) {
|
if(this.hintIdx >= this.hintQueue.length) {
|
||||||
this.hintIdx = 0;
|
this.hintIdx = 0;
|
||||||
if(opener < 1000)
|
if(opener < 1000)
|
||||||
this.isHintInit = 0;
|
this.isHintInit = 0;
|
||||||
@ -2007,7 +2009,7 @@ var openerGenerator = {
|
|||||||
this.isHintInit = 0;
|
this.isHintInit = 0;
|
||||||
},
|
},
|
||||||
getLength() {
|
getLength() {
|
||||||
return this.hintQueue.length;
|
return this.customHintQueue.length || this.hintQueue.length;
|
||||||
},
|
},
|
||||||
addSequence(sequence) {
|
addSequence(sequence) {
|
||||||
//this.reset();
|
//this.reset();
|
||||||
@ -2020,10 +2022,10 @@ var openerGenerator = {
|
|||||||
shape.x = sequence[i].x;
|
shape.x = sequence[i].x;
|
||||||
shape.y = sequence[i].y;
|
shape.y = sequence[i].y;
|
||||||
shape.state = sequence[i].state;
|
shape.state = sequence[i].state;
|
||||||
this.hintQueue.unshift(utils.deepClone(shape));
|
this.customHintQueue.unshift(utils.deepClone(shape));
|
||||||
shape.x = shape.originX;
|
shape.x = shape.originX;
|
||||||
shape.y = shape.originY;
|
shape.y = shape.originY;
|
||||||
this.shapeQueue.unshift(utils.deepClone(shape));
|
this.customShapeQueue.unshift(utils.deepClone(shape));
|
||||||
this.isInit = 1;
|
this.isInit = 1;
|
||||||
this.isHintInit = 1;
|
this.isHintInit = 1;
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
|
11
src/main.js
11
src/main.js
@ -309,6 +309,7 @@ Tetris.prototype = {
|
|||||||
this.levelTime = this.startTime;
|
this.levelTime = this.startTime;
|
||||||
this.prevInputTime = this.startTime;
|
this.prevInputTime = this.startTime;
|
||||||
// current tetrino index gets set to 0 at the end of opener sequence
|
// current tetrino index gets set to 0 at the end of opener sequence
|
||||||
|
//if(this.currentMinoInx == undefined || this.currentMinoInx < 1000) // todo: refactor -- seppuku worthy
|
||||||
this.currentMinoInx = 0;
|
this.currentMinoInx = 0;
|
||||||
this.shapeQueue = [];
|
this.shapeQueue = [];
|
||||||
this.hintQueue = [];
|
this.hintQueue = [];
|
||||||
@ -357,7 +358,7 @@ Tetris.prototype = {
|
|||||||
if(this.holdStack.length > 0) {
|
if(this.holdStack.length > 0) {
|
||||||
this.canPopFromHoldStack = false;
|
this.canPopFromHoldStack = false;
|
||||||
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
||||||
this.shape = this.holdStack.pop();
|
this.shape = utils.deepClone(this.holdStack.pop());
|
||||||
this.shape.resetOrigin();
|
this.shape.resetOrigin();
|
||||||
this._draw();
|
this._draw();
|
||||||
}else if(this.holdStack.length < 4) {
|
}else if(this.holdStack.length < 4) {
|
||||||
@ -386,7 +387,7 @@ Tetris.prototype = {
|
|||||||
if(this.shape.canDown(this.matrix)) return;
|
if(this.shape.canDown(this.matrix)) return;
|
||||||
this.shape.copyTo(this.matrix);
|
this.shape.copyTo(this.matrix);
|
||||||
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
this.shapeQueue.unshift(utils.deepClone(this.shape));
|
||||||
this.shape = this.holdStack.pop();
|
this.shape = utils.deepClone(this.holdStack.pop());
|
||||||
this._check();
|
this._check();
|
||||||
this._draw();
|
this._draw();
|
||||||
return;
|
return;
|
||||||
@ -430,12 +431,12 @@ Tetris.prototype = {
|
|||||||
_processOpenerTrainerQueue: function() {
|
_processOpenerTrainerQueue: function() {
|
||||||
while(this.shapeQueue.length <= 4)
|
while(this.shapeQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = openers.getNextMino(this.currentOpener);
|
this.preparedShape = utils.deepClone(openers.getNextMino(this.currentOpener));
|
||||||
this.shapeQueue.push(this.preparedShape);
|
this.shapeQueue.push(this.preparedShape);
|
||||||
}
|
}
|
||||||
while(this.hintQueue.length <= 4)
|
while(this.hintQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = openers.getNextHint(this.currentOpener);
|
this.preparedShape = utils.deepClone(openers.getNextHint(this.currentOpener));
|
||||||
this.hintQueue.push(this.preparedShape);
|
this.hintQueue.push(this.preparedShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,8 +454,6 @@ Tetris.prototype = {
|
|||||||
if(besttime == "" || deltaTime/1000.0 < parseFloat(besttime)) {
|
if(besttime == "" || deltaTime/1000.0 < parseFloat(besttime)) {
|
||||||
document.getElementById("besttime").value = (deltaTime/1000.0).toString();
|
document.getElementById("besttime").value = (deltaTime/1000.0).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hintQueue = [];
|
this.hintQueue = [];
|
||||||
|
@ -11,7 +11,8 @@ var openerGenerator = {
|
|||||||
hintIdx: 0,
|
hintIdx: 0,
|
||||||
isInit: 0,
|
isInit: 0,
|
||||||
isHintInit: 0,
|
isHintInit: 0,
|
||||||
|
customShapeQueue: [],
|
||||||
|
customHintQueue: [],
|
||||||
// O - 1, I - 6, L - 0, S - 5, J - 4, Z - 2, T - 3
|
// O - 1, I - 6, L - 0, S - 5, J - 4, Z - 2, T - 3
|
||||||
// Current Tetriminos
|
// Current Tetriminos
|
||||||
init(opener) {
|
init(opener) {
|
||||||
@ -182,10 +183,11 @@ var openerGenerator = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getNextMino(opener) {
|
getNextMino(opener) {
|
||||||
|
if(this.customShapeQueue.length > 0) return this.customShapeQueue[this.idx++%this.customShapeQueue.length];
|
||||||
this.init(opener);
|
this.init(opener);
|
||||||
var mino = this.shapeQueue[this.idx];
|
var mino = this.shapeQueue[this.idx];
|
||||||
this.idx++;
|
this.idx++;
|
||||||
if(this.idx == this.shapeQueue.length) {
|
if(this.idx >= this.shapeQueue.length) {
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
if(opener < 1000)
|
if(opener < 1000)
|
||||||
this.isInit = 0;
|
this.isInit = 0;
|
||||||
@ -458,10 +460,11 @@ var openerGenerator = {
|
|||||||
// End initHint
|
// End initHint
|
||||||
|
|
||||||
getNextHint(opener) {
|
getNextHint(opener) {
|
||||||
|
if(this.customHintQueue.length > 0) return this.customHintQueue[this.hintIdx++%this.customHintQueue.length];
|
||||||
this.initHint(opener);
|
this.initHint(opener);
|
||||||
var mino = this.hintQueue[this.hintIdx];
|
var mino = this.hintQueue[this.hintIdx];
|
||||||
this.hintIdx++;
|
this.hintIdx++;
|
||||||
if(this.hintIdx == this.hintQueue.length) {
|
if(this.hintIdx >= this.hintQueue.length) {
|
||||||
this.hintIdx = 0;
|
this.hintIdx = 0;
|
||||||
if(opener < 1000)
|
if(opener < 1000)
|
||||||
this.isHintInit = 0;
|
this.isHintInit = 0;
|
||||||
@ -479,7 +482,7 @@ var openerGenerator = {
|
|||||||
this.isHintInit = 0;
|
this.isHintInit = 0;
|
||||||
},
|
},
|
||||||
getLength() {
|
getLength() {
|
||||||
return this.hintQueue.length;
|
return this.customHintQueue.length || this.hintQueue.length;
|
||||||
},
|
},
|
||||||
addSequence(sequence) {
|
addSequence(sequence) {
|
||||||
//this.reset();
|
//this.reset();
|
||||||
@ -492,10 +495,10 @@ var openerGenerator = {
|
|||||||
shape.x = sequence[i].x;
|
shape.x = sequence[i].x;
|
||||||
shape.y = sequence[i].y;
|
shape.y = sequence[i].y;
|
||||||
shape.state = sequence[i].state;
|
shape.state = sequence[i].state;
|
||||||
this.hintQueue.unshift(utils.deepClone(shape));
|
this.customHintQueue.unshift(utils.deepClone(shape));
|
||||||
shape.x = shape.originX;
|
shape.x = shape.originX;
|
||||||
shape.y = shape.originY;
|
shape.y = shape.originY;
|
||||||
this.shapeQueue.unshift(utils.deepClone(shape));
|
this.customShapeQueue.unshift(utils.deepClone(shape));
|
||||||
this.isInit = 1;
|
this.isInit = 1;
|
||||||
this.isHintInit = 1;
|
this.isHintInit = 1;
|
||||||
this.idx = 0;
|
this.idx = 0;
|
||||||
|
1
startserver.sh.bat
Normal file
1
startserver.sh.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
python3 -m http.server
|
Loading…
Reference in New Issue
Block a user