This commit is contained in:
PolicyChanges1@gmail.com 2021-05-04 22:44:48 -04:00
parent fa37f623f1
commit 5093a568f6
10 changed files with 4000 additions and 3996 deletions

42
LICENSE
View File

@ -1,21 +1,21 @@
MIT License
Copyright (c) 2021 PolicyChanges
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2021 PolicyChanges
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,22 +1,22 @@
# Tetrion Opening Trainer
# PolicyChanges (2021)
# MIT Liecense
# [Tetrion](http://policychanges.github.io)
Tetris
This is a small html5 tetris game , written by pure javascript and html5 canvas,modular by browserify.
Just a practice, if you are interested in writing html5 games,check the code and have fun!
Demo
[Tetris Game](http://sandywalker.github.io/Tetris/)
License
MIT © Sandy Duan
# Tetrion Opening Trainer
# PolicyChanges (2021)
# MIT Liecense
# [Tetrion](http://policychanges.github.io)
Tetris
This is a small html5 tetris game , written by pure javascript and html5 canvas,modular by browserify.
Just a practice, if you are interested in writing html5 games,check the code and have fun!
Demo
[Tetris Game](http://sandywalker.github.io/Tetris/)
License
MIT © Sandy Duan

3667
dist/tetrion.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,214 +1,220 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}
</style>
<title>Tetrion Opening Trainer</title>
<link rel="stylesheet" href="css/styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--insert shadertoy background-->
<!--https://www.shadertoy.com/embed/wttfW2?gui=&t=10&paused=false&muted=false-->
<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 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/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/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="" ></iframe>
<script>
if( (Math.floor(Math.random() * Math.floor(10)) % 3) == 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";
var resizebg = function() {
document.getElementById("bg").width = window.innerWidth;
document.getElementById("bg").height = window.innerHeight;
};
window.addEventListener("resize", function() { this.resizebg(); } );
document.getElementById("bg").removeAttribute("tabIndex");
document.getElementById("divbg").removeAttribute("tabIndex");
this.resizebg();
</script>
</div>
<div id="tetris">
<canvas id="scene"></canvas>
<div id="leftSide">
<div id="leftInfo">
<style>
a:link, a:visited {
color: powderblue;
background-color: transparent;
/*text-decoration: none;*/
}</style>
<ul style="font-size:16px;color:dodgerblue;text-align:left;" id="Openers">Openers:
<li style="font-size:12px;cdolor:powderblue;"><a href="#" id="setFreePlay">No Opener </a></li>
<ul style="font-size:14px;color:dodgerblue;text-align:left;" id="TSpinOpeners">T-Spin Openers:
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyIPiece">Early I Piece:
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">TKI 3 (Fonzie variation) </a></li>
<!--<li style="font-size:12px;padding-left:1em;";><a href="#" id="setTKIFTVar">TKI 3 (Flat Top variation) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setTKICTVar">TKI 3 (Castle Top variation) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAjanbaTSDVar">Ajanba TSD </a></li>-->
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early L or J Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonVar">DT Cannon (LS / JZ base)</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonLHVar">DT Cannon LH (LS / JZ base)</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="TestSequence">Test Sequence</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMKOStackingVar">MKO Stacking</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPokeminosSTDVar">Pokemino's STD </a></li>
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early O Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMrTSpinsSTDreversedVar">Mr. T-Spin's STD (reversed) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setHachispinVar">Hachispin</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAlbatrossVar">Albatross</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setNumberOneVar">Number One </a></li>
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlySZOrJPiece">Early S, Z, or T Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPelicanVar">Pelican</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonTSZbaseVar">DT Cannon (TSZ base) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setBTCannonVar">BT Cannon </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setCSpinVar">C-Spin </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setHummingbirdVar">Hummingbird</a></li>
</ul>
</ul>
<!--
<ul style="font-size:14px;color:powderblue;text-align:left;" id="ComboOpeners">Combo Openers
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">Side 4 Wide </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">Center 4 Wide </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">6 Residuals </a></li>
</ul>
-->
<ul style="font-size:16px;color:dodgerblue;text-align:left;" >
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="setPCOpenersVar">Perfect Clear Openers:
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setStdPCOpenerVar">The Standard PC Opener </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setSecondPCVar">Second Perfect Clear </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLoJVar">Either L or 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="setPCTPieceVar">T piece </a></li>
</ul>
</ul>
</ul>
</div>
<canvas style="border: 1px solid #6666;" id="hold"></canvas>
<br>
<br>
<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,.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,.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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttime" value=""/>
</div>
<div id="gameOver">
<h1>Game Over !</h1>
<h3>Score: <span id="finalScore">0</span></h3>
<h2><a href="#" id="restart">Restart</a></h2>
</div>
<div id="side">
<div id="info">
<h1 id="levelInfo">Level: <br><span id="level">1</span></h1>
<h2 id="scoreInfo">Score: <br><span id="score" >0</span></h2>
<!-- <h1 style="visibility:collapse;" id="linesInfo">Lines: <br><span id="lines" >0</span></h1> -->
<div style="visibility:collapse" id="rewardInfo" class="invisible">+<span id="reward">0</span></div>
<canvas style="border: 1px solid #6666;" id="preview"></canvas>
<br>
<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>
</select>
<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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="submitsetting" type="submit" value="Set"></input>
<br>
<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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="enablegamepad" type="button" value="Enable Gamepad"/>
<input style="width:100px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="sequenceeditor" type="button" value="Opener Editor"/>
<input style="width:80px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="addopener" type="button" value="Add Opener"/>
</div>
<div id="editor" style="visibility:hidden">
</div>
</div>
</div>
</body>
<script src="dist/tetrion.js"></script>
<script>
(function(){
var tetrion = new Tetris('tetris');
document.getElementById("setFreePlay").addEventListener("click", function() { tetrion.setFreePlay(); } );
document.getElementById("setTKIFonzieVar").addEventListener("click", function() { tetrion.setCurrentOpener(1); } );
document.getElementById("setDTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(2); } );
document.getElementById("setMKOStackingVar").addEventListener("click", function() { tetrion.setCurrentOpener(3); } );
document.getElementById("setPokeminosSTDVar").addEventListener("click", function() { tetrion.setCurrentOpener(4); } );
document.getElementById("setMrTSpinsSTDreversedVar").addEventListener("click", function() { tetrion.setCurrentOpener(5); } );
document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } );
document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } );
document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } );
document.getElementById("setPelicanVar").addEventListener("click", function() { tetrion.setCurrentOpener(9); } );
document.getElementById("setDTCannonTSZbaseVar").addEventListener("click", function() { tetrion.setCurrentOpener(10); } );
document.getElementById("setDTCannonLHVar").addEventListener("click", function() { tetrion.setCurrentOpener(11); } );
document.getElementById("TestSequence").addEventListener("click", function() { tetrion.setCurrentOpener(12); } );
//document.getElementById("setStdPCOpenerVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("setBTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );
document.getElementById("Timer").addEventListener("click", function() { tetrion.toggleTimer(); } );
document.getElementById("test").addEventListener("click", function() { tetrion.setDoTest(); } );
document.getElementById("settings").addEventListener("change", function() { tetrion.updateSettingTextBox(); } );
document.getElementById("submitsetting").addEventListener("click", function() { tetrion.setSettings(); } );
document.getElementById("sequenceeditor").addEventListener("click", function() { tetrion.setGameStateSequenceEditor(); } );
document.getElementById("addopener").addEventListener("click", function() { tetrion.addOpener(); } );
tetrion.start();
})();
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}
</style>
<title>Tetrion Opening Trainer</title>
<link rel="stylesheet" href="css/styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--insert shadertoy background-->
<!--https://www.shadertoy.com/embed/wttfW2?gui=&t=10&paused=false&muted=false-->
<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 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/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/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="" ></iframe>
<script>
if( (Math.floor(Math.random() * Math.floor(10)) % 3) == 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";
var resizebg = function() {
document.getElementById("bg").width = window.innerWidth;
document.getElementById("bg").height = window.innerHeight;
};
window.addEventListener("resize", function() { this.resizebg(); } );
document.getElementById("bg").removeAttribute("tabIndex");
document.getElementById("divbg").removeAttribute("tabIndex");
this.resizebg();
</script>
</div>
<div id="tetris">
<canvas id="scene"></canvas>
<div id="leftSide">
<div id="leftInfo">
<style>
a:link, a:visited {
color: powderblue;
background-color: transparent;
/*text-decoration: none;*/
}</style>
<ul style="font-size:16px;color:dodgerblue;text-align:left;" id="Openers">Openers:
<li style="font-size:12px;cdolor:powderblue;"><a href="#" id="setFreePlay">No Opener </a></li>
<ul style="font-size:14px;color:dodgerblue;text-align:left;" id="TSpinOpeners">T-Spin Openers:
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyIPiece">Early I Piece:
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">TKI 3 (Fonzie variation) </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKITSDMorphVar">TKI 3 TSD Morph </a></li>
<!--<li style="font-size:12px;padding-left:1em;";><a href="#" id="setTKIFTVar">TKI 3 (Flat Top variation) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setTKICTVar">TKI 3 (Castle Top variation) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAjanbaTSDVar">Ajanba TSD </a></li>-->
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early L or J Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonVar">DT Cannon (LS / JZ base)</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonLHVar">DT Cannon LH (LS / JZ base)</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="TestSequence">Test Sequence</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMKOStackingVar">MKO Stacking</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPokeminosSTDVar">Pokemino's STD </a></li>
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early O Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMrTSpinsSTDreversedVar">Mr. T-Spin's STD (reversed) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setHachispinVar">Hachispin</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAlbatrossVar">Albatross</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setNumberOneVar">Number One </a></li>
</ul>
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlySZOrJPiece">Early S, Z, or T Piece:
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPelicanVar">Pelican</a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonTSZbaseVar">DT Cannon (TSZ base) </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setBTCannonVar">BT Cannon </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setCSpinVar">C-Spin </a></li>
<li style="font-size:12px;padding-left:1em";><a href="#" id="setHummingbirdVar">Hummingbird</a></li>
</ul>
</ul>
<ul style="font-size:14px;color:dodgerblue;text-align:left;" id="TSpinTripleSetups">T-Spin Triple Setups:
</ul>
<!--
<ul style="font-size:14px;color:powderblue;text-align:left;" id="ComboOpeners">Combo Openers
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">Side 4 Wide </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">Center 4 Wide </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">6 Residuals </a></li>
</ul>
-->
<ul style="font-size:16px;color:dodgerblue;text-align:left;" >
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="setPCOpenersVar">Perfect Clear Openers:
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setStdPCOpenerVar">The Standard PC Opener </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setSecondPCVar">Second Perfect Clear </a></li>
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLoJVar">Either L or 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="setPCTPieceVar">T piece </a></li>
</ul>
</ul>
</ul>
</div>
<canvas style="border: 1px solid #6666;" id="hold"></canvas>
<br>
<br>
<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,.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,.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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" type="text" id="besttime" value=""/>
</div>
<div id="gameOver">
<h1>Game Over !</h1>
<h3>Score: <span id="finalScore">0</span></h3>
<h2><a href="#" id="restart">Restart</a></h2>
</div>
<div id="side">
<div id="info">
<h1 id="levelInfo">Level: <br><span id="level">1</span></h1>
<h2 id="scoreInfo">Score: <br><span id="score" >0</span></h2>
<!-- <h1 style="visibility:collapse;" id="linesInfo">Lines: <br><span id="lines" >0</span></h1> -->
<div style="visibility:collapse" id="rewardInfo" class="invisible">+<span id="reward">0</span></div>
<canvas style="border: 1px solid #6666;" id="preview"></canvas>
<br>
<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>
</select>
<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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="submitsetting" type="submit" value="Set"></input>
<br>
<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,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="enablegamepad" type="button" value="Enable Gamepad"/>
<input style="width:100px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="sequenceeditor" type="button" value="Opener Editor"/>
<input style="width:80px;font-size:12px;background:rgba(40,40,40,.5);color:dodgerblue;border:1px solid #6666;text-align:left;" id="addopener" type="button" value="Add Opener"/>
</div>
<div id="editor" style="visibility:hidden">
</div>
</div>
</div>
</body>
<script src="dist/tetrion.js"></script>
<script>
(function(){
var tetrion = new Tetris('tetris');
document.getElementById("setFreePlay").addEventListener("click", function() { tetrion.setFreePlay(); } );
document.getElementById("setTKIFonzieVar").addEventListener("click", function() { tetrion.setCurrentOpener(1); } );
document.getElementById("setDTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(2); } );
document.getElementById("setMKOStackingVar").addEventListener("click", function() { tetrion.setCurrentOpener(3); } );
document.getElementById("setPokeminosSTDVar").addEventListener("click", function() { tetrion.setCurrentOpener(4); } );
document.getElementById("setMrTSpinsSTDreversedVar").addEventListener("click", function() { tetrion.setCurrentOpener(5); } );
document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } );
document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } );
document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } );
document.getElementById("setPelicanVar").addEventListener("click", function() { tetrion.setCurrentOpener(9); } );
document.getElementById("setDTCannonTSZbaseVar").addEventListener("click", function() { tetrion.setCurrentOpener(10); } );
document.getElementById("setDTCannonLHVar").addEventListener("click", function() { tetrion.setCurrentOpener(11); } );
document.getElementById("TestSequence").addEventListener("click", function() { tetrion.setCurrentOpener(12); } );
//document.getElementById("setStdPCOpenerVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("setBTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("setTKITSDMorphVar").addEventListener("click", function() { tetrion.setCurrentOpener(14); } );
document.getElementById("setCSpinVar").addEventListener("click", function() { tetrion.setCurrentOpener(15); } );
document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );
document.getElementById("Timer").addEventListener("click", function() { tetrion.toggleTimer(); } );
document.getElementById("test").addEventListener("click", function() { tetrion.setDoTest(); } );
document.getElementById("settings").addEventListener("change", function() { tetrion.updateSettingTextBox(); } );
document.getElementById("submitsetting").addEventListener("click", function() { tetrion.setSettings(); } );
document.getElementById("sequenceeditor").addEventListener("click", function() { tetrion.setGameStateSequenceEditor(); } );
document.getElementById("addopener").addEventListener("click", function() { tetrion.addOpener(); } );
tetrion.start();
})();
</script>
</html>

View File

@ -1,85 +1,85 @@
var gamepadAPI = {
controller: {},
turbo: false,
connect: function(evt) {
gamepadAPI.controller = evt.gamepad;
gamepadAPI.turbo = true;
console.log('Gamepad connected.');
},
disconnect: function(evt) {
gamepadAPI.turbo = false;
delete gamepadAPI.controller;
console.log('Gamepad disconnected.');
},
update: function() {
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if(!isFirefox) {
for(var i = 0; i < 4; i++)
if((gp = window.navigator.getGamepads()[i]) != undefined) // dumb gamepad update. fix.
gamepadAPI.controller = gp;
}
gamepadAPI.buttonsCache = [];
for (var k = 0; k < gamepadAPI.buttonsStatus.length; k++) {
gamepadAPI.buttonsCache[k] = gamepadAPI.buttonsStatus[k];
}
gamepadAPI.buttonsStatus = [];
var c = gamepadAPI.controller || {};
var pressed = [];
if (c.buttons) {
for (var b = 0, t = c.buttons.length; b < t; b++) {
if (c.buttons[b].pressed) {
pressed.push(gamepadAPI.buttons[b]);
}
}
}
var axes = [];
if (c.axes) {
for (var a = 0, x = c.axes.length; a < x; a++) {
axes.push(c.axes[a].toFixed(2));
}
}
gamepadAPI.axesStatus = axes;
gamepadAPI.buttonsStatus = pressed;
return pressed;
},
buttonPressed: function(button, hold) {
var newPress = false;
for (var i = 0, s = gamepadAPI.buttonsStatus.length; i < s; i++) {
if (gamepadAPI.buttonsStatus[i] == button) {
newPress = true;
if (!hold) {
for (var j = 0, p = gamepadAPI.buttonsCache.length; j < p; j++) {
if (gamepadAPI.buttonsCache[j] == button) {
newPress = false;
}
}
}
}
}
return newPress;
},
buttons: [ // XBox360 layout
'A', 'B', 'X', 'Y',
'LB', 'RB', 'Axis-Left', 'DPad-Right',
'Back', 'Start', 'Power', 'Axis-Right','DPad-Up', 'DPad-Down' , 'DPad-Left','DPad-Right'
],
/*
'DPad-Up', 'DPad-Down', 'DPad-Left', 'DPad-Right',
'Start', 'Back', 'Axis-Left', 'Axis-Right',
'LB', 'RB', 'Power', 'A', 'B', 'X', 'Y',
],*/
buttonsCache: [],
buttonsStatus: [],
axesStatus: []
};
window.addEventListener("gamepadconnected", gamepadAPI.connect);
window.addEventListener("gamepaddisconnected", gamepadAPI.disconnect);
module.exports = gamepadAPI;
var gamepadAPI = {
controller: {},
turbo: false,
connect: function(evt) {
gamepadAPI.controller = evt.gamepad;
gamepadAPI.turbo = true;
console.log('Gamepad connected.');
},
disconnect: function(evt) {
gamepadAPI.turbo = false;
delete gamepadAPI.controller;
console.log('Gamepad disconnected.');
},
update: function() {
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if(!isFirefox) {
for(var i = 0; i < 4; i++)
if((gp = window.navigator.getGamepads()[i]) != undefined) // dumb gamepad update. fix.
gamepadAPI.controller = gp;
}
gamepadAPI.buttonsCache = [];
for (var k = 0; k < gamepadAPI.buttonsStatus.length; k++) {
gamepadAPI.buttonsCache[k] = gamepadAPI.buttonsStatus[k];
}
gamepadAPI.buttonsStatus = [];
var c = gamepadAPI.controller || {};
var pressed = [];
if (c.buttons) {
for (var b = 0, t = c.buttons.length; b < t; b++) {
if (c.buttons[b].pressed) {
pressed.push(gamepadAPI.buttons[b]);
}
}
}
var axes = [];
if (c.axes) {
for (var a = 0, x = c.axes.length; a < x; a++) {
axes.push(c.axes[a].toFixed(2));
}
}
gamepadAPI.axesStatus = axes;
gamepadAPI.buttonsStatus = pressed;
return pressed;
},
buttonPressed: function(button, hold) {
var newPress = false;
for (var i = 0, s = gamepadAPI.buttonsStatus.length; i < s; i++) {
if (gamepadAPI.buttonsStatus[i] == button) {
newPress = true;
if (!hold) {
for (var j = 0, p = gamepadAPI.buttonsCache.length; j < p; j++) {
if (gamepadAPI.buttonsCache[j] == button) {
newPress = false;
}
}
}
}
}
return newPress;
},
buttons: [ // XBox360 layout
'A', 'B', 'X', 'Y',
'LB', 'RB', 'Axis-Left', 'DPad-Right',
'Back', 'Start', 'Power', 'Axis-Right','DPad-Up', 'DPad-Down' , 'DPad-Left','DPad-Right'
],
/*
'DPad-Up', 'DPad-Down', 'DPad-Left', 'DPad-Right',
'Start', 'Back', 'Axis-Left', 'Axis-Right',
'LB', 'RB', 'Power', 'A', 'B', 'X', 'Y',
],*/
buttonsCache: [],
buttonsStatus: [],
axesStatus: []
};
window.addEventListener("gamepadconnected", gamepadAPI.connect);
window.addEventListener("gamepaddisconnected", gamepadAPI.disconnect);
module.exports = gamepadAPI;
// export gamepadAPI;

View File

@ -1,250 +1,250 @@
var gamepad = require('./gamepad.js');
var utils = require('./utils.js');
// import * as gamepad from './gamepad.js';
var UserInputs = {
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.gamepadButtonTimer = new Date();
this.keyboardKeyTimer = new Date();
this.keyboardShiftTimer = new Date();
this.settingsMap = new Map();
this.gamepadEventMap = new Map();
///this.gamepadEventMap = new Map();
// var init = utils.getCookie("init");
// if(init == "")
for(var i in this.settingsList)
utils.setCookie(this.settingsList[i], this.settingsDefault[i], 30); // cookies expire in 30 days
// else
// for(var i in this.settingsList)
// this.settingsDefault[i] = utils.getCookie(this.settingsList[i]);
for(var i in this.settingsList)
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('keyup', this.keyUp.bind(this));
},
updateGamepad() {
this.gpButtons = gamepad.update();
},
gamepadEnabled() {
return gamepad.controller || false;
},
processGamepadInput() {
this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
},
processGamepadDPad() {
this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
},
// Single press gamepad buttons
gamepadButtonsDown(finds) {
var DAS = 167.0;
var ARR = 300.0;
var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds);
if(isPrevContained != isContained ) {
// Not being held yet
this.gamepadButtonTimer = new Date();
this.isPassedDelayGamepadShift = false;
// Add button to queue on pressed input
if(isContained)
this.gamepadQueue.push(finds);
}
var deltaTime = (new Date()).getTime() - this.gamepadButtonTimer.getTime();
if (!this.isPassedDelayGamepadShift) {
if (deltaTime >= DAS) {
this.gamepadButtonTimer = new Date();
this.isPassedDelayGamepadShift = true;
}
} else {
if (deltaTime >= ARR && isContained) {
this.gamepadQueue.push(finds);
this.gamepadButtonTimer = new Date();
}
}
},
// Direction Pad
gamepadDPadDown(finds) {
var DAS = parseInt(this.settingsMap.get("Gamepad DAS"));
var ARR = parseInt(this.settingsMap.get("Gamepad ARR"));
var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds);
if(isPrevContained != isContained ) {
// Not being held yet
this.gamepadShiftTimer = new Date();
this.isDelayedPassedGamepadShift = false;
// Add button to queue on pressed input
if(isContained)
this.gamepadQueue.push(finds);
}
var deltaTime = (new Date()).getTime() - this.gamepadShiftTimer.getTime();
if (!this.isDelayedPassedGamepadShift) {
if (deltaTime >= DAS) {
this.gamepadShiftTimer = new Date();
this.isDelayedPassedGamepadShift = true;
}
}
else {
if (deltaTime >= ARR && isContained) {
this.gamepadQueue.push(finds);
this.gamepadShiftTimer = new Date();
}
}
return;
},
processKeys() {
this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
},
// keyboard keys z,x,space
processKeyDown(key)
{
var DAS = 167.0;
var ARR = 300.0;
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.keyboardKeyTimer = new Date();
this.isPassedDelayKeyboardKey = false;
// Add shift to queue on pressed input
if(this.keyboardKeys[key] == true)
this.inputQueue.push(key);
}
var deltaTime = (new Date()).getTime() - this.keyboardKeyTimer.getTime();
if (!this.isPassedDelayKeyboardKey) {
if (deltaTime >= DAS) {
this.keyboardKeyTimer = new Date();
this.keyboardButtonsDeciframes = 0;
this.isPassedDelayKeyboardKey = true;
}
} else {
if (deltaTime >= ARR && this.keyboardKeys[key] == true) {
this.inputQueue.push(key);
this.keyboardKeyTimer = new Date();
}
}
},
// Process applicable key inputs
processKeyShift() {
this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
},
// Direction arrows
processKeyboardArrowKeys(key) {
var DAS = parseInt(this.settingsMap.get("Keyboard DAS"));
var ARR = parseInt(this.settingsMap.get("Keyboard ARR"));
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.isPassedDelayKeyboardShift = false;
this.keyboardShiftTimer = new Date();
// Do shift if key has been pushed down
if(this.keyboardKeys[key] == true)
this.inputQueue.push(key);
}
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
if (!this.isPassedDelayKeyboardShift) {
if (deltaTime >= DAS) {
this.keyboardShiftTimer = new Date();
this.isPassedDelayKeyboardShift = true;
}
}
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
this.inputQueue.push(key);
this.keyboardShiftTimer = new Date();
}
},
keyDown(event) {
if(event.keyCode != 38)
if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8))
event.preventDefault();
this.keyboardKeys[event.keyCode] = true;
this.isKeyBoardKeyDown = true;
},
keyUp(event) {
this.isKeyDown = false;
this.keyboardKeys[event.keyCode] = false;
this.isKeyBoardKeyDown = false;
},
gamepadClear() {
//this.gpButtons = [];
//this.gamepadQueue = [];
},
saveButtons() {
this.prevGpButtons = this.gpButtons;
},
saveKeyboardKeys() {
//this.prevKeyboardKeys = utils.deepClone(this.keyboardKeys);
this.prevKeyboardKeys = {...this.keyboardKeys};
},
// button states
isPassedDelayKeyboardShift: false,
isPassedDelayKeyboardKey: false,
isPassedDelayGamepadShift: false,
isPassedDelayGamepadButton: false,
// buttons state contatiners
gpButtons: [],
prevGpButtons:[],
keyboardKeys: [],
prevKeyboardKeys: [],
// button pressed containers
inputQueue: [],
gamepadQueue: [],
keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down", "Keyboard Up"],
keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
settingsList: [],
settingsDefault: [ "167.0", "33.0",
"37", "39", "40", "38",
"32", "16", "90", "88", "17", "82", "81",
"167.0", "33.0",
"DPad-Left", "DPad-Right", "DPad-Down",
"RB", "LB", "A", "B", "DPad-Up", "Back", ""],
settingsMap: []
};
module.exports = UserInputs;
var gamepad = require('./gamepad.js');
var utils = require('./utils.js');
// import * as gamepad from './gamepad.js';
var UserInputs = {
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.gamepadButtonTimer = new Date();
this.keyboardKeyTimer = new Date();
this.keyboardShiftTimer = new Date();
this.settingsMap = new Map();
this.gamepadEventMap = new Map();
///this.gamepadEventMap = new Map();
// var init = utils.getCookie("init");
// if(init == "")
for(var i in this.settingsList)
utils.setCookie(this.settingsList[i], this.settingsDefault[i], 30); // cookies expire in 30 days
// else
// for(var i in this.settingsList)
// this.settingsDefault[i] = utils.getCookie(this.settingsList[i]);
for(var i in this.settingsList)
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('keyup', this.keyUp.bind(this));
},
updateGamepad() {
this.gpButtons = gamepad.update();
},
gamepadEnabled() {
return gamepad.controller || false;
},
processGamepadInput() {
this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
},
processGamepadDPad() {
this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
},
// Single press gamepad buttons
gamepadButtonsDown(finds) {
var DAS = 167.0;
var ARR = 300.0;
var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds);
if(isPrevContained != isContained ) {
// Not being held yet
this.gamepadButtonTimer = new Date();
this.isPassedDelayGamepadShift = false;
// Add button to queue on pressed input
if(isContained)
this.gamepadQueue.push(finds);
}
var deltaTime = (new Date()).getTime() - this.gamepadButtonTimer.getTime();
if (!this.isPassedDelayGamepadShift) {
if (deltaTime >= DAS) {
this.gamepadButtonTimer = new Date();
this.isPassedDelayGamepadShift = true;
}
} else {
if (deltaTime >= ARR && isContained) {
this.gamepadQueue.push(finds);
this.gamepadButtonTimer = new Date();
}
}
},
// Direction Pad
gamepadDPadDown(finds) {
var DAS = parseInt(this.settingsMap.get("Gamepad DAS"));
var ARR = parseInt(this.settingsMap.get("Gamepad ARR"));
var isContained = this.gpButtons.includes(finds);
var isPrevContained = this.prevGpButtons.includes(finds);
if(isPrevContained != isContained ) {
// Not being held yet
this.gamepadShiftTimer = new Date();
this.isDelayedPassedGamepadShift = false;
// Add button to queue on pressed input
if(isContained)
this.gamepadQueue.push(finds);
}
var deltaTime = (new Date()).getTime() - this.gamepadShiftTimer.getTime();
if (!this.isDelayedPassedGamepadShift) {
if (deltaTime >= DAS) {
this.gamepadShiftTimer = new Date();
this.isDelayedPassedGamepadShift = true;
}
}
else {
if (deltaTime >= ARR && isContained) {
this.gamepadQueue.push(finds);
this.gamepadShiftTimer = new Date();
}
}
return;
},
processKeys() {
this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
},
// keyboard keys z,x,space
processKeyDown(key)
{
var DAS = 167.0;
var ARR = 300.0;
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.keyboardKeyTimer = new Date();
this.isPassedDelayKeyboardKey = false;
// Add shift to queue on pressed input
if(this.keyboardKeys[key] == true)
this.inputQueue.push(key);
}
var deltaTime = (new Date()).getTime() - this.keyboardKeyTimer.getTime();
if (!this.isPassedDelayKeyboardKey) {
if (deltaTime >= DAS) {
this.keyboardKeyTimer = new Date();
this.keyboardButtonsDeciframes = 0;
this.isPassedDelayKeyboardKey = true;
}
} else {
if (deltaTime >= ARR && this.keyboardKeys[key] == true) {
this.inputQueue.push(key);
this.keyboardKeyTimer = new Date();
}
}
},
// Process applicable key inputs
processKeyShift() {
this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
},
// Direction arrows
processKeyboardArrowKeys(key) {
var DAS = parseInt(this.settingsMap.get("Keyboard DAS"));
var ARR = parseInt(this.settingsMap.get("Keyboard ARR"));
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.isPassedDelayKeyboardShift = false;
this.keyboardShiftTimer = new Date();
// Do shift if key has been pushed down
if(this.keyboardKeys[key] == true)
this.inputQueue.push(key);
}
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
if (!this.isPassedDelayKeyboardShift) {
if (deltaTime >= DAS) {
this.keyboardShiftTimer = new Date();
this.isPassedDelayKeyboardShift = true;
}
}
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
this.inputQueue.push(key);
this.keyboardShiftTimer = new Date();
}
},
keyDown(event) {
if(event.keyCode != 38)
if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8))
event.preventDefault();
this.keyboardKeys[event.keyCode] = true;
this.isKeyBoardKeyDown = true;
},
keyUp(event) {
this.isKeyDown = false;
this.keyboardKeys[event.keyCode] = false;
this.isKeyBoardKeyDown = false;
},
gamepadClear() {
//this.gpButtons = [];
//this.gamepadQueue = [];
},
saveButtons() {
this.prevGpButtons = this.gpButtons;
},
saveKeyboardKeys() {
//this.prevKeyboardKeys = utils.deepClone(this.keyboardKeys);
this.prevKeyboardKeys = {...this.keyboardKeys};
},
// button states
isPassedDelayKeyboardShift: false,
isPassedDelayKeyboardKey: false,
isPassedDelayGamepadShift: false,
isPassedDelayGamepadButton: false,
// buttons state contatiners
gpButtons: [],
prevGpButtons:[],
keyboardKeys: [],
prevKeyboardKeys: [],
// button pressed containers
inputQueue: [],
gamepadQueue: [],
keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down", "Keyboard Up"],
keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
settingsList: [],
settingsDefault: [ "167.0", "33.0",
"37", "39", "40", "38",
"32", "16", "90", "88", "17", "82", "81",
"167.0", "33.0",
"DPad-Left", "DPad-Right", "DPad-Down",
"RB", "LB", "A", "B", "DPad-Up", "Back", ""],
settingsMap: []
};
module.exports = UserInputs;
// export UserInputs;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,71 +1,71 @@
var consts = require('./consts.ds');
var utils = require('./utils.js');
var utils. = requre('./shapes.js');
var initMatrix = function(rowCount, columnCount) {
var result = [];
for (var i = 0; i < rowCount; i++) {
var row = [];
result.push(row);
for (var j = 0; j < columnCount; j++) {
row.push(0);
}
}
return result;
};
var sequence = {
this.matrix = initMatrix(consts.ROW_COUNT, consts.COLUMN_COUNT);
this.minoList = [];
this.currentMino = [];
addMino: function(mino) {
this.minoList.push (mino)
this.updateMatrix();
},
//Copy the shape data to the game data
copyTo: function(matrix) {
var smatrix = this.matrix();
for (var i = 0; i < smatrix.length; i++) {
var row = smatrix[i];
for (var j = 0; j < row.length; j++) {
if (row[j] === 1) {
var x = this.x + j;
var y = this.y + i;
if (x >= 0 && x < matrix[0].length && y >= 0 && y < matrix.length) {
matrix[y][x] = this.color;
}
}
}
}
},
};
/*
var sequences = {
this.sequenceList = [];
this.currentMino = [];
init(setSequenceList){
this.sequnceList = setSequenceList;
},
addNewSequence: function(newsequence) {
this.sequenceList.push(newsequence);
},
addMinoToCurrentSequence: function(mino) {
this.currentSequnce.addMino(mino);
},
reset: function() {
sequenceList = [];
}
};
*/
function getNextMino() {
currentSequence.popMino();
var consts = require('./consts.ds');
var utils = require('./utils.js');
var utils. = requre('./shapes.js');
var initMatrix = function(rowCount, columnCount) {
var result = [];
for (var i = 0; i < rowCount; i++) {
var row = [];
result.push(row);
for (var j = 0; j < columnCount; j++) {
row.push(0);
}
}
return result;
};
var sequence = {
this.matrix = initMatrix(consts.ROW_COUNT, consts.COLUMN_COUNT);
this.minoList = [];
this.currentMino = [];
addMino: function(mino) {
this.minoList.push (mino)
this.updateMatrix();
},
//Copy the shape data to the game data
copyTo: function(matrix) {
var smatrix = this.matrix();
for (var i = 0; i < smatrix.length; i++) {
var row = smatrix[i];
for (var j = 0; j < row.length; j++) {
if (row[j] === 1) {
var x = this.x + j;
var y = this.y + i;
if (x >= 0 && x < matrix[0].length && y >= 0 && y < matrix.length) {
matrix[y][x] = this.color;
}
}
}
}
},
};
/*
var sequences = {
this.sequenceList = [];
this.currentMino = [];
init(setSequenceList){
this.sequnceList = setSequenceList;
},
addNewSequence: function(newsequence) {
this.sequenceList.push(newsequence);
},
addMinoToCurrentSequence: function(mino) {
this.currentSequnce.addMino(mino);
},
reset: function() {
sequenceList = [];
}
};
*/
function getNextMino() {
currentSequence.popMino();
};

View File

@ -1 +1 @@
python3 -m http.server
python3 -m http.server