c spin
This commit is contained in:
parent
fa37f623f1
commit
5093a568f6
42
LICENSE
42
LICENSE
@ -1,21 +1,21 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 PolicyChanges
|
Copyright (c) 2021 PolicyChanges
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
44
README.md
44
README.md
@ -1,22 +1,22 @@
|
|||||||
# Tetrion Opening Trainer
|
# Tetrion Opening Trainer
|
||||||
# PolicyChanges (2021)
|
# PolicyChanges (2021)
|
||||||
|
|
||||||
# MIT Liecense
|
# MIT Liecense
|
||||||
|
|
||||||
# [Tetrion](http://policychanges.github.io)
|
# [Tetrion](http://policychanges.github.io)
|
||||||
|
|
||||||
Tetris
|
Tetris
|
||||||
|
|
||||||
This is a small html5 tetris game , written by pure javascript and html5 canvas,modular by browserify.
|
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!
|
Just a practice, if you are interested in writing html5 games,check the code and have fun!
|
||||||
|
|
||||||
|
|
||||||
Demo
|
Demo
|
||||||
|
|
||||||
[Tetris Game](http://sandywalker.github.io/Tetris/)
|
[Tetris Game](http://sandywalker.github.io/Tetris/)
|
||||||
|
|
||||||
License
|
License
|
||||||
|
|
||||||
MIT © Sandy Duan
|
MIT © Sandy Duan
|
||||||
|
|
||||||
|
3667
dist/tetrion.js
vendored
3667
dist/tetrion.js
vendored
File diff suppressed because it is too large
Load Diff
434
index.html
434
index.html
@ -1,214 +1,220 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar-track {
|
||||||
background: #f1f1f1;
|
background: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle */
|
/* Handle */
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
background: #888;
|
background: #888;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle on hover */
|
/* Handle on hover */
|
||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: #555;
|
background: #555;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Tetrion Opening Trainer</title>
|
<title>Tetrion Opening Trainer</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="css/styles.css">
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<!--insert shadertoy background-->
|
<!--insert shadertoy background-->
|
||||||
<!--https://www.shadertoy.com/embed/wttfW2?gui=&t=10&paused=false&muted=false-->
|
<!--https://www.shadertoy.com/embed/wttfW2?gui=&t=10&paused=false&muted=false-->
|
||||||
|
|
||||||
|
|
||||||
<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/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>
|
<iframe id="bg" width="640" height="360" frameborder="0" src="" ></iframe>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
if( (Math.floor(Math.random() * Math.floor(10)) % 3) == 0) {
|
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").src="https://www.shadertoy.com/embed/MlSSRt?gui=&paused=false&muted=false";
|
||||||
document.getElementById("bg").style.webkitFilter = "blur(4px)";
|
document.getElementById("bg").style.webkitFilter = "blur(4px)";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
document.getElementById("bg").src="https://www.shadertoy.com/embed/WldfWX?gui=&paused=false&muted=false";
|
document.getElementById("bg").src="https://www.shadertoy.com/embed/WldfWX?gui=&paused=false&muted=false";
|
||||||
|
|
||||||
var resizebg = function() {
|
var resizebg = function() {
|
||||||
document.getElementById("bg").width = window.innerWidth;
|
document.getElementById("bg").width = window.innerWidth;
|
||||||
document.getElementById("bg").height = window.innerHeight;
|
document.getElementById("bg").height = window.innerHeight;
|
||||||
};
|
};
|
||||||
window.addEventListener("resize", function() { this.resizebg(); } );
|
window.addEventListener("resize", function() { this.resizebg(); } );
|
||||||
document.getElementById("bg").removeAttribute("tabIndex");
|
document.getElementById("bg").removeAttribute("tabIndex");
|
||||||
document.getElementById("divbg").removeAttribute("tabIndex");
|
document.getElementById("divbg").removeAttribute("tabIndex");
|
||||||
this.resizebg();
|
this.resizebg();
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="tetris">
|
<div id="tetris">
|
||||||
<canvas id="scene"></canvas>
|
<canvas id="scene"></canvas>
|
||||||
|
|
||||||
<div id="leftSide">
|
<div id="leftSide">
|
||||||
<div id="leftInfo">
|
<div id="leftInfo">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a:link, a:visited {
|
a:link, a:visited {
|
||||||
color: powderblue;
|
color: powderblue;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
/*text-decoration: none;*/
|
/*text-decoration: none;*/
|
||||||
}</style>
|
}</style>
|
||||||
|
|
||||||
<ul style="font-size:16px;color:dodgerblue;text-align:left;" id="Openers">Openers:
|
<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>
|
<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: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:
|
<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="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="setTKITSDMorphVar">TKI 3 TSD Morph </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="setTKIFTVar">TKI 3 (Flat Top variation) </a></li>
|
||||||
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAjanbaTSDVar">Ajanba TSD </a></li>-->
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setTKICTVar">TKI 3 (Castle Top variation) </a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAjanbaTSDVar">Ajanba TSD </a></li>-->
|
||||||
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early L or J Piece:
|
</ul>
|
||||||
<li style="font-size:12px;padding-left:1em";><a href="#" id="setDTCannonVar">DT Cannon (LS / JZ base)</a></li>
|
<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="setDTCannonLHVar">DT Cannon LH (LS / JZ base)</a></li>
|
<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="TestSequence">Test Sequence</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="setMKOStackingVar">MKO Stacking</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="setPokeminosSTDVar">Pokemino's STD </a></li>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMKOStackingVar">MKO Stacking</a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPokeminosSTDVar">Pokemino's STD </a></li>
|
||||||
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlyLOrJPiece">Early O Piece:
|
</ul>
|
||||||
<li style="font-size:12px;padding-left:1em";><a href="#" id="setMrTSpinsSTDreversedVar">Mr. T-Spin's STD (reversed) </a></li>
|
<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="setHachispinVar">Hachispin</a></li>
|
<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="setAlbatrossVar">Albatross</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="setNumberOneVar">Number One </a></li>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setAlbatrossVar">Albatross</a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setNumberOneVar">Number One </a></li>
|
||||||
<ul style="font-size:13px;color:dodgerblue;text-align:left;padding-left:1em;" id="EarlySZOrJPiece">Early S, Z, or T Piece:
|
</ul>
|
||||||
<li style="font-size:12px;padding-left:1em";><a href="#" id="setPelicanVar">Pelican</a></li>
|
<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="setDTCannonTSZbaseVar">DT Cannon (TSZ base) </a></li>
|
<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="setBTCannonVar">BT Cannon </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="setCSpinVar">C-Spin </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="setHummingbirdVar">Hummingbird</a></li>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setCSpinVar">C-Spin </a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em";><a href="#" id="setHummingbirdVar">Hummingbird</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</ul>
|
||||||
<!--
|
|
||||||
<ul style="font-size:14px;color:powderblue;text-align:left;" id="ComboOpeners">Combo Openers
|
<ul style="font-size:14px;color:dodgerblue;text-align:left;" id="TSpinTripleSetups">T-Spin Triple Setups:
|
||||||
<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>
|
</ul>
|
||||||
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">6 Residuals </a></li>
|
|
||||||
</ul>
|
<!--
|
||||||
-->
|
<ul style="font-size:14px;color:powderblue;text-align:left;" id="ComboOpeners">Combo Openers
|
||||||
<ul style="font-size:16px;color:dodgerblue;text-align:left;" >
|
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setTKIFonzieVar">Side 4 Wide </a></li>
|
||||||
<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="setTKIFonzieVar">Center 4 Wide </a></li>
|
||||||
<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="setTKIFonzieVar">6 Residuals </a></li>
|
||||||
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setSecondPCVar">Second Perfect Clear </a></li>
|
</ul>
|
||||||
<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>
|
<ul style="font-size:16px;color:dodgerblue;text-align:left;" >
|
||||||
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLaJVar">Both L and J </a></li>
|
<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="setPCTPieceVar">T piece </a></li>
|
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setStdPCOpenerVar">The Standard PC Opener </a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setSecondPCVar">Second Perfect Clear </a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLoJVar">Either L or J </a></li>
|
||||||
</ul>
|
<li style="font-size:12px;padding-left:1em;"><a href="#" id="setLnJVar">Neither L nor J </a></li>
|
||||||
</div>
|
<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>
|
||||||
<canvas style="border: 1px solid #6666;" id="hold"></canvas>
|
</ul>
|
||||||
<br>
|
</ul>
|
||||||
<br>
|
</ul>
|
||||||
<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"/>
|
</div>
|
||||||
<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=""/>
|
|
||||||
|
<canvas style="border: 1px solid #6666;" id="hold"></canvas>
|
||||||
<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:"/>
|
<br>
|
||||||
<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=""/>
|
<br>
|
||||||
</div>
|
<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=""/>
|
||||||
<div id="gameOver">
|
|
||||||
<h1>Game Over !</h1>
|
<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:"/>
|
||||||
<h3>Score: <span id="finalScore">0</span></h3>
|
<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=""/>
|
||||||
<h2><a href="#" id="restart">Restart</a></h2>
|
</div>
|
||||||
|
|
||||||
</div>
|
<div id="gameOver">
|
||||||
<div id="side">
|
<h1>Game Over !</h1>
|
||||||
<div id="info">
|
<h3>Score: <span id="finalScore">0</span></h3>
|
||||||
<h1 id="levelInfo">Level: <br><span id="level">1</span></h1>
|
<h2><a href="#" id="restart">Restart</a></h2>
|
||||||
<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>
|
||||||
<div style="visibility:collapse" id="rewardInfo" class="invisible">+<span id="reward">0</span></div>
|
<div id="side">
|
||||||
<canvas style="border: 1px solid #6666;" id="preview"></canvas>
|
<div id="info">
|
||||||
|
<h1 id="levelInfo">Level: <br><span id="level">1</span></h1>
|
||||||
<br>
|
<h2 id="scoreInfo">Score: <br><span id="score" >0</span></h2>
|
||||||
<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">
|
<!-- <h1 style="visibility:collapse;" id="linesInfo">Lines: <br><span id="lines" >0</span></h1> -->
|
||||||
<option selected="">Settings:</option>
|
<div style="visibility:collapse" id="rewardInfo" class="invisible">+<span id="reward">0</span></div>
|
||||||
</select>
|
<canvas style="border: 1px solid #6666;" id="preview"></canvas>
|
||||||
<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>
|
||||||
<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">
|
||||||
<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>
|
<option selected="">Settings:</option>
|
||||||
<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"/>
|
</select>
|
||||||
<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: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: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"/>
|
<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>
|
||||||
</div>
|
<br>
|
||||||
<div id="editor" style="visibility:hidden">
|
<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>
|
||||||
</div>
|
<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"/>
|
||||||
</div>
|
<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>
|
||||||
|
<div id="editor" style="visibility:hidden">
|
||||||
|
</div>
|
||||||
</body>
|
|
||||||
<script src="dist/tetrion.js"></script>
|
</div>
|
||||||
<script>
|
</div>
|
||||||
(function(){
|
|
||||||
var tetrion = new Tetris('tetris');
|
|
||||||
document.getElementById("setFreePlay").addEventListener("click", function() { tetrion.setFreePlay(); } );
|
</body>
|
||||||
document.getElementById("setTKIFonzieVar").addEventListener("click", function() { tetrion.setCurrentOpener(1); } );
|
<script src="dist/tetrion.js"></script>
|
||||||
document.getElementById("setDTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(2); } );
|
<script>
|
||||||
document.getElementById("setMKOStackingVar").addEventListener("click", function() { tetrion.setCurrentOpener(3); } );
|
(function(){
|
||||||
document.getElementById("setPokeminosSTDVar").addEventListener("click", function() { tetrion.setCurrentOpener(4); } );
|
var tetrion = new Tetris('tetris');
|
||||||
document.getElementById("setMrTSpinsSTDreversedVar").addEventListener("click", function() { tetrion.setCurrentOpener(5); } );
|
document.getElementById("setFreePlay").addEventListener("click", function() { tetrion.setFreePlay(); } );
|
||||||
document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } );
|
document.getElementById("setTKIFonzieVar").addEventListener("click", function() { tetrion.setCurrentOpener(1); } );
|
||||||
document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } );
|
document.getElementById("setDTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(2); } );
|
||||||
document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } );
|
document.getElementById("setMKOStackingVar").addEventListener("click", function() { tetrion.setCurrentOpener(3); } );
|
||||||
document.getElementById("setPelicanVar").addEventListener("click", function() { tetrion.setCurrentOpener(9); } );
|
document.getElementById("setPokeminosSTDVar").addEventListener("click", function() { tetrion.setCurrentOpener(4); } );
|
||||||
document.getElementById("setDTCannonTSZbaseVar").addEventListener("click", function() { tetrion.setCurrentOpener(10); } );
|
document.getElementById("setMrTSpinsSTDreversedVar").addEventListener("click", function() { tetrion.setCurrentOpener(5); } );
|
||||||
document.getElementById("setDTCannonLHVar").addEventListener("click", function() { tetrion.setCurrentOpener(11); } );
|
document.getElementById("setHachispinVar").addEventListener("click", function() { tetrion.setCurrentOpener(6); } );
|
||||||
document.getElementById("TestSequence").addEventListener("click", function() { tetrion.setCurrentOpener(12); } );
|
document.getElementById("setAlbatrossVar").addEventListener("click", function() { tetrion.setCurrentOpener(7); } );
|
||||||
//document.getElementById("setStdPCOpenerVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
|
document.getElementById("setNumberOneVar").addEventListener("click", function() { tetrion.setCurrentOpener(8); } );
|
||||||
document.getElementById("setBTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
|
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("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );
|
//document.getElementById("setStdPCOpenerVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
|
||||||
|
document.getElementById("setBTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
|
||||||
document.getElementById("Timer").addEventListener("click", function() { tetrion.toggleTimer(); } );
|
document.getElementById("setTKITSDMorphVar").addEventListener("click", function() { tetrion.setCurrentOpener(14); } );
|
||||||
|
document.getElementById("setCSpinVar").addEventListener("click", function() { tetrion.setCurrentOpener(15); } );
|
||||||
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("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );
|
||||||
document.getElementById("sequenceeditor").addEventListener("click", function() { tetrion.setGameStateSequenceEditor(); } );
|
|
||||||
document.getElementById("addopener").addEventListener("click", function() { tetrion.addOpener(); } );
|
document.getElementById("Timer").addEventListener("click", function() { tetrion.toggleTimer(); } );
|
||||||
tetrion.start();
|
|
||||||
})();
|
document.getElementById("test").addEventListener("click", function() { tetrion.setDoTest(); } );
|
||||||
</script>
|
document.getElementById("settings").addEventListener("change", function() { tetrion.updateSettingTextBox(); } );
|
||||||
</html>
|
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>
|
||||||
|
168
src/gamepad.js
168
src/gamepad.js
@ -1,85 +1,85 @@
|
|||||||
|
|
||||||
var gamepadAPI = {
|
var gamepadAPI = {
|
||||||
controller: {},
|
controller: {},
|
||||||
turbo: false,
|
turbo: false,
|
||||||
connect: function(evt) {
|
connect: function(evt) {
|
||||||
gamepadAPI.controller = evt.gamepad;
|
gamepadAPI.controller = evt.gamepad;
|
||||||
gamepadAPI.turbo = true;
|
gamepadAPI.turbo = true;
|
||||||
console.log('Gamepad connected.');
|
console.log('Gamepad connected.');
|
||||||
},
|
},
|
||||||
disconnect: function(evt) {
|
disconnect: function(evt) {
|
||||||
gamepadAPI.turbo = false;
|
gamepadAPI.turbo = false;
|
||||||
delete gamepadAPI.controller;
|
delete gamepadAPI.controller;
|
||||||
console.log('Gamepad disconnected.');
|
console.log('Gamepad disconnected.');
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||||
if(!isFirefox) {
|
if(!isFirefox) {
|
||||||
for(var i = 0; i < 4; i++)
|
for(var i = 0; i < 4; i++)
|
||||||
if((gp = window.navigator.getGamepads()[i]) != undefined) // dumb gamepad update. fix.
|
if((gp = window.navigator.getGamepads()[i]) != undefined) // dumb gamepad update. fix.
|
||||||
gamepadAPI.controller = gp;
|
gamepadAPI.controller = gp;
|
||||||
}
|
}
|
||||||
|
|
||||||
gamepadAPI.buttonsCache = [];
|
gamepadAPI.buttonsCache = [];
|
||||||
for (var k = 0; k < gamepadAPI.buttonsStatus.length; k++) {
|
for (var k = 0; k < gamepadAPI.buttonsStatus.length; k++) {
|
||||||
gamepadAPI.buttonsCache[k] = gamepadAPI.buttonsStatus[k];
|
gamepadAPI.buttonsCache[k] = gamepadAPI.buttonsStatus[k];
|
||||||
}
|
}
|
||||||
gamepadAPI.buttonsStatus = [];
|
gamepadAPI.buttonsStatus = [];
|
||||||
var c = gamepadAPI.controller || {};
|
var c = gamepadAPI.controller || {};
|
||||||
var pressed = [];
|
var pressed = [];
|
||||||
if (c.buttons) {
|
if (c.buttons) {
|
||||||
for (var b = 0, t = c.buttons.length; b < t; b++) {
|
for (var b = 0, t = c.buttons.length; b < t; b++) {
|
||||||
if (c.buttons[b].pressed) {
|
if (c.buttons[b].pressed) {
|
||||||
pressed.push(gamepadAPI.buttons[b]);
|
pressed.push(gamepadAPI.buttons[b]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var axes = [];
|
var axes = [];
|
||||||
if (c.axes) {
|
if (c.axes) {
|
||||||
for (var a = 0, x = c.axes.length; a < x; a++) {
|
for (var a = 0, x = c.axes.length; a < x; a++) {
|
||||||
axes.push(c.axes[a].toFixed(2));
|
axes.push(c.axes[a].toFixed(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gamepadAPI.axesStatus = axes;
|
gamepadAPI.axesStatus = axes;
|
||||||
gamepadAPI.buttonsStatus = pressed;
|
gamepadAPI.buttonsStatus = pressed;
|
||||||
return pressed;
|
return pressed;
|
||||||
},
|
},
|
||||||
|
|
||||||
buttonPressed: function(button, hold) {
|
buttonPressed: function(button, hold) {
|
||||||
var newPress = false;
|
var newPress = false;
|
||||||
for (var i = 0, s = gamepadAPI.buttonsStatus.length; i < s; i++) {
|
for (var i = 0, s = gamepadAPI.buttonsStatus.length; i < s; i++) {
|
||||||
|
|
||||||
if (gamepadAPI.buttonsStatus[i] == button) {
|
if (gamepadAPI.buttonsStatus[i] == button) {
|
||||||
newPress = true;
|
newPress = true;
|
||||||
if (!hold) {
|
if (!hold) {
|
||||||
for (var j = 0, p = gamepadAPI.buttonsCache.length; j < p; j++) {
|
for (var j = 0, p = gamepadAPI.buttonsCache.length; j < p; j++) {
|
||||||
if (gamepadAPI.buttonsCache[j] == button) {
|
if (gamepadAPI.buttonsCache[j] == button) {
|
||||||
newPress = false;
|
newPress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newPress;
|
return newPress;
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: [ // XBox360 layout
|
buttons: [ // XBox360 layout
|
||||||
'A', 'B', 'X', 'Y',
|
'A', 'B', 'X', 'Y',
|
||||||
'LB', 'RB', 'Axis-Left', 'DPad-Right',
|
'LB', 'RB', 'Axis-Left', 'DPad-Right',
|
||||||
'Back', 'Start', 'Power', 'Axis-Right','DPad-Up', 'DPad-Down' , 'DPad-Left','DPad-Right'
|
'Back', 'Start', 'Power', 'Axis-Right','DPad-Up', 'DPad-Down' , 'DPad-Left','DPad-Right'
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
'DPad-Up', 'DPad-Down', 'DPad-Left', 'DPad-Right',
|
'DPad-Up', 'DPad-Down', 'DPad-Left', 'DPad-Right',
|
||||||
'Start', 'Back', 'Axis-Left', 'Axis-Right',
|
'Start', 'Back', 'Axis-Left', 'Axis-Right',
|
||||||
'LB', 'RB', 'Power', 'A', 'B', 'X', 'Y',
|
'LB', 'RB', 'Power', 'A', 'B', 'X', 'Y',
|
||||||
],*/
|
],*/
|
||||||
|
|
||||||
buttonsCache: [],
|
buttonsCache: [],
|
||||||
buttonsStatus: [],
|
buttonsStatus: [],
|
||||||
axesStatus: []
|
axesStatus: []
|
||||||
};
|
};
|
||||||
window.addEventListener("gamepadconnected", gamepadAPI.connect);
|
window.addEventListener("gamepadconnected", gamepadAPI.connect);
|
||||||
window.addEventListener("gamepaddisconnected", gamepadAPI.disconnect);
|
window.addEventListener("gamepaddisconnected", gamepadAPI.disconnect);
|
||||||
|
|
||||||
module.exports = gamepadAPI;
|
module.exports = gamepadAPI;
|
||||||
// export gamepadAPI;
|
// export gamepadAPI;
|
498
src/input.js
498
src/input.js
@ -1,250 +1,250 @@
|
|||||||
var gamepad = require('./gamepad.js');
|
var gamepad = require('./gamepad.js');
|
||||||
var utils = require('./utils.js');
|
var utils = require('./utils.js');
|
||||||
// import * as gamepad from './gamepad.js';
|
// import * as gamepad from './gamepad.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)))));
|
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));
|
//;["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();
|
||||||
///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)
|
||||||
utils.setCookie(this.settingsList[i], this.settingsDefault[i], 30); // cookies expire in 30 days
|
utils.setCookie(this.settingsList[i], this.settingsDefault[i], 30); // cookies expire in 30 days
|
||||||
// else
|
// else
|
||||||
// for(var i in this.settingsList)
|
// for(var i in this.settingsList)
|
||||||
// this.settingsDefault[i] = utils.getCookie(this.settingsList[i]);
|
// this.settingsDefault[i] = utils.getCookie(this.settingsList[i]);
|
||||||
|
|
||||||
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);
|
this.gamepadEvents = this.gamepadShiftEvents.concat(this.gameButtonsEvents);
|
||||||
|
|
||||||
var mapIdx = [14, 7, 13, 5, 4, 1, 2, 12, 8, 3];
|
var mapIdx = [14, 7, 13, 5, 4, 1, 2, 12, 8, 3];
|
||||||
for(var i in mapIdx) {
|
for(var i in mapIdx) {
|
||||||
this.gamepadEventMap.set(this.gamepadEvents[i], gamepad.buttons[mapIdx[i]]);
|
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));
|
||||||
},
|
},
|
||||||
|
|
||||||
updateGamepad() {
|
updateGamepad() {
|
||||||
this.gpButtons = gamepad.update();
|
this.gpButtons = gamepad.update();
|
||||||
},
|
},
|
||||||
gamepadEnabled() {
|
gamepadEnabled() {
|
||||||
return gamepad.controller || false;
|
return gamepad.controller || false;
|
||||||
},
|
},
|
||||||
processGamepadInput() {
|
processGamepadInput() {
|
||||||
this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
|
this.gamepadButtonEvents.forEach(gamepadButton => this.gamepadButtonsDown(this.settingsMap.get(gamepadButton)));
|
||||||
},
|
},
|
||||||
processGamepadDPad() {
|
processGamepadDPad() {
|
||||||
this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
|
this.gamepadShiftEvents.forEach(dpadButton => this.gamepadDPadDown(this.settingsMap.get(dpadButton)));
|
||||||
},
|
},
|
||||||
// Single press gamepad buttons
|
// Single press gamepad buttons
|
||||||
gamepadButtonsDown(finds) {
|
gamepadButtonsDown(finds) {
|
||||||
var DAS = 167.0;
|
var DAS = 167.0;
|
||||||
var ARR = 300.0;
|
var ARR = 300.0;
|
||||||
var isContained = this.gpButtons.includes(finds);
|
var isContained = this.gpButtons.includes(finds);
|
||||||
var isPrevContained = this.prevGpButtons.includes(finds);
|
var isPrevContained = this.prevGpButtons.includes(finds);
|
||||||
|
|
||||||
if(isPrevContained != isContained ) {
|
if(isPrevContained != isContained ) {
|
||||||
// Not being held yet
|
// Not being held yet
|
||||||
this.gamepadButtonTimer = new Date();
|
this.gamepadButtonTimer = new Date();
|
||||||
this.isPassedDelayGamepadShift = false;
|
this.isPassedDelayGamepadShift = false;
|
||||||
// Add button to queue on pressed input
|
// Add button to queue on pressed input
|
||||||
if(isContained)
|
if(isContained)
|
||||||
this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaTime = (new Date()).getTime() - this.gamepadButtonTimer.getTime();
|
var deltaTime = (new Date()).getTime() - this.gamepadButtonTimer.getTime();
|
||||||
|
|
||||||
if (!this.isPassedDelayGamepadShift) {
|
if (!this.isPassedDelayGamepadShift) {
|
||||||
if (deltaTime >= DAS) {
|
if (deltaTime >= DAS) {
|
||||||
this.gamepadButtonTimer = new Date();
|
this.gamepadButtonTimer = new Date();
|
||||||
this.isPassedDelayGamepadShift = true;
|
this.isPassedDelayGamepadShift = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (deltaTime >= ARR && isContained) {
|
if (deltaTime >= ARR && isContained) {
|
||||||
this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
this.gamepadButtonTimer = new Date();
|
this.gamepadButtonTimer = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Direction Pad
|
// Direction Pad
|
||||||
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);
|
||||||
|
|
||||||
if(isPrevContained != isContained ) {
|
if(isPrevContained != isContained ) {
|
||||||
// Not being held yet
|
// Not being held yet
|
||||||
this.gamepadShiftTimer = new Date();
|
this.gamepadShiftTimer = new Date();
|
||||||
this.isDelayedPassedGamepadShift = false;
|
this.isDelayedPassedGamepadShift = false;
|
||||||
// Add button to queue on pressed input
|
// Add button to queue on pressed input
|
||||||
if(isContained)
|
if(isContained)
|
||||||
this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaTime = (new Date()).getTime() - this.gamepadShiftTimer.getTime();
|
var deltaTime = (new Date()).getTime() - this.gamepadShiftTimer.getTime();
|
||||||
|
|
||||||
if (!this.isDelayedPassedGamepadShift) {
|
if (!this.isDelayedPassedGamepadShift) {
|
||||||
if (deltaTime >= DAS) {
|
if (deltaTime >= DAS) {
|
||||||
this.gamepadShiftTimer = new Date();
|
this.gamepadShiftTimer = new Date();
|
||||||
this.isDelayedPassedGamepadShift = true;
|
this.isDelayedPassedGamepadShift = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (deltaTime >= ARR && isContained) {
|
if (deltaTime >= ARR && isContained) {
|
||||||
this.gamepadQueue.push(finds);
|
this.gamepadQueue.push(finds);
|
||||||
this.gamepadShiftTimer = new Date();
|
this.gamepadShiftTimer = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
processKeys() {
|
processKeys() {
|
||||||
this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
|
this.keyboardKeyEvents.forEach( key => this.settingsMap.get(key).split(',').forEach( idx => this.processKeyDown( parseInt(idx) ) ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
// keyboard keys z,x,space
|
// keyboard keys z,x,space
|
||||||
processKeyDown(key)
|
processKeyDown(key)
|
||||||
{
|
{
|
||||||
var DAS = 167.0;
|
var DAS = 167.0;
|
||||||
var ARR = 300.0;
|
var ARR = 300.0;
|
||||||
|
|
||||||
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
||||||
// Not being held yet
|
// Not being held yet
|
||||||
this.keyboardKeyTimer = new Date();
|
this.keyboardKeyTimer = new Date();
|
||||||
this.isPassedDelayKeyboardKey = false;
|
this.isPassedDelayKeyboardKey = false;
|
||||||
// Add shift to queue on pressed input
|
// Add shift to queue on pressed input
|
||||||
if(this.keyboardKeys[key] == true)
|
if(this.keyboardKeys[key] == true)
|
||||||
this.inputQueue.push(key);
|
this.inputQueue.push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaTime = (new Date()).getTime() - this.keyboardKeyTimer.getTime();
|
var deltaTime = (new Date()).getTime() - this.keyboardKeyTimer.getTime();
|
||||||
|
|
||||||
if (!this.isPassedDelayKeyboardKey) {
|
if (!this.isPassedDelayKeyboardKey) {
|
||||||
if (deltaTime >= DAS) {
|
if (deltaTime >= DAS) {
|
||||||
this.keyboardKeyTimer = new Date();
|
this.keyboardKeyTimer = new Date();
|
||||||
this.keyboardButtonsDeciframes = 0;
|
this.keyboardButtonsDeciframes = 0;
|
||||||
this.isPassedDelayKeyboardKey = true;
|
this.isPassedDelayKeyboardKey = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (deltaTime >= ARR && this.keyboardKeys[key] == true) {
|
if (deltaTime >= ARR && this.keyboardKeys[key] == true) {
|
||||||
this.inputQueue.push(key);
|
this.inputQueue.push(key);
|
||||||
this.keyboardKeyTimer = new Date();
|
this.keyboardKeyTimer = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Process applicable key inputs
|
// Process applicable key inputs
|
||||||
processKeyShift() {
|
processKeyShift() {
|
||||||
this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
|
this.keyboardShiftEvents.forEach(arrowKey => arrowKey.split(',').forEach(option => this.processKeyboardArrowKeys(parseInt(this.settingsMap.get(option)))));
|
||||||
},
|
},
|
||||||
// Direction arrows
|
// Direction arrows
|
||||||
processKeyboardArrowKeys(key) {
|
processKeyboardArrowKeys(key) {
|
||||||
var DAS = parseInt(this.settingsMap.get("Keyboard DAS"));
|
var DAS = parseInt(this.settingsMap.get("Keyboard DAS"));
|
||||||
var ARR = parseInt(this.settingsMap.get("Keyboard ARR"));
|
var ARR = parseInt(this.settingsMap.get("Keyboard ARR"));
|
||||||
|
|
||||||
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
|
||||||
// Not being held yet
|
// Not being held yet
|
||||||
this.isPassedDelayKeyboardShift = false;
|
this.isPassedDelayKeyboardShift = false;
|
||||||
this.keyboardShiftTimer = new Date();
|
this.keyboardShiftTimer = new Date();
|
||||||
|
|
||||||
// Do shift if key has been pushed down
|
// Do shift if key has been pushed down
|
||||||
if(this.keyboardKeys[key] == true)
|
if(this.keyboardKeys[key] == true)
|
||||||
this.inputQueue.push(key);
|
this.inputQueue.push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
|
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
|
||||||
|
|
||||||
if (!this.isPassedDelayKeyboardShift) {
|
if (!this.isPassedDelayKeyboardShift) {
|
||||||
|
|
||||||
if (deltaTime >= DAS) {
|
if (deltaTime >= DAS) {
|
||||||
this.keyboardShiftTimer = new Date();
|
this.keyboardShiftTimer = new Date();
|
||||||
this.isPassedDelayKeyboardShift = true;
|
this.isPassedDelayKeyboardShift = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
|
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
|
||||||
this.inputQueue.push(key);
|
this.inputQueue.push(key);
|
||||||
this.keyboardShiftTimer = new Date();
|
this.keyboardShiftTimer = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
keyDown(event) {
|
keyDown(event) {
|
||||||
if(event.keyCode != 38)
|
if(event.keyCode != 38)
|
||||||
if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8))
|
if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8))
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
this.keyboardKeys[event.keyCode] = true;
|
this.keyboardKeys[event.keyCode] = true;
|
||||||
this.isKeyBoardKeyDown = true;
|
this.isKeyBoardKeyDown = true;
|
||||||
},
|
},
|
||||||
keyUp(event) {
|
keyUp(event) {
|
||||||
this.isKeyDown = false;
|
this.isKeyDown = false;
|
||||||
this.keyboardKeys[event.keyCode] = false;
|
this.keyboardKeys[event.keyCode] = false;
|
||||||
this.isKeyBoardKeyDown = false;
|
this.isKeyBoardKeyDown = false;
|
||||||
},
|
},
|
||||||
gamepadClear() {
|
gamepadClear() {
|
||||||
//this.gpButtons = [];
|
//this.gpButtons = [];
|
||||||
//this.gamepadQueue = [];
|
//this.gamepadQueue = [];
|
||||||
},
|
},
|
||||||
saveButtons() {
|
saveButtons() {
|
||||||
this.prevGpButtons = this.gpButtons;
|
this.prevGpButtons = this.gpButtons;
|
||||||
},
|
},
|
||||||
saveKeyboardKeys() {
|
saveKeyboardKeys() {
|
||||||
//this.prevKeyboardKeys = utils.deepClone(this.keyboardKeys);
|
//this.prevKeyboardKeys = utils.deepClone(this.keyboardKeys);
|
||||||
this.prevKeyboardKeys = {...this.keyboardKeys};
|
this.prevKeyboardKeys = {...this.keyboardKeys};
|
||||||
},
|
},
|
||||||
// button states
|
// button states
|
||||||
isPassedDelayKeyboardShift: false,
|
isPassedDelayKeyboardShift: false,
|
||||||
isPassedDelayKeyboardKey: false,
|
isPassedDelayKeyboardKey: false,
|
||||||
isPassedDelayGamepadShift: false,
|
isPassedDelayGamepadShift: false,
|
||||||
isPassedDelayGamepadButton: false,
|
isPassedDelayGamepadButton: false,
|
||||||
|
|
||||||
// buttons state contatiners
|
// buttons state contatiners
|
||||||
gpButtons: [],
|
gpButtons: [],
|
||||||
prevGpButtons:[],
|
prevGpButtons:[],
|
||||||
keyboardKeys: [],
|
keyboardKeys: [],
|
||||||
prevKeyboardKeys: [],
|
prevKeyboardKeys: [],
|
||||||
|
|
||||||
// button pressed containers
|
// button pressed containers
|
||||||
inputQueue: [],
|
inputQueue: [],
|
||||||
gamepadQueue: [],
|
gamepadQueue: [],
|
||||||
|
|
||||||
keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
|
keyboardKeySettings: ["Keyboard DAS", "Keyboard ARR"],
|
||||||
keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down", "Keyboard Up"],
|
keyboardShiftEvents: ["Keyboard Left", "Keyboard Right", "Keyboard Down", "Keyboard Up"],
|
||||||
keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
|
keyboardKeyEvents: ["Keyboard Harddrop", "Keyboard Hold", "Keyboard Rotateccw", "Keyboard Rotate", "Keyboard Pophold", "Keyboard Reset", "Keyboard Background"],
|
||||||
|
|
||||||
gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
|
gamepadSettings: ["Gamepad DAS", "Gamepad ARR"],
|
||||||
gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
|
gamepadShiftEvents: ["Gamepad Left", "Gamepad Right","Gamepad Down"],
|
||||||
gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
|
gamepadButtonEvents: ["Gamepad Harddrop", "Gamepad Hold", "Gamepad Rotateccw", "Gamepad Rotate", "Gamepad Pophold", "Gamepad Reset", "Gamepad Background"],
|
||||||
|
|
||||||
settingsList: [],
|
settingsList: [],
|
||||||
|
|
||||||
settingsDefault: [ "167.0", "33.0",
|
settingsDefault: [ "167.0", "33.0",
|
||||||
"37", "39", "40", "38",
|
"37", "39", "40", "38",
|
||||||
"32", "16", "90", "88", "17", "82", "81",
|
"32", "16", "90", "88", "17", "82", "81",
|
||||||
|
|
||||||
"167.0", "33.0",
|
"167.0", "33.0",
|
||||||
"DPad-Left", "DPad-Right", "DPad-Down",
|
"DPad-Left", "DPad-Right", "DPad-Down",
|
||||||
"RB", "LB", "A", "B", "DPad-Up", "Back", ""],
|
"RB", "LB", "A", "B", "DPad-Up", "Back", ""],
|
||||||
settingsMap: []
|
settingsMap: []
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = UserInputs;
|
module.exports = UserInputs;
|
||||||
// export UserInputs;
|
// export UserInputs;
|
1728
src/main.js
1728
src/main.js
File diff suppressed because it is too large
Load Diff
1273
src/openers.js
1273
src/openers.js
File diff suppressed because it is too large
Load Diff
140
src/sequence.js
140
src/sequence.js
@ -1,71 +1,71 @@
|
|||||||
var consts = require('./consts.ds');
|
var consts = require('./consts.ds');
|
||||||
var utils = require('./utils.js');
|
var utils = require('./utils.js');
|
||||||
var utils. = requre('./shapes.js');
|
var utils. = requre('./shapes.js');
|
||||||
|
|
||||||
|
|
||||||
var initMatrix = function(rowCount, columnCount) {
|
var initMatrix = function(rowCount, columnCount) {
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var i = 0; i < rowCount; i++) {
|
for (var i = 0; i < rowCount; i++) {
|
||||||
var row = [];
|
var row = [];
|
||||||
result.push(row);
|
result.push(row);
|
||||||
for (var j = 0; j < columnCount; j++) {
|
for (var j = 0; j < columnCount; j++) {
|
||||||
row.push(0);
|
row.push(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var sequence = {
|
var sequence = {
|
||||||
this.matrix = initMatrix(consts.ROW_COUNT, consts.COLUMN_COUNT);
|
this.matrix = initMatrix(consts.ROW_COUNT, consts.COLUMN_COUNT);
|
||||||
this.minoList = [];
|
this.minoList = [];
|
||||||
this.currentMino = [];
|
this.currentMino = [];
|
||||||
|
|
||||||
addMino: function(mino) {
|
addMino: function(mino) {
|
||||||
this.minoList.push (mino)
|
this.minoList.push (mino)
|
||||||
this.updateMatrix();
|
this.updateMatrix();
|
||||||
},
|
},
|
||||||
//Copy the shape data to the game data
|
//Copy the shape data to the game data
|
||||||
copyTo: function(matrix) {
|
copyTo: function(matrix) {
|
||||||
var smatrix = this.matrix();
|
var smatrix = this.matrix();
|
||||||
for (var i = 0; i < smatrix.length; i++) {
|
for (var i = 0; i < smatrix.length; i++) {
|
||||||
var row = smatrix[i];
|
var row = smatrix[i];
|
||||||
for (var j = 0; j < row.length; j++) {
|
for (var j = 0; j < row.length; j++) {
|
||||||
if (row[j] === 1) {
|
if (row[j] === 1) {
|
||||||
var x = this.x + j;
|
var x = this.x + j;
|
||||||
var y = this.y + i;
|
var y = this.y + i;
|
||||||
if (x >= 0 && x < matrix[0].length && y >= 0 && y < matrix.length) {
|
if (x >= 0 && x < matrix[0].length && y >= 0 && y < matrix.length) {
|
||||||
matrix[y][x] = this.color;
|
matrix[y][x] = this.color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var sequences = {
|
var sequences = {
|
||||||
this.sequenceList = [];
|
this.sequenceList = [];
|
||||||
this.currentMino = [];
|
this.currentMino = [];
|
||||||
|
|
||||||
init(setSequenceList){
|
init(setSequenceList){
|
||||||
this.sequnceList = setSequenceList;
|
this.sequnceList = setSequenceList;
|
||||||
},
|
},
|
||||||
addNewSequence: function(newsequence) {
|
addNewSequence: function(newsequence) {
|
||||||
this.sequenceList.push(newsequence);
|
this.sequenceList.push(newsequence);
|
||||||
},
|
},
|
||||||
addMinoToCurrentSequence: function(mino) {
|
addMinoToCurrentSequence: function(mino) {
|
||||||
this.currentSequnce.addMino(mino);
|
this.currentSequnce.addMino(mino);
|
||||||
},
|
},
|
||||||
reset: function() {
|
reset: function() {
|
||||||
sequenceList = [];
|
sequenceList = [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNextMino() {
|
function getNextMino() {
|
||||||
currentSequence.popMino();
|
currentSequence.popMino();
|
||||||
};
|
};
|
@ -1 +1 @@
|
|||||||
python3 -m http.server
|
python3 -m http.server
|
||||||
|
Loading…
Reference in New Issue
Block a user