added piece move clicks, finished opener proof of concept, fixed gamepad das, keyboard das is scuffed b/c of javascript key events
parent
2cfd4d854e
commit
aab893ccb9
|
@ -176,7 +176,7 @@ var tetrisCanvas = {
|
|||
return;
|
||||
}
|
||||
var colorRGB = this.hexToRgb(shape.color);
|
||||
var color = "rgba(" + colorRGB.r + "," + colorRGB.g + "," + colorRGB.b + "," + "0.4)";
|
||||
var color = "rgba(" + colorRGB.r + "," + colorRGB.g + "," + colorRGB.b + "," + "0.2)";
|
||||
|
||||
var matrix = shape.matrix();
|
||||
var gsize = this.gridSize;
|
||||
|
@ -444,6 +444,7 @@ var UserInputs = {
|
|||
this.gamepadButtonsDown("A");
|
||||
this.gamepadButtonsDown("B");
|
||||
this.gamepadButtonsDown("DPad-Up");
|
||||
this.gamepadButtonsDown("Back");
|
||||
//this.gamepadButtonsDown("X");
|
||||
//this.gamepadButtonsDown("Y");
|
||||
|
||||
|
@ -532,6 +533,7 @@ var UserInputs = {
|
|||
this.processKeyDown(16); // shift
|
||||
this.processKeyDown(17); // ctrl
|
||||
this.processKeyDown(81); // q
|
||||
this.processKeyDown(82); // r
|
||||
},
|
||||
|
||||
// keyboard keys z,x,space
|
||||
|
@ -818,8 +820,8 @@ Tetris.prototype = {
|
|||
this.currentTime = this.startTime;
|
||||
this.prevTime = this.startTime;
|
||||
this.levelTime = this.startTime;
|
||||
this.shapeQueue = this.shapeQueue || [];
|
||||
this.hintQueue = this.hintQueue || [];
|
||||
this.shapeQueue = [];
|
||||
this.hintQueue = [];
|
||||
this.holdQueue = [];
|
||||
this.canPullFromHoldQueue = false;
|
||||
clearMatrix(this.matrix);
|
||||
|
@ -899,7 +901,7 @@ Tetris.prototype = {
|
|||
this.hintQueue.push(this.preparedShape);
|
||||
}
|
||||
|
||||
//this.hintMino = this.hintQueue.shift();
|
||||
this.hintMino = this.hintQueue.shift();
|
||||
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
||||
|
||||
this._draw();
|
||||
|
@ -912,7 +914,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) {
|
||||
|
||||
|
||||
|
@ -932,7 +934,7 @@ Tetris.prototype = {
|
|||
this.currentTime = new Date().getTime();
|
||||
var deltaTime = this.currentTime - this.prevTime;
|
||||
|
||||
// todo: put in web worker
|
||||
// TODO: put in web worker--limited to 60fps here
|
||||
if(deltaTime >= 1) { // needs to be 600hz
|
||||
inputs.incDeciframes();
|
||||
//console.log(deltaTime / 600.0);
|
||||
|
@ -981,6 +983,10 @@ Tetris.prototype = {
|
|||
this.popHoldStack();
|
||||
this._update();
|
||||
}
|
||||
if(curkey == "Back") {
|
||||
this._restartHandler();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inputs.gamepadQueue = [];
|
||||
|
@ -1036,6 +1042,12 @@ Tetris.prototype = {
|
|||
else
|
||||
document.getElementById("bg").style.display="none";
|
||||
}
|
||||
if(curkey == 82) {
|
||||
views.setGameOver(true);
|
||||
this._restartHandler();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
inputs.inputqueue = [];
|
||||
}
|
||||
|
@ -1221,16 +1233,20 @@ var OpenerGenerator = {
|
|||
this.hintQueue[2].x = 8;
|
||||
this.hintQueue[2].y = 18;
|
||||
// S
|
||||
this.hintQueue[3].x = 4;
|
||||
this.hintQueue[3].y = 18;
|
||||
//this.hintQueue[3].states++;
|
||||
this.hintQueue[3].x = 6;
|
||||
this.hintQueue[3].y = 17;
|
||||
this.hintQueue[3].state = this.hintQueue[3].nextState(1);
|
||||
// Z
|
||||
this.hintQueue[4].x = 3;
|
||||
this.hintQueue[4].y = 17;
|
||||
this.hintQueue[5].x = 4;
|
||||
this.hintQueue[5].y = 4;
|
||||
this.hintQueue[6].x = 4;
|
||||
this.hintQueue[6].y = 4;
|
||||
// J
|
||||
this.hintQueue[5].x = 7;
|
||||
this.hintQueue[5].y = 16;
|
||||
this.hintQueue[5].state = this.hintQueue[5].nextState(3);
|
||||
|
||||
// T
|
||||
this.hintQueue[6].x = 1;
|
||||
this.hintQueue[6].y = 18;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
<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>
|
||||
<script>
|
||||
|
||||
|
||||
document.getElementById("bg").width = window.innerWidth;
|
||||
document.getElementById("bg").height = window.innerHeight;
|
||||
document.getElementById("bg").height = window.innerHeight;-->
|
||||
</script>
|
||||
<div id="tetris">
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ var tetrisCanvas = {
|
|||
return;
|
||||
}
|
||||
var colorRGB = this.hexToRgb(shape.color);
|
||||
var color = "rgba(" + colorRGB.r + "," + colorRGB.g + "," + colorRGB.b + "," + "0.4)";
|
||||
var color = "rgba(" + colorRGB.r + "," + colorRGB.g + "," + colorRGB.b + "," + "0.2)";
|
||||
|
||||
var matrix = shape.matrix();
|
||||
var gsize = this.gridSize;
|
||||
|
|
|
@ -24,6 +24,7 @@ var UserInputs = {
|
|||
this.gamepadButtonsDown("A");
|
||||
this.gamepadButtonsDown("B");
|
||||
this.gamepadButtonsDown("DPad-Up");
|
||||
this.gamepadButtonsDown("Back");
|
||||
//this.gamepadButtonsDown("X");
|
||||
//this.gamepadButtonsDown("Y");
|
||||
|
||||
|
@ -112,6 +113,7 @@ var UserInputs = {
|
|||
this.processKeyDown(16); // shift
|
||||
this.processKeyDown(17); // ctrl
|
||||
this.processKeyDown(81); // q
|
||||
this.processKeyDown(82); // r
|
||||
},
|
||||
|
||||
// keyboard keys z,x,space
|
||||
|
|
20
src/main.js
20
src/main.js
|
@ -173,8 +173,8 @@ Tetris.prototype = {
|
|||
this.currentTime = this.startTime;
|
||||
this.prevTime = this.startTime;
|
||||
this.levelTime = this.startTime;
|
||||
this.shapeQueue = this.shapeQueue || [];
|
||||
this.hintQueue = this.hintQueue || [];
|
||||
this.shapeQueue = [];
|
||||
this.hintQueue = [];
|
||||
this.holdQueue = [];
|
||||
this.canPullFromHoldQueue = false;
|
||||
clearMatrix(this.matrix);
|
||||
|
@ -254,7 +254,7 @@ Tetris.prototype = {
|
|||
this.hintQueue.push(this.preparedShape);
|
||||
}
|
||||
|
||||
//this.hintMino = this.hintQueue.shift();
|
||||
this.hintMino = this.hintQueue.shift();
|
||||
this.shape = this.shapeQueue.shift();// shapes.randomShape();
|
||||
|
||||
this._draw();
|
||||
|
@ -267,7 +267,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) {
|
||||
|
||||
|
||||
|
@ -287,7 +287,7 @@ Tetris.prototype = {
|
|||
this.currentTime = new Date().getTime();
|
||||
var deltaTime = this.currentTime - this.prevTime;
|
||||
|
||||
// todo: put in web worker
|
||||
// TODO: put in web worker--limited to 60fps here
|
||||
if(deltaTime >= 1) { // needs to be 600hz
|
||||
inputs.incDeciframes();
|
||||
//console.log(deltaTime / 600.0);
|
||||
|
@ -336,6 +336,10 @@ Tetris.prototype = {
|
|||
this.popHoldStack();
|
||||
this._update();
|
||||
}
|
||||
if(curkey == "Back") {
|
||||
this._restartHandler();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inputs.gamepadQueue = [];
|
||||
|
@ -391,6 +395,12 @@ Tetris.prototype = {
|
|||
else
|
||||
document.getElementById("bg").style.display="none";
|
||||
}
|
||||
if(curkey == 82) {
|
||||
views.setGameOver(true);
|
||||
this._restartHandler();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
inputs.inputqueue = [];
|
||||
}
|
||||
|
|
|
@ -106,16 +106,20 @@ var OpenerGenerator = {
|
|||
this.hintQueue[2].x = 8;
|
||||
this.hintQueue[2].y = 18;
|
||||
// S
|
||||
this.hintQueue[3].x = 4;
|
||||
this.hintQueue[3].y = 18;
|
||||
//this.hintQueue[3].states++;
|
||||
this.hintQueue[3].x = 6;
|
||||
this.hintQueue[3].y = 17;
|
||||
this.hintQueue[3].state = this.hintQueue[3].nextState(1);
|
||||
// Z
|
||||
this.hintQueue[4].x = 3;
|
||||
this.hintQueue[4].y = 17;
|
||||
this.hintQueue[5].x = 4;
|
||||
this.hintQueue[5].y = 4;
|
||||
this.hintQueue[6].x = 4;
|
||||
this.hintQueue[6].y = 4;
|
||||
// J
|
||||
this.hintQueue[5].x = 7;
|
||||
this.hintQueue[5].y = 16;
|
||||
this.hintQueue[5].state = this.hintQueue[5].nextState(3);
|
||||
|
||||
// T
|
||||
this.hintQueue[6].x = 1;
|
||||
this.hintQueue[6].y = 18;
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue