revert
parent
0a388ebd56
commit
2cfd4d854e
Binary file not shown.
Binary file not shown.
|
@ -486,7 +486,7 @@ var UserInputs = {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (gamepadDASFrames >= deciARR && isContained) {
|
if (gamepadDASFrames >= deciARR && isContained) {
|
||||||
this.gamepadQueue.push(finds);
|
//this.gamepadQueue.push(finds);
|
||||||
this.gamepadButtonsDeciFrames = 0;
|
this.gamepadButtonsDeciFrames = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,16 +495,16 @@ var UserInputs = {
|
||||||
|
|
||||||
// Direction Pad
|
// Direction Pad
|
||||||
gamepadDPadDown(finds) {
|
gamepadDPadDown(finds) {
|
||||||
var DAS = 7.0;
|
var DAS = 10.0;
|
||||||
var ARR = 3.0;
|
var ARR = 5.0;
|
||||||
var isContained = this.gpButtons.includes(finds);
|
var isContained = this.gpButtons.includes(finds);
|
||||||
var isPrevContained = this.prevGpButtons.includes(finds);
|
var isPrevContained = this.prevGpButtons.includes(finds);
|
||||||
//console.log("but: " + this.gpButtons + " prev but:" + this.prevGpButtons);
|
//console.log("but: " + this.gpButtons + " prev but:" + this.prevGpButtons);
|
||||||
if(isPrevContained != isContained ) {
|
if(isPrevContained != isContained ) {
|
||||||
this.isGamepadDown = false;
|
this.isGamepadDown = false;
|
||||||
// Do once
|
// Do once
|
||||||
//if(isContained)
|
if(isContained)
|
||||||
// this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
}
|
}
|
||||||
var gamepadDirectionDasFrames = this.gamepadDirectionPadDeciFrames / 1.0;
|
var gamepadDirectionDasFrames = this.gamepadDirectionPadDeciFrames / 1.0;
|
||||||
if (!this.isGamepadDown) {
|
if (!this.isGamepadDown) {
|
||||||
|
@ -556,7 +556,7 @@ var UserInputs = {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (keyboardDASFrames >= deciARR && this.keyboardKeys[key] == true) {
|
if (keyboardDASFrames >= deciARR && this.keyboardKeys[key] == true) {
|
||||||
this.inputqueue.push(key);
|
//this.inputqueue.push(key);
|
||||||
this.keyboardButtonsDeciframes = 0;
|
this.keyboardButtonsDeciframes = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,16 +572,16 @@ var UserInputs = {
|
||||||
},
|
},
|
||||||
// Direction arrows
|
// Direction arrows
|
||||||
processKeyboardArrowKeys(key) {
|
processKeyboardArrowKeys(key) {
|
||||||
var DAS = 8.0;
|
var DAS = 30.0;
|
||||||
var ARR = 0.0;
|
var ARR = 0.0;
|
||||||
|
|
||||||
/* do once?
|
|
||||||
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
||||||
this.isDirectionArrowDown = false;
|
this.isDirectionArrowDown = false;
|
||||||
if(this.keyboardKeys[key] == true)
|
if(this.keyboardKeys[key] == true)
|
||||||
this.inputqueue.push(key);
|
this.inputqueue.push(key);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//console.log(key + " " + this.held
|
//console.log(key + " " + this.held
|
||||||
var keyboardDASFrames = this.keyboardDirectionArrowsDeciframes / 1.0; // why isnt this 10?
|
var keyboardDASFrames = this.keyboardDirectionArrowsDeciframes / 1.0; // why isnt this 10?
|
||||||
//console.log(keyboardDASFrames + " " + this.held);
|
//console.log(keyboardDASFrames + " " + this.held);
|
||||||
|
@ -820,7 +820,7 @@ Tetris.prototype = {
|
||||||
this.levelTime = this.startTime;
|
this.levelTime = this.startTime;
|
||||||
this.shapeQueue = this.shapeQueue || [];
|
this.shapeQueue = this.shapeQueue || [];
|
||||||
this.hintQueue = this.hintQueue || [];
|
this.hintQueue = this.hintQueue || [];
|
||||||
this.holdQueue = this.holdQueue || [];
|
this.holdQueue = [];
|
||||||
this.canPullFromHoldQueue = false;
|
this.canPullFromHoldQueue = false;
|
||||||
clearMatrix(this.matrix);
|
clearMatrix(this.matrix);
|
||||||
views.setLevel(this.level);
|
views.setLevel(this.level);
|
||||||
|
@ -887,16 +887,17 @@ Tetris.prototype = {
|
||||||
_fireShape: function() {
|
_fireShape: function() {
|
||||||
//this.shape = this.shapeQueue.shift() || shapes.randomShape();
|
//this.shape = this.shapeQueue.shift() || shapes.randomShape();
|
||||||
|
|
||||||
|
|
||||||
while(this.shapeQueue.length <= 4)
|
while(this.shapeQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = shapes.randomShape();//openers.getNextMino();
|
this.preparedShape = openers.getNextMino();
|
||||||
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.matrix);
|
this.preparedShape = openers.getNextHint(this.matrix);
|
||||||
this.hintQueue.push(this.preparedShape);
|
this.hintQueue.push(this.preparedShape);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
//this.hintMino = this.hintQueue.shift();
|
//this.hintMino = this.hintQueue.shift();
|
||||||
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
||||||
|
@ -1030,10 +1031,10 @@ Tetris.prototype = {
|
||||||
this._update();
|
this._update();
|
||||||
}
|
}
|
||||||
if(curkey == 81) {
|
if(curkey == 81) {
|
||||||
//if(document.getElementById("bg").style.display == "none")
|
if(document.getElementById("bg").style.display == "none")
|
||||||
// document.getElementById("bg").style.display = "initial";
|
document.getElementById("bg").style.display = "initial";
|
||||||
//else
|
else
|
||||||
// document.getElementById("bg").style.display="none";
|
document.getElementById("bg").style.display="none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputs.inputqueue = [];
|
inputs.inputqueue = [];
|
||||||
|
@ -1067,7 +1068,7 @@ Tetris.prototype = {
|
||||||
this.shape.copyTo(this.matrix);
|
this.shape.copyTo(this.matrix);
|
||||||
this._check();
|
this._check();
|
||||||
this._fireShape();
|
this._fireShape();
|
||||||
new Audio('./dist/Blop.ogg').play();
|
new Audio('./dist/Blop2.ogg').play();
|
||||||
}
|
}
|
||||||
this._draw();
|
this._draw();
|
||||||
this.isGameOver = checkGameOver(this.matrix);
|
this.isGameOver = checkGameOver(this.matrix);
|
||||||
|
@ -1641,12 +1642,14 @@ ShapeZR.prototype = {
|
||||||
//Move the shape to the left
|
//Move the shape to the left
|
||||||
goLeft: function(matrix) {
|
goLeft: function(matrix) {
|
||||||
if (isShapeCanMove(this, matrix, 'left')) {
|
if (isShapeCanMove(this, matrix, 'left')) {
|
||||||
|
new Audio('./dist/Click.ogg').play();
|
||||||
this.x -= 1;
|
this.x -= 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//Move the shape to the right
|
//Move the shape to the right
|
||||||
goRight: function(matrix) {
|
goRight: function(matrix) {
|
||||||
if (isShapeCanMove(this, matrix, 'right')) {
|
if (isShapeCanMove(this, matrix, 'right')) {
|
||||||
|
new Audio('./dist/Click.ogg').play();
|
||||||
this.x += 1;
|
this.x += 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,13 +37,13 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/4lBGDh?gui=&t=10&paused=false&muted=false" allowfullscreen></iframe>
|
<iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/4lBGDh?gui=&t=10&paused=false&muted=false" allowfullscreen></iframe>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("bg").width = window.innerWidth;
|
document.getElementById("bg").width = window.innerWidth;
|
||||||
document.getElementById("bg").height = window.innerHeight;-->
|
document.getElementById("bg").height = window.innerHeight;
|
||||||
</script>
|
</script>
|
||||||
<div id="tetris">
|
<div id="tetris">
|
||||||
|
|
||||||
|
|
18
src/input.js
18
src/input.js
|
@ -66,7 +66,7 @@ var UserInputs = {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (gamepadDASFrames >= deciARR && isContained) {
|
if (gamepadDASFrames >= deciARR && isContained) {
|
||||||
this.gamepadQueue.push(finds);
|
//this.gamepadQueue.push(finds);
|
||||||
this.gamepadButtonsDeciFrames = 0;
|
this.gamepadButtonsDeciFrames = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,16 @@ var UserInputs = {
|
||||||
|
|
||||||
// Direction Pad
|
// Direction Pad
|
||||||
gamepadDPadDown(finds) {
|
gamepadDPadDown(finds) {
|
||||||
var DAS = 7.0;
|
var DAS = 10.0;
|
||||||
var ARR = 3.0;
|
var ARR = 5.0;
|
||||||
var isContained = this.gpButtons.includes(finds);
|
var isContained = this.gpButtons.includes(finds);
|
||||||
var isPrevContained = this.prevGpButtons.includes(finds);
|
var isPrevContained = this.prevGpButtons.includes(finds);
|
||||||
//console.log("but: " + this.gpButtons + " prev but:" + this.prevGpButtons);
|
//console.log("but: " + this.gpButtons + " prev but:" + this.prevGpButtons);
|
||||||
if(isPrevContained != isContained ) {
|
if(isPrevContained != isContained ) {
|
||||||
this.isGamepadDown = false;
|
this.isGamepadDown = false;
|
||||||
// Do once
|
// Do once
|
||||||
//if(isContained)
|
if(isContained)
|
||||||
// this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
}
|
}
|
||||||
var gamepadDirectionDasFrames = this.gamepadDirectionPadDeciFrames / 1.0;
|
var gamepadDirectionDasFrames = this.gamepadDirectionPadDeciFrames / 1.0;
|
||||||
if (!this.isGamepadDown) {
|
if (!this.isGamepadDown) {
|
||||||
|
@ -136,7 +136,7 @@ var UserInputs = {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (keyboardDASFrames >= deciARR && this.keyboardKeys[key] == true) {
|
if (keyboardDASFrames >= deciARR && this.keyboardKeys[key] == true) {
|
||||||
this.inputqueue.push(key);
|
//this.inputqueue.push(key);
|
||||||
this.keyboardButtonsDeciframes = 0;
|
this.keyboardButtonsDeciframes = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,16 +152,16 @@ var UserInputs = {
|
||||||
},
|
},
|
||||||
// Direction arrows
|
// Direction arrows
|
||||||
processKeyboardArrowKeys(key) {
|
processKeyboardArrowKeys(key) {
|
||||||
var DAS = 8.0;
|
var DAS = 30.0;
|
||||||
var ARR = 0.0;
|
var ARR = 0.0;
|
||||||
|
|
||||||
/* do once?
|
|
||||||
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
||||||
this.isDirectionArrowDown = false;
|
this.isDirectionArrowDown = false;
|
||||||
if(this.keyboardKeys[key] == true)
|
if(this.keyboardKeys[key] == true)
|
||||||
this.inputqueue.push(key);
|
this.inputqueue.push(key);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//console.log(key + " " + this.held
|
//console.log(key + " " + this.held
|
||||||
var keyboardDASFrames = this.keyboardDirectionArrowsDeciframes / 1.0; // why isnt this 10?
|
var keyboardDASFrames = this.keyboardDirectionArrowsDeciframes / 1.0; // why isnt this 10?
|
||||||
//console.log(keyboardDASFrames + " " + this.held);
|
//console.log(keyboardDASFrames + " " + this.held);
|
||||||
|
|
19
src/main.js
19
src/main.js
|
@ -175,7 +175,7 @@ Tetris.prototype = {
|
||||||
this.levelTime = this.startTime;
|
this.levelTime = this.startTime;
|
||||||
this.shapeQueue = this.shapeQueue || [];
|
this.shapeQueue = this.shapeQueue || [];
|
||||||
this.hintQueue = this.hintQueue || [];
|
this.hintQueue = this.hintQueue || [];
|
||||||
this.holdQueue = this.holdQueue || [];
|
this.holdQueue = [];
|
||||||
this.canPullFromHoldQueue = false;
|
this.canPullFromHoldQueue = false;
|
||||||
clearMatrix(this.matrix);
|
clearMatrix(this.matrix);
|
||||||
views.setLevel(this.level);
|
views.setLevel(this.level);
|
||||||
|
@ -242,16 +242,17 @@ Tetris.prototype = {
|
||||||
_fireShape: function() {
|
_fireShape: function() {
|
||||||
//this.shape = this.shapeQueue.shift() || shapes.randomShape();
|
//this.shape = this.shapeQueue.shift() || shapes.randomShape();
|
||||||
|
|
||||||
|
|
||||||
while(this.shapeQueue.length <= 4)
|
while(this.shapeQueue.length <= 4)
|
||||||
{
|
{
|
||||||
this.preparedShape = shapes.randomShape();//openers.getNextMino();
|
this.preparedShape = openers.getNextMino();
|
||||||
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.matrix);
|
this.preparedShape = openers.getNextHint(this.matrix);
|
||||||
this.hintQueue.push(this.preparedShape);
|
this.hintQueue.push(this.preparedShape);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
//this.hintMino = this.hintQueue.shift();
|
//this.hintMino = this.hintQueue.shift();
|
||||||
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
||||||
|
@ -385,10 +386,10 @@ Tetris.prototype = {
|
||||||
this._update();
|
this._update();
|
||||||
}
|
}
|
||||||
if(curkey == 81) {
|
if(curkey == 81) {
|
||||||
//if(document.getElementById("bg").style.display == "none")
|
if(document.getElementById("bg").style.display == "none")
|
||||||
// document.getElementById("bg").style.display = "initial";
|
document.getElementById("bg").style.display = "initial";
|
||||||
//else
|
else
|
||||||
// document.getElementById("bg").style.display="none";
|
document.getElementById("bg").style.display="none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputs.inputqueue = [];
|
inputs.inputqueue = [];
|
||||||
|
@ -422,7 +423,7 @@ Tetris.prototype = {
|
||||||
this.shape.copyTo(this.matrix);
|
this.shape.copyTo(this.matrix);
|
||||||
this._check();
|
this._check();
|
||||||
this._fireShape();
|
this._fireShape();
|
||||||
new Audio('./dist/Blop.ogg').play();
|
new Audio('./dist/Blop2.ogg').play();
|
||||||
}
|
}
|
||||||
this._draw();
|
this._draw();
|
||||||
this.isGameOver = checkGameOver(this.matrix);
|
this.isGameOver = checkGameOver(this.matrix);
|
||||||
|
|
31
src/openers
31
src/openers
|
@ -1,31 +0,0 @@
|
||||||
shapes = require(./shapes.js);
|
|
||||||
|
|
||||||
|
|
||||||
function TKI3FonzieVariation {
|
|
||||||
|
|
||||||
this.shapeQueue: [],
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
TKI3FonzieVariation.prototype = {
|
|
||||||
init: function () {
|
|
||||||
this.shapeQueue.push(new ShapeL());
|
|
||||||
this.shapeQueue.push(new ShapeI());
|
|
||||||
this.shapeQueue.push(new ShapeO());
|
|
||||||
this.shapeQueue.push(new ShapeS());
|
|
||||||
this.shapeQueue.push(new ShapeZ());
|
|
||||||
this.shapeQueue.push(new ShapeJ());
|
|
||||||
this.shapeQueue.push(new ShapeT());
|
|
||||||
}
|
|
||||||
|
|
||||||
//hintShape
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNewOpener()
|
|
||||||
{
|
|
||||||
var opener = new TKI3FonzieVariation()
|
|
||||||
opener.init();
|
|
||||||
return opener;
|
|
||||||
}
|
|
||||||
//var Openers = {
|
|
||||||
|
|
|
@ -360,12 +360,14 @@ ShapeZR.prototype = {
|
||||||
//Move the shape to the left
|
//Move the shape to the left
|
||||||
goLeft: function(matrix) {
|
goLeft: function(matrix) {
|
||||||
if (isShapeCanMove(this, matrix, 'left')) {
|
if (isShapeCanMove(this, matrix, 'left')) {
|
||||||
|
new Audio('./dist/Click.ogg').play();
|
||||||
this.x -= 1;
|
this.x -= 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//Move the shape to the right
|
//Move the shape to the right
|
||||||
goRight: function(matrix) {
|
goRight: function(matrix) {
|
||||||
if (isShapeCanMove(this, matrix, 'right')) {
|
if (isShapeCanMove(this, matrix, 'right')) {
|
||||||
|
new Audio('./dist/Click.ogg').play();
|
||||||
this.x += 1;
|
this.x += 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue