odds and ends

pull/1/head
PolicyChanges1@gmail.com 2021-03-08 15:52:04 -05:00
parent 1cccd4adf5
commit f1b4d94dc7
7 changed files with 310 additions and 293 deletions

View File

@ -42,7 +42,7 @@ body{
left:0px; left:0px;
width:210px; width:210px;
text-align: left; text-align: left;
background:rgba(200,200,200,.03); background:rgba(20,20,20,.5);
} }
#leftInfo{ #leftInfo{
@ -58,12 +58,12 @@ body{
#leftInfo ul {padding:2%;} #leftInfo ul {padding:2%;}
#hold{ #hold{
left:55px; left:45%;
position:relative; position:relative;
width:80px; width:80px;
height:400px; height:400px;
margin:5px auto; margin:5px auto;
background:rgba(1,1,1,.3); background: rgba(0,0,0,.8); /*rgba(50,50,50,.5);*/
} }
#gameOver{ #gameOver{
@ -106,7 +106,7 @@ body{
width:210px; width:210px;
left:210px; left:210px;
margin:0 auto; margin:0 auto;
background:rgba(200,200,200,.03); background:rgba(20,20,20,.5);
} }
#preview{ #preview{
@ -114,7 +114,7 @@ body{
height:400px; height:400px;
top:0px; top:0px;
margin:10px auto; margin:10px auto;
background:rgba(1,1,1,.3); background:rgba(0,0,0,.8);
} }

274
dist/tetrion.js vendored
View File

@ -428,12 +428,16 @@ var utils = require('./utils.js');
var UserInputs = { var UserInputs = {
init() { init() {
this.settingsList = this.keyboardKeySettings.concat(this.keyboardShiftEvents.concat(this.keyboardKeyEvents.concat(this.gamepadSettings.concat(this.gamepadShiftEvents.concat(this.gamepadButtonEvents)))));
//;["Soft Drop Rate [1 - 100]"].concat(this.keyboardSettings.concat(this.gamepadSettings));
this.gamepadShiftTimer = new Date(); this.gamepadShiftTimer = new Date();
this.gamepadButtonTimer = new Date(); this.gamepadButtonTimer = new Date();
this.keyboardKeyTimer = new Date(); this.keyboardKeyTimer = new Date();
this.keyboardShiftTimer = new Date(); this.keyboardShiftTimer = new Date();
this.settingsMap = new Map(); this.settingsMap = new Map();
this.gamepadEventMap = new Map();
///this.gamepadEventMap = new Map();
// var init = utils.getCookie("init"); // var init = utils.getCookie("init");
// if(init == "") // if(init == "")
for(var i in this.settingsList) for(var i in this.settingsList)
@ -445,6 +449,15 @@ var UserInputs = {
for(var i in this.settingsList) for(var i in this.settingsList)
this.settingsMap.set(this.settingsList[i], this.settingsDefault[i]); this.settingsMap.set(this.settingsList[i], this.settingsDefault[i]);
this.gamepadEvents = this.gamepadShiftEvents.concat(this.gameButtonsEvents);
var mapIdx = [14, 7, 13, 5, 4, 1, 2, 12, 8, 3];
for(var i in mapIdx) {
this.gamepadEventMap.set(this.gamepadEvents[i], gamepad.buttons[mapIdx[i]]);
}
document.addEventListener('keydown', this.keyDown.bind(this)); document.addEventListener('keydown', this.keyDown.bind(this));
document.addEventListener('keyup', this.keyUp.bind(this)); document.addEventListener('keyup', this.keyUp.bind(this));
}, },
@ -455,25 +468,11 @@ var UserInputs = {
gamepadEnabled() { gamepadEnabled() {
return gamepad.controller || false; return gamepad.controller || false;
}, },
processGamepadInput() { processGamepadInput() {
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Harddrop")); // hard drop this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Hold")); // hold
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Rotateccw")); // rotate counter
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Rotate")); // rotate cwise
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Pophold")); // Pop hold stack
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Reset")); // reset
return;
}, },
processGamepadDPad() { processGamepadDPad() {
this.gamepadDPadDown(this.settingsMap.get("Gamepad Left")); // shift left this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
this.gamepadDPadDown(this.settingsMap.get("Gamepad Right")); // shift right
this.gamepadDPadDown(this.settingsMap.get("Gamepad Down")); // down
return;
}, },
// Single press gamepad buttons // Single press gamepad buttons
gamepadButtonsDown(finds) { gamepadButtonsDown(finds) {
@ -512,6 +511,7 @@ var UserInputs = {
gamepadDPadDown(finds) { gamepadDPadDown(finds) {
var DAS = parseInt(this.settingsMap.get("Gamepad DAS")); var DAS = parseInt(this.settingsMap.get("Gamepad DAS"));
var ARR = parseInt(this.settingsMap.get("Gamepad ARR")); var ARR = parseInt(this.settingsMap.get("Gamepad ARR"));
var isContained = this.gpButtons.includes(finds); var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds); var isPrevContained = this.prevGpButtons.includes(finds);
@ -538,20 +538,11 @@ var UserInputs = {
this.gamepadShiftTimer = new Date(); this.gamepadShiftTimer = new Date();
} }
} }
return; return;
}, },
// doing a lot of back and forth between strings and integers to represtent the same thing -- todo: fix
processKeys() { processKeys() {
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset")));
//this.processKeyDown(this.settingsMap.get("Keyboard hold"))); // c - pop hold stack
}, },
// keyboard keys z,x,space // keyboard keys z,x,space
@ -583,15 +574,10 @@ var UserInputs = {
this.keyboardKeyTimer = new Date(); this.keyboardKeyTimer = new Date();
} }
} }
}, },
// Process applicable key inputs // Process applicable key inputs
processKeyShift() { processKeyShift() {
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right")));
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down")));
}, },
// Direction arrows // Direction arrows
processKeyboardArrowKeys(key) { processKeyboardArrowKeys(key) {
@ -637,11 +623,9 @@ var UserInputs = {
this.keyboardKeys[event.keyCode] = false; this.keyboardKeys[event.keyCode] = false;
this.isKeyBoardKeyDown = false; this.isKeyBoardKeyDown = false;
}, },
gamepadButtonClear() { gamepadClear() {
gpButtons = []; //this.gpButtons = [];
isGamepadDown = false; //this.gamepadQueue = [];
isGamepadButtonDown = false;
gamepadQueue = [];
}, },
saveButtons() { saveButtons() {
this.prevGpButtons = this.gpButtons; this.prevGpButtons = this.gpButtons;
@ -665,26 +649,24 @@ var UserInputs = {
// button pressed containers // button pressed containers
inputQueue: [], inputQueue: [],
gamepadQueue: [], gamepadQueue: [],
settingsList: ["Soft Drop Rate [1 - 100]", keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
"Keyboard DAS", "Keyboard ARR", "Keyboard Harddrop", "Keyboard Hold", keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down"],
"Keyboard Left", "Keyboard Right", "Keyboard Rotateccw", "Keyboard Rotate", keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
"Keyboard Down", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background",
"Gamepad DAS", "Gamepad ARR", "Gamepad Harddrop", "Gamepad Hold", gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
"Gamepad Left", "Gamepad Right", "Gamepad Rotateccw", "Gamepad Rotate", gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
"Gamepad Down","Gamepad Pophold", "Gamepad Reset", "Gamepad Background", gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
"path", "High Score"],
settingsList: [],
settingsDefault: ["70",
"167.0", "33.0", "32", "16", settingsDefault: [ "167.0", "33.0",
"37", "39", "90", "88", "37", "39", "40",
"40", "17", "82", "81", "32", "16", "90", "88,38", "17", "82", "81",
"167.0", "33.0", "RB", "LB", "167.0", "33.0",
"DPad-Left", "DPad-Right", "A", "B", "DPad-Left", "DPad-Right", "DPad-Down",
"DPad-Down", "DPad-Up", "Back", "", "RB", "LB", "A", "B", "DPad-Up", "Back", ""],
"=/",""],
settingsMap: [] settingsMap: []
}; };
@ -839,11 +821,7 @@ function Tetris(id) {
} }
Tetris.prototype = { Tetris.prototype = {
init: function(options) { init: function(options) {
// this gameStates = {"
// this.state =
var cfg = this.config = utils.extend(options, defaults); var cfg = this.config = utils.extend(options, defaults);
this.interval = consts.DEFAULT_INTERVAL; this.interval = consts.DEFAULT_INTERVAL;
@ -950,6 +928,7 @@ Tetris.prototype = {
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this.holdStack = []; this.holdStack = [];
this.shape = shapes.getShape(0);
// gets set to false after mino has been popped from hold stack; set back to true on mino dropped // gets set to false after mino has been popped from hold stack; set back to true on mino dropped
this.canPopFromHoldStack = false; this.canPopFromHoldStack = false;
// manipulation counter for srs extended piece lockdown // manipulation counter for srs extended piece lockdown
@ -1042,14 +1021,19 @@ 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.isSequenceCompleted = true;
}
}
this.hintQueue = []; this.hintQueue = [];
this.shapeQueue = []; this.shapeQueue = [];
this.isSequenceCompleted = true;
// Recursion warning // Recursion warning
this._restartHandler(); this._restartHandler();
// this.reset();
// this.start();
return;
} }
} else { } else {
while(this.shapeQueue.length <= 4) while(this.shapeQueue.length <= 4)
@ -1112,21 +1096,17 @@ Tetris.prototype = {
}, },
// tick input data -- wont have better than 4-15ms resolution since javascript is single theaded and any ARR or DAS below 15ms will likely be broken // tick input data -- wont have better than 4-15ms resolution since javascript is single theaded and any ARR or DAS below 15ms will likely be broken
_processTick: async function() { _processTick: async function() {
//var deltaTime = (new Date()).getTime() - this.eventTimer.getTime();
//console.log("desync time: " + deltaTime);
if(this.isTimerOn) { if(this.isTimerOn) {
var deltaPlayTime = new Date().getTime() - this.sequencePrevTime; var deltaPlayTime = new Date().getTime() - this.sequencePrevTime;
document.getElementById("Time").value = (deltaPlayTime/1000).toString(); document.getElementById("Time").value = (deltaPlayTime/1000).toString();
} }
// Don't process game related events if game over // Don't process game related events if game over
if(this.isGameOver) return; if(this.isGameOver) return;
@ -1145,56 +1125,52 @@ Tetris.prototype = {
// drain gamepad queue // drain gamepad queue
// if( inputs.getTickCounter() > halfFrame) // 8 millisecons // if( inputs.getTickCounter() > halfFrame) // 8 millisecons
// { // {
while((inputs.gamepadQueue != undefined && inputs.gamepadQueue.length >= 1)){ while((inputs.gamepadQueue != undefined && inputs.gamepadQueue.length >= 1)){
var curkey = inputs.gamepadQueue.shift(); var curkey = inputs.gamepadQueue.shift();
if(curkey == "DPad-Left") { if(inputs.settingsMap.get("Gamepad Left").includes(curkey)) {
this.shape.goLeft(this.matrix); this.shape.goLeft(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
}
if(curkey == "DPad-Right") {
this.shape.goRight(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "A") {
this.rotationCounter++;
this.shape.rotate(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "B") {
this.rotationCounter++;
this.shape.rotateClockwise(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "DPad-Down") {
this.shape.goDown(this.matrix);
this._draw();
}
if(curkey == "RB") {
this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000;
this._update();
}
if(curkey == "LB") {
this.pushHoldStack();
this._draw();
}
if(curkey == "DPad-Up") {
this.popHoldStack();
this._draw();
}
if(curkey == "Back") {
this._restartHandler();
return;
}
} }
else if(inputs.settingsMap.get("Gamepad Right").includes(curkey)) {
inputs.gamepadQueue = []; this.shape.goRight(this.matrix);
// } this.resetLockdown();
//inputs.gamepadButtonClear(); this._draw();
}
else if(inputs.settingsMap.get("Gamepad Rotateccw").includes(curkey)) {
this.shape.rotate(this.matrix);
this.resetLockdown();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Rotate").includes(curkey)) {
this.shape.rotateClockwise(this.matrix);
this.resetLockdown();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Down").includes(curkey)) {
this.shape.goDown(this.matrix);
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Harddrop").includes(curkey)) {
this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000;
this._update();
}
else if(inputs.settingsMap.get("Gamepad Hold").includes(curkey)) {
this.pushHoldStack();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Pophold").includes(curkey)) {
this.popHoldStack();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Reset").includes(curkey)) {
this._restartHandler();
return;
}
}
inputs.saveButtons();
inputs.gamepadClear();
} }
@ -1204,54 +1180,51 @@ Tetris.prototype = {
// Keyboard inputs // Keyboard inputs
while((inputs.inputQueue != undefined && inputs.inputQueue.length >= 1)){ while((inputs.inputQueue != undefined && inputs.inputQueue.length >= 1)){
var curkey = inputs.inputQueue.shift(); var curkey = inputs.inputQueue.shift();
if(curkey == 37) { if(inputs.settingsMap.get("Keyboard Left").includes(curkey)) {
this.debugTimer = new Date();
this.shape.goLeft(this.matrix); this.shape.goLeft(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 39){ else if(inputs.settingsMap.get("Keyboard Right").includes(curkey)) {
this.shape.goRight(this.matrix); this.shape.goRight(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 40) { else if(inputs.settingsMap.get("Keyboard Down").includes(curkey)) {
this.shape.goDown(this.matrix); this.shape.goDown(this.matrix);
this._draw(); this._draw();
} }
if(curkey == 90) { else if(inputs.settingsMap.get("Keyboard Rotateccw").includes(curkey)) {
this.rotationCounter++;
this.shape.rotate(this.matrix); this.shape.rotate(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 88){ else if(inputs.settingsMap.get("Keyboard Rotate").includes(curkey)) {
this.rotationCounter++;
this.shape.rotateClockwise(this.matrix); this.shape.rotateClockwise(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 32) { else if(inputs.settingsMap.get("Keyboard Harddrop").includes(curkey)) {
this.shape.goBottom(this.matrix); this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000; this.lockDownTimer = 5000;
this._update(); this._update();
} }
if(curkey == 16) { else if(inputs.settingsMap.get("Keyboard Hold").includes(curkey)) {
this.pushHoldStack(); this.pushHoldStack();
this._draw(); this._draw();
} }
if(curkey == 17 || curkey == 67) { else if(inputs.settingsMap.get("Keyboard Pophold").includes(curkey)) {
this.popHoldStack(); this.popHoldStack();
this._draw(); this._draw();
} }
if(curkey == 81) { else if(inputs.settingsMap.get("Keyboard Hold").includes(curkey)) {
if(document.getElementById("divbg").style.display == "none") if(document.getElementById("divbg").style.display == "none")
document.getElementById("divbg").style.display = "initial"; document.getElementById("divbg").style.display = "initial";
else else
document.getElementById("divbg").style.display="none"; document.getElementById("divbg").style.display="none";
} }
if(curkey == 82) { if(inputs.settingsMap.get("Keyboard Reset").includes(curkey)) {
this._restartHandler(); this._restartHandler();
return; return;
} }
@ -1387,7 +1360,8 @@ Tetris.prototype = {
views.setLevel(this.level); views.setLevel(this.level);
this.levelTime = currentTime; this.levelTime = currentTime;
} }
} },
} }
@ -1539,6 +1513,17 @@ var openerGenerator = {
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(3)); shapes.getShape(3));
break;
case 9:
// Pelican
this.shapeQueue = new Array(
shapes.getShape(5),
shapes.getShape(2),
shapes.getShape(4),
shapes.getShape(0),
shapes.getShape(6),
shapes.getShape(1),
shapes.getShape(3));
break; break;
default: default:
return; return;
@ -1567,6 +1552,8 @@ var openerGenerator = {
switch(opener) { switch(opener) {
case 0: case 0:
this.hintQueue = [];
break;
case 1: case 1:
// Fonzie Variation // Fonzie Variation
this.hintQueue = new Array( this.hintQueue = new Array(
@ -1766,6 +1753,25 @@ var openerGenerator = {
this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]); this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]);
} }
break; break;
case 9:
// Pelican
this.hintQueue = new Array(
shapes.getShape(5),
shapes.getShape(2),
shapes.getShape(4),
shapes.getShape(0),
shapes.getShape(6),
shapes.getShape(1),
shapes.getShape(3));
var hintDataList = [0,17,-1, 1,16,2, 5,18,0, 5,16,-1, 8,16,-1, 5,17,0, 3,16,2];
for(var i = 0; i < this.hintQueue.length; i++) {
this.hintQueue[i].x = hintDataList[i * 3];
this.hintQueue[i].y = hintDataList[i * 3 + 1];
this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]);
}
break;
default: default:
return; return;
} }

View File

@ -39,28 +39,28 @@
<div id="divbg"> <div id="divbg">
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/4lBGDh?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/4lBGDh?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> -->
<!-- <iframe width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3tXBWj?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> --> <!-- <iframe width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3tXBWj?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> -->
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/Xlf3Rj?gui=true&t=10&paused=false&muted=false" allowfullscreen></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/Xlf3Rj?gui=true&t=10&paused=false&muted=false" allowfullscreen></iframe> -->
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/tdjyzz?gui=true&t=10&paused=false&muted=false" allowfullscreen></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/tdjyzz?gui=true&t=10&paused=false&muted=false" allowfullscreen></iframe> -->
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3lVfDm?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3lVfDm?gui=true&t=10&paused=true&muted=false" allowfullscreen></iframe> -->
<iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/WldfWX?gui=&paused=false&muted=false" ></iframe>
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/MlSSRt?gui=&paused=false&muted=false" allowfullscreen></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/MlSSRt?gui=&paused=false&muted=false" allowfullscreen></iframe> -->
<!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3sy3Wy?gui=true&t=10&paused=false&muted=false" ></iframe> --> <!-- <iframe id="bg" width="640" height="360" frameborder="0" src="https://www.shadertoy.com/embed/3sy3Wy?gui=true&t=10&paused=false&muted=false" ></iframe> -->
<iframe id="bg" width="640" height="360" frameborder="0" src="" ></iframe>
<script> <script>
if( (Math.floor(Math.random() * Math.floor(10)) % 10) == 0) {
document.getElementById("bg").src="https://www.shadertoy.com/embed/MlSSRt?gui=&paused=false&muted=false";
document.getElementById("bg").style.webkitFilter = "blur(4px)";
}
else
document.getElementById("bg").src="https://www.shadertoy.com/embed/WldfWX?gui=&paused=false&muted=false";
document.getElementById("bg").width = window.innerWidth; document.getElementById("bg").width = window.innerWidth;
document.getElementById("bg").height = window.innerHeight; document.getElementById("bg").height = window.innerHeight;
document.getElementById("bg").removeAttribute("tabIndex"); document.getElementById("bg").removeAttribute("tabIndex");
document.getElementById("divbg").removeAttribute("tabIndex"); document.getElementById("divbg").removeAttribute("tabIndex");
</script> </script>
@ -124,7 +124,6 @@ document.getElementById("divbg").removeAttribute("tabIndex");
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLnJVar">Neither L nor J </a></li> <li style="font-size:12px;padding-left:1em;"><a href="#" id="setLnJVar">Neither L nor J </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLaJVar">Both L and J </a></li> <li style="font-size:12px;padding-left:1em;"><a href="#" id="setLaJVar">Both L and J </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setPCTPieceVar">T piece </a></li> <li style="font-size:12px;padding-left:1em;"><a href="#" id="setPCTPieceVar">T piece </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setSAVar">see also </a></li>
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -133,11 +132,11 @@ document.getElementById("divbg").removeAttribute("tabIndex");
<canvas style="border: 1px solid #6666;" id="hold"></canvas> <canvas style="border: 1px solid #6666;" id="hold"></canvas>
<br> <br>
<br> <br>
<input style="padding-left:12px;text-decoration:underline;overflow:visible;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" type="button" id="Timer" value="Timer Off"/> <input style="padding-left:12px;text-decoration:underline;overflow:visible;font-size:12px;background:rgba(40,40,40,.5);color:powderblue;border:1px solid #6666;text-align:left;" type="button" id="Timer" value="Timer Off"/>
<input disabled=true style="padding:1px;overflow:visible;width:70px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="Time" value=""/> <input disabled=true style="padding:1px;overflow:visible;width:70px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="Time" value=""/>
<input disabled=true style="overflow:visible;width:63px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttimetext" value="Best Time:"/> <input disabled=true style="overflow:visible;width:63px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttimetext" value="Best Time:"/>
<input disabled=true style="overflow:visible;width:68px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttime" value=""/> <input disabled=true style="overflow:visible;width:68px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttime" value=""/>
</div> </div>
<div id="gameOver"> <div id="gameOver">
@ -155,14 +154,14 @@ document.getElementById("divbg").removeAttribute("tabIndex");
<canvas style="border: 1px solid #6666;" id="preview"></canvas> <canvas style="border: 1px solid #6666;" id="preview"></canvas>
<br> <br>
<select style="width:80px;font-size:13px;background:rgba(40,40,40,0);color:dodgerblue;border: 1px solid #6666;text-align:left;" id="settings" name="setting"> <select style="width:80px;font-size:13px;background:rgba(40,40,40,.5);color:dodgerblue;border: 1px solid #6666;text-align:left;" id="settings" name="setting">
<option selected="">Settings:</option> <option selected="">Settings:</option>
</select> </select>
<input style="width:50px;font-size:13px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="setting_value"> <input style="width:50px;font-size:13px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="setting_value">
<input style="width:45px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" id="submitsetting" type="submit" value="Set"></input> <input style="width:45px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="submitsetting" type="submit" value="Set"></input>
<br> <br>
<input style="width:70px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" id="test" type="submit" value="Hide Hints"></input> <input style="width:70px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="test" type="submit" value="Hide Hints"></input>
<input style="width:110px;font-size:12px;background:rgba(40,40,40,0);color:dodgerblue;border:1px solid #6666;text-align:left;" id="enablegamepad" type="button" value="Enable Gamepad"/> <input style="width:110px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="enablegamepad" type="button" value="Enable Gamepad"/>
</div> </div>
@ -185,6 +184,8 @@ document.getElementById("divbg").removeAttribute("tabIndex");
document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } ); document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } );
document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } ); document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } );
document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } ); document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } );
document.getElementById("setPelicanVar").addEventListener("click", function() { tetrion.setCurrentOpener(9); } );
document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } ); document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );
@ -193,6 +194,8 @@ document.getElementById("divbg").removeAttribute("tabIndex");
document.getElementById("test").addEventListener("click", function() { tetrion.setDoTest(); } ); document.getElementById("test").addEventListener("click", function() { tetrion.setDoTest(); } );
document.getElementById("settings").addEventListener("change", function() { tetrion.updateSettingTextBox(); } ); document.getElementById("settings").addEventListener("change", function() { tetrion.updateSettingTextBox(); } );
document.getElementById("submitsetting").addEventListener("click", function() { tetrion.setSettings(); } ); document.getElementById("submitsetting").addEventListener("click", function() { tetrion.setSettings(); } );
tetrion.start(); tetrion.start();
})(); })();
</script> </script>

View File

@ -4,12 +4,16 @@ var utils = require('./utils.js');
var UserInputs = { var UserInputs = {
init() { init() {
this.settingsList = this.keyboardKeySettings.concat(this.keyboardShiftEvents.concat(this.keyboardKeyEvents.concat(this.gamepadSettings.concat(this.gamepadShiftEvents.concat(this.gamepadButtonEvents)))));
//;["Soft Drop Rate [1 - 100]"].concat(this.keyboardSettings.concat(this.gamepadSettings));
this.gamepadShiftTimer = new Date(); this.gamepadShiftTimer = new Date();
this.gamepadButtonTimer = new Date(); this.gamepadButtonTimer = new Date();
this.keyboardKeyTimer = new Date(); this.keyboardKeyTimer = new Date();
this.keyboardShiftTimer = new Date(); this.keyboardShiftTimer = new Date();
this.settingsMap = new Map(); this.settingsMap = new Map();
this.gamepadEventMap = new Map();
///this.gamepadEventMap = new Map();
// var init = utils.getCookie("init"); // var init = utils.getCookie("init");
// if(init == "") // if(init == "")
for(var i in this.settingsList) for(var i in this.settingsList)
@ -21,6 +25,15 @@ var UserInputs = {
for(var i in this.settingsList) for(var i in this.settingsList)
this.settingsMap.set(this.settingsList[i], this.settingsDefault[i]); this.settingsMap.set(this.settingsList[i], this.settingsDefault[i]);
this.gamepadEvents = this.gamepadShiftEvents.concat(this.gameButtonsEvents);
var mapIdx = [14, 7, 13, 5, 4, 1, 2, 12, 8, 3];
for(var i in mapIdx) {
this.gamepadEventMap.set(this.gamepadEvents[i], gamepad.buttons[mapIdx[i]]);
}
document.addEventListener('keydown', this.keyDown.bind(this)); document.addEventListener('keydown', this.keyDown.bind(this));
document.addEventListener('keyup', this.keyUp.bind(this)); document.addEventListener('keyup', this.keyUp.bind(this));
}, },
@ -31,25 +44,11 @@ var UserInputs = {
gamepadEnabled() { gamepadEnabled() {
return gamepad.controller || false; return gamepad.controller || false;
}, },
processGamepadInput() { processGamepadInput() {
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Harddrop")); // hard drop this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Hold")); // hold
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Rotateccw")); // rotate counter
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Rotate")); // rotate cwise
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Pophold")); // Pop hold stack
this.gamepadButtonsDown(this.settingsMap.get("Gamepad Reset")); // reset
return;
}, },
processGamepadDPad() { processGamepadDPad() {
this.gamepadDPadDown(this.settingsMap.get("Gamepad Left")); // shift left this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
this.gamepadDPadDown(this.settingsMap.get("Gamepad Right")); // shift right
this.gamepadDPadDown(this.settingsMap.get("Gamepad Down")); // down
return;
}, },
// Single press gamepad buttons // Single press gamepad buttons
gamepadButtonsDown(finds) { gamepadButtonsDown(finds) {
@ -88,6 +87,7 @@ var UserInputs = {
gamepadDPadDown(finds) { gamepadDPadDown(finds) {
var DAS = parseInt(this.settingsMap.get("Gamepad DAS")); var DAS = parseInt(this.settingsMap.get("Gamepad DAS"));
var ARR = parseInt(this.settingsMap.get("Gamepad ARR")); var ARR = parseInt(this.settingsMap.get("Gamepad ARR"));
var isContained = this.gpButtons.includes(finds); var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds); var isPrevContained = this.prevGpButtons.includes(finds);
@ -114,20 +114,11 @@ var UserInputs = {
this.gamepadShiftTimer = new Date(); this.gamepadShiftTimer = new Date();
} }
} }
return; return;
}, },
// doing a lot of back and forth between strings and integers to represtent the same thing -- todo: fix
processKeys() { processKeys() {
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background")));
this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset")));
//this.processKeyDown(this.settingsMap.get("Keyboard hold"))); // c - pop hold stack
}, },
// keyboard keys z,x,space // keyboard keys z,x,space
@ -159,15 +150,10 @@ var UserInputs = {
this.keyboardKeyTimer = new Date(); this.keyboardKeyTimer = new Date();
} }
} }
}, },
// Process applicable key inputs // Process applicable key inputs
processKeyShift() { processKeyShift() {
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right")));
this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down")));
}, },
// Direction arrows // Direction arrows
processKeyboardArrowKeys(key) { processKeyboardArrowKeys(key) {
@ -213,11 +199,9 @@ var UserInputs = {
this.keyboardKeys[event.keyCode] = false; this.keyboardKeys[event.keyCode] = false;
this.isKeyBoardKeyDown = false; this.isKeyBoardKeyDown = false;
}, },
gamepadButtonClear() { gamepadClear() {
gpButtons = []; //this.gpButtons = [];
isGamepadDown = false; //this.gamepadQueue = [];
isGamepadButtonDown = false;
gamepadQueue = [];
}, },
saveButtons() { saveButtons() {
this.prevGpButtons = this.gpButtons; this.prevGpButtons = this.gpButtons;
@ -241,26 +225,24 @@ var UserInputs = {
// button pressed containers // button pressed containers
inputQueue: [], inputQueue: [],
gamepadQueue: [], gamepadQueue: [],
settingsList: ["Soft Drop Rate [1 - 100]", keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
"Keyboard DAS", "Keyboard ARR", "Keyboard Harddrop", "Keyboard Hold", keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down"],
"Keyboard Left", "Keyboard Right", "Keyboard Rotateccw", "Keyboard Rotate", keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
"Keyboard Down", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background",
"Gamepad DAS", "Gamepad ARR", "Gamepad Harddrop", "Gamepad Hold", gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
"Gamepad Left", "Gamepad Right", "Gamepad Rotateccw", "Gamepad Rotate", gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
"Gamepad Down","Gamepad Pophold", "Gamepad Reset", "Gamepad Background", gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
"path", "High Score"],
settingsList: [],
settingsDefault: ["70",
"167.0", "33.0", "32", "16", settingsDefault: [ "167.0", "33.0",
"37", "39", "90", "88", "37", "39", "40",
"40", "17", "82", "81", "32", "16", "90", "88,38", "17", "82", "81",
"167.0", "33.0", "RB", "LB", "167.0", "33.0",
"DPad-Left", "DPad-Right", "A", "B", "DPad-Left", "DPad-Right", "DPad-Down",
"DPad-Down", "DPad-Up", "Back", "", "RB", "LB", "A", "B", "DPad-Up", "Back", ""],
"=/",""],
settingsMap: [] settingsMap: []
}; };

View File

@ -146,11 +146,7 @@ function Tetris(id) {
} }
Tetris.prototype = { Tetris.prototype = {
init: function(options) { init: function(options) {
// this gameStates = {"
// this.state =
var cfg = this.config = utils.extend(options, defaults); var cfg = this.config = utils.extend(options, defaults);
this.interval = consts.DEFAULT_INTERVAL; this.interval = consts.DEFAULT_INTERVAL;
@ -257,6 +253,7 @@ Tetris.prototype = {
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this.holdStack = []; this.holdStack = [];
this.shape = shapes.getShape(0);
// gets set to false after mino has been popped from hold stack; set back to true on mino dropped // gets set to false after mino has been popped from hold stack; set back to true on mino dropped
this.canPopFromHoldStack = false; this.canPopFromHoldStack = false;
// manipulation counter for srs extended piece lockdown // manipulation counter for srs extended piece lockdown
@ -349,14 +346,19 @@ 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.isSequenceCompleted = true;
}
}
this.hintQueue = []; this.hintQueue = [];
this.shapeQueue = []; this.shapeQueue = [];
this.isSequenceCompleted = true;
// Recursion warning // Recursion warning
this._restartHandler(); this._restartHandler();
// this.reset();
// this.start();
return;
} }
} else { } else {
while(this.shapeQueue.length <= 4) while(this.shapeQueue.length <= 4)
@ -419,21 +421,17 @@ Tetris.prototype = {
}, },
// tick input data -- wont have better than 4-15ms resolution since javascript is single theaded and any ARR or DAS below 15ms will likely be broken // tick input data -- wont have better than 4-15ms resolution since javascript is single theaded and any ARR or DAS below 15ms will likely be broken
_processTick: async function() { _processTick: async function() {
//var deltaTime = (new Date()).getTime() - this.eventTimer.getTime();
//console.log("desync time: " + deltaTime);
if(this.isTimerOn) { if(this.isTimerOn) {
var deltaPlayTime = new Date().getTime() - this.sequencePrevTime; var deltaPlayTime = new Date().getTime() - this.sequencePrevTime;
document.getElementById("Time").value = (deltaPlayTime/1000).toString(); document.getElementById("Time").value = (deltaPlayTime/1000).toString();
} }
// Don't process game related events if game over // Don't process game related events if game over
if(this.isGameOver) return; if(this.isGameOver) return;
@ -452,56 +450,52 @@ Tetris.prototype = {
// drain gamepad queue // drain gamepad queue
// if( inputs.getTickCounter() > halfFrame) // 8 millisecons // if( inputs.getTickCounter() > halfFrame) // 8 millisecons
// { // {
while((inputs.gamepadQueue != undefined && inputs.gamepadQueue.length >= 1)){ while((inputs.gamepadQueue != undefined && inputs.gamepadQueue.length >= 1)){
var curkey = inputs.gamepadQueue.shift(); var curkey = inputs.gamepadQueue.shift();
if(curkey == "DPad-Left") { if(inputs.settingsMap.get("Gamepad Left").includes(curkey)) {
this.shape.goLeft(this.matrix); this.shape.goLeft(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
}
if(curkey == "DPad-Right") {
this.shape.goRight(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "A") {
this.rotationCounter++;
this.shape.rotate(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "B") {
this.rotationCounter++;
this.shape.rotateClockwise(this.matrix);
this.resetLockdown();
this._draw();
}
if(curkey == "DPad-Down") {
this.shape.goDown(this.matrix);
this._draw();
}
if(curkey == "RB") {
this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000;
this._update();
}
if(curkey == "LB") {
this.pushHoldStack();
this._draw();
}
if(curkey == "DPad-Up") {
this.popHoldStack();
this._draw();
}
if(curkey == "Back") {
this._restartHandler();
return;
}
} }
else if(inputs.settingsMap.get("Gamepad Right").includes(curkey)) {
inputs.gamepadQueue = []; this.shape.goRight(this.matrix);
// } this.resetLockdown();
//inputs.gamepadButtonClear(); this._draw();
}
else if(inputs.settingsMap.get("Gamepad Rotateccw").includes(curkey)) {
this.shape.rotate(this.matrix);
this.resetLockdown();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Rotate").includes(curkey)) {
this.shape.rotateClockwise(this.matrix);
this.resetLockdown();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Down").includes(curkey)) {
this.shape.goDown(this.matrix);
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Harddrop").includes(curkey)) {
this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000;
this._update();
}
else if(inputs.settingsMap.get("Gamepad Hold").includes(curkey)) {
this.pushHoldStack();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Pophold").includes(curkey)) {
this.popHoldStack();
this._draw();
}
else if(inputs.settingsMap.get("Gamepad Reset").includes(curkey)) {
this._restartHandler();
return;
}
}
inputs.saveButtons();
inputs.gamepadClear();
} }
@ -511,54 +505,51 @@ Tetris.prototype = {
// Keyboard inputs // Keyboard inputs
while((inputs.inputQueue != undefined && inputs.inputQueue.length >= 1)){ while((inputs.inputQueue != undefined && inputs.inputQueue.length >= 1)){
var curkey = inputs.inputQueue.shift(); var curkey = inputs.inputQueue.shift();
if(curkey == 37) { if(inputs.settingsMap.get("Keyboard Left").includes(curkey)) {
this.debugTimer = new Date();
this.shape.goLeft(this.matrix); this.shape.goLeft(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 39){ else if(inputs.settingsMap.get("Keyboard Right").includes(curkey)) {
this.shape.goRight(this.matrix); this.shape.goRight(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 40) { else if(inputs.settingsMap.get("Keyboard Down").includes(curkey)) {
this.shape.goDown(this.matrix); this.shape.goDown(this.matrix);
this._draw(); this._draw();
} }
if(curkey == 90) { else if(inputs.settingsMap.get("Keyboard Rotateccw").includes(curkey)) {
this.rotationCounter++;
this.shape.rotate(this.matrix); this.shape.rotate(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 88){ else if(inputs.settingsMap.get("Keyboard Rotate").includes(curkey)) {
this.rotationCounter++;
this.shape.rotateClockwise(this.matrix); this.shape.rotateClockwise(this.matrix);
this.resetLockdown(); this.resetLockdown();
this._draw(); this._draw();
} }
if(curkey == 32) { else if(inputs.settingsMap.get("Keyboard Harddrop").includes(curkey)) {
this.shape.goBottom(this.matrix); this.shape.goBottom(this.matrix);
this.lockDownTimer = 5000; this.lockDownTimer = 5000;
this._update(); this._update();
} }
if(curkey == 16) { else if(inputs.settingsMap.get("Keyboard Hold").includes(curkey)) {
this.pushHoldStack(); this.pushHoldStack();
this._draw(); this._draw();
} }
if(curkey == 17 || curkey == 67) { else if(inputs.settingsMap.get("Keyboard Pophold").includes(curkey)) {
this.popHoldStack(); this.popHoldStack();
this._draw(); this._draw();
} }
if(curkey == 81) { else if(inputs.settingsMap.get("Keyboard Hold").includes(curkey)) {
if(document.getElementById("divbg").style.display == "none") if(document.getElementById("divbg").style.display == "none")
document.getElementById("divbg").style.display = "initial"; document.getElementById("divbg").style.display = "initial";
else else
document.getElementById("divbg").style.display="none"; document.getElementById("divbg").style.display="none";
} }
if(curkey == 82) { if(inputs.settingsMap.get("Keyboard Reset").includes(curkey)) {
this._restartHandler(); this._restartHandler();
return; return;
} }
@ -694,7 +685,8 @@ Tetris.prototype = {
views.setLevel(this.level); views.setLevel(this.level);
this.levelTime = currentTime; this.levelTime = currentTime;
} }
} },
} }

View File

@ -143,6 +143,17 @@ var openerGenerator = {
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(3)); shapes.getShape(3));
break;
case 9:
// Pelican
this.shapeQueue = new Array(
shapes.getShape(5),
shapes.getShape(2),
shapes.getShape(4),
shapes.getShape(0),
shapes.getShape(6),
shapes.getShape(1),
shapes.getShape(3));
break; break;
default: default:
return; return;
@ -171,6 +182,8 @@ var openerGenerator = {
switch(opener) { switch(opener) {
case 0: case 0:
this.hintQueue = [];
break;
case 1: case 1:
// Fonzie Variation // Fonzie Variation
this.hintQueue = new Array( this.hintQueue = new Array(
@ -370,6 +383,25 @@ var openerGenerator = {
this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]); this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]);
} }
break; break;
case 9:
// Pelican
this.hintQueue = new Array(
shapes.getShape(5),
shapes.getShape(2),
shapes.getShape(4),
shapes.getShape(0),
shapes.getShape(6),
shapes.getShape(1),
shapes.getShape(3));
var hintDataList = [0,17,-1, 1,16,2, 5,18,0, 5,16,-1, 8,16,-1, 5,17,0, 3,16,2];
for(var i = 0; i < this.hintQueue.length; i++) {
this.hintQueue[i].x = hintDataList[i * 3];
this.hintQueue[i].y = hintDataList[i * 3 + 1];
this.hintQueue[i].state = this.hintQueue[i].nextState(hintDataList[i * 3 + 2]);
}
break;
default: default:
return; return;
} }

View File

@ -46,6 +46,7 @@ var sequence = {
}; };
/*
var sequences = { var sequences = {
this.sequenceList = []; this.sequenceList = [];
this.currentMino = []; this.currentMino = [];
@ -63,6 +64,7 @@ var sequences = {
sequenceList = []; sequenceList = [];
} }
}; };
*/
function getNextMino() { function getNextMino() {
currentSequence.popMino(); currentSequence.popMino();