Skip to content

Commit

Permalink
add rotation system
Browse files Browse the repository at this point in the history
touch button update

Signed-off-by: farteryhr <[email protected]>
  • Loading branch information
farteryhr committed Nov 11, 2022
1 parent 7dcbd90 commit 675d412
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 36 deletions.
70 changes: 46 additions & 24 deletions data.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ var OffsetE60 = [
[[+1,+1],[+1, 0],[+1, 0],[+2, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1,+1],[+1, 0],[+1, 0],[+2, 0]]];
var OffsetJJSRS = [
[[ 0, 0],[ 0, 0],[ 0, 0],[ 0, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[ 0, 0],[ 0, 0],[ 0, 0],[ 0, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]]];
var Offset5000 = [
[[ 0,+1],[-1, 0],[ 0, 0],[ 0, 0]],
[[ 0, 0],[ 0, 0],[ 0, 0],[ 0, 0]],
Expand Down Expand Up @@ -316,14 +308,31 @@ var OffsetTwin = [
[[+1,+1],[ 0,+1],[+1, 0],[+1,+1]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1,+1],[ 0,+1],[+1, 0],[+1,+1]]];
var OffsetFun = [
var OffsetFun2k = [
[[ 0, 0],[ 0, 0],[ 0,-1],[+1, 0]],
[[ 0,+1],[ 0,+1],[ 0,+1],[ 0,+1]],
[[ 0,+1],[ 0,+1],[ 0,+1],[ 0,+1]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1, 0],[ 0, 0],[+1,-1],[+1, 0]],
[[+1, 0],[+1, 0],[+1, 0],[+1, 0]],
[[+1, 0],[ 0, 0],[+1,-1],[+1, 0]]];
var OffsetBrick = [
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 0]];
var InitInfoJJSRS = [[ 0, 0, 0],[+1, 0, 0],[+1, 0, 0],[ 0, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0]];
var InitInfo5000 = [[ 0, 0, 3],[ 0, 0, 1],[+1, 0, 3],[ 0, 0, 0],[ 0, 0, 0],[ 0, -1, 2],[ 0, 0, 0]];
var InitInfoPlus = [[ 0, 0, 0],[+1, 0, 2],[+1, 0, 2],[ 0,+1, 0],[+1,+1, 0],[+1, 0, 2],[+1,+1, 0]];
var InitInfoSHC = [[+1,+1, 0],[+1, 0, 2],[+1, 0, 2],[ 0,+1, 0],[+1,+1, 0],[+1, 0, 2],[+1,+1, 0]];
Expand All @@ -353,7 +361,9 @@ var InitInfoBPS2 = [[ 0,+1, 0],[ 0, 0, 2],[ 0, 0, 2],[ 0,+1, 0],[ 0, 0, 2],[ 0,
var InitInfoAcid = [[+1, 0, 0],[+2, 0, 2],[+2, 0, 2],[+2,+1, 0],[+2,+1, 0],[+2, 0, 2],[+2,+1, 0]];
var InitInfoTrukaMy = [[ 0, 0, 0],[+1, 0, 2],[+1, 0, 2],[ 0, 0, 0],[+1, 0, 0],[+1, 0, 2],[+1, 0, 0]];
var InitInfoTwin = [[ 0, 0, 0],[+1,+1, 0],[ 0,+1, 0],[ 0,+1, 0],[+1,+1, 0],[ 0,+1, 0],[+1,+1, 0]];
var InitInfoFun = [[ 0, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0]];
var InitInfoFun2k = [[ 0, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0],[+1, 0, 0]];
var InitInfoBrick = [[ 0, 0, 0],[ 0, 0, 2],[ 0, 0, 2],[ 0,+1, 0],[ 0,+1, 0],[ 0, 0, 2],[ 0,+1, 0]];
var InitInfoHuanle = [[ 0, 0, 0],[ 0, 0, 0],[ 0, 0, 0],[ 0, 0, 0],[ 0,-1, 1],[ 0, 0, 0],[ 0,-1, 1]];

var ColorSRS = [1, 2, 3, 4, 5, 6, 7];
var ColorSega = [7, 2, 3, 4, 6, 1, 5];
Expand All @@ -366,13 +376,13 @@ var ColorNintendo = [9, 2, 7, 9, 2, 9, 7];
var ColorMS = [7, 6, 4, 1, 2, 8, 5];
var ColorE60 = [5, 5, 5, 5, 5, 5, 5];
var ColorIBM = [7, 9, 6, 2, 5, 3, 1];
var ColorJJSRS = [5, 1, 3, 4, 7, 6, 2];
var ColorJJ = [5, 1, 3, 4, 7, 6, 2];
var Color5000 = [7, 6, 8, 4, 5, 1, 2];
var ColorDX = [9, 7, 2, 4, 3, 5, 6];
var ColorMybo = [5, 6, 7, 4, 3, 2, 1];
var ColorQuadra = [5, 4, 6, 3, 1, 2, 7];
var ColorGameBoy = [9, 2, 7, 8, 7, 9, 2];
var ColorTNET = [5, 5, 6, 4, 2, 4, 7];
var ColorTNET = [2, 5, 6, 4, 2, 4, 7];
var ColorCDi = [3, 7, 5, 9, 6, 2, 4];
var ColorSHC = [2, 4, 5, 7, 1, 3, 6];
var ColorMax = [2, 7, 1, 6, 4, 5, 9];
Expand All @@ -386,7 +396,9 @@ var ColorAcid = [4, 6, 1, 5, 7, 2, 3];
var ColorCrazyYXWD = [9, 1, 6, 4, 2, 7, 5];
var ColorTrukaMy = [5, 2, 1, 6, 4, 7, 3];
var ColorTwin = [7, 6, 3, 2, 1, 4, 5];
var ColorFun = [1, 7, 4, 3, 6, 2, 5];
var ColorFun2k = [1, 7, 4, 3, 6, 2, 5];
var ColorMono = [9, 9, 9, 9, 9, 9, 9];
var ColorHuanle = [1, 2, 5, 7, 6, 4, 3];

var RotSys = [
{
Expand Down Expand Up @@ -450,9 +462,9 @@ var RotSys = [
color: ColorIBM,
},
{
initinfo: InitInfoJJSRS,
offset: OffsetJJSRS,
color: ColorJJSRS,
initinfo: InitInfoSRS,
offset: OffsetSRS,
color: ColorJJ,
},
{
initinfo: InitInfo5000,
Expand Down Expand Up @@ -501,7 +513,7 @@ var RotSys = [
},
{
initinfo: InitInfoMax,
offset: OffsetJJSRS,
offset: OffsetMax,
color: ColorMax,
},
{ //4 games at puzzle-game-download.com / intelore, interesting rs
Expand Down Expand Up @@ -555,9 +567,19 @@ var RotSys = [
color: ColorTwin,
},
{
initinfo: InitInfoFun,
offset: OffsetFun,
color: ColorFun,
initinfo: InitInfoFun2k,
offset: OffsetFun2k,
color: ColorFun2k,
},
{
initinfo: InitInfoBrick,
offset: OffsetBrick,
color: ColorMono,
},
{
initinfo: InitInfoHuanle,
offset: OffsetHuanle,
color: ColorHuanle,
},
];

Expand Down Expand Up @@ -785,11 +807,11 @@ var setting = {
Gravity: ["Auto"].concat(gravityNameArr),
LockDelay: range(0, 101),
RotSys: [
'Super', 'CultrisII', 'Arika*', 'DTET', 'NM/QQ', 'Atari', 'Tengen',
'- Super -', 'CultrisII', 'Arika*', 'DTET', 'NM/QQ', 'Atari', 'Tengen',
'N-Blox', 'Nintendo', 'Microsoft', 'E-60', 'IBM PC', 'JJ', '5000',
'Plus', 'DX', 'GameBoy', 'Quadra', 'Mybo', 'TNET', 'CD-i',
'SH-C', 'Max', 'Intelore', 'Zen', 'Tris', 'Quinn', 'BPS', 'BPS2',
'ACiD', '英雄无敌', 'Truka·My', 'Twin', 'TFun2k'
'SH Clsc.', 'Max/BL', 'Intelore', 'Zen', 'Tris', 'Quinn', 'BPS', 'BPS2',
'ACiD', '英雄无敌', 'Truka·My', 'Twin', 'TFun2k', 'Brick', '桃谷欢乐'
],
Next: ['-', '1', '2', '3', '4', '5', '6'],
Size: ['Auto', 'Small', 'Medium', 'Large', 'Larger'],
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3>Hold</h3>
</div>

<nav class="menu on">
<h1>Tetr.js - Dig v0.65</h1>
<h1>Tetr.js - Dig v0.66</h1>
<p>
original: <a class="link" href="//simon.lc/tetr.js/">&gt;&gt;simonlc</a><br/>
enhanced: <a class="link" href="//doktorocelot.com/tetr.js/">&gt;&gt;drocelot</a><br/>
Expand Down Expand Up @@ -208,6 +208,8 @@ <h3>Next</h3>

</div>

<div style="display:none;" id="divdebug">debug</div>

<canvas id="sprite"></canvas>
<script type="text/javascript" src="bigmin.js"></script>
<script type="text/javascript" src="polyfill.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ body {
-webkit-touch-callout: none;
overflow: hidden;
}
html, body{
width:100%;
height:100%;
}
body, span, a, p, div, h2, h3, h4, h5, h6 {
font-family: 'Roboto', 'Trebuchet MS', 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
}
Expand Down Expand Up @@ -515,9 +519,12 @@ i.left.material-icons, i.right.material-icons {
/* Touch Buttons */
#touchOverlay {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 100;
/*pointer-events: none;*/
}

.touchoverlay-disabled {
Expand Down
7 changes: 6 additions & 1 deletion tetris.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ var column;
/**
* Get html elements.
*/
var divdebug = $$('divdebug');
function debugmsg(s){
$setText(divdebug, s);
}

var msg = $$('msg');
var stats = $$('stats');
var statsTime = $$('time');
Expand Down Expand Up @@ -330,7 +335,7 @@ function init(gt, params) {
try{
tryUpgradeSetting(replay.settings);
}catch(e){
alert("replay too old, failed to auto-upgrade... 回访数据过于古代,自动升级失败...\n" + e);
alert("replay too old, failed to auto-upgrade... 回放数据过于古代,自动升级失败...\n" + e);
return;
}
replay.keys = keysDecode(replay.keys);
Expand Down
43 changes: 33 additions & 10 deletions touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,28 +220,50 @@ function touchButtonsToggle(){

function touch(e)
{
// debugmsg("test");
var winH = window.innerHeight, winW = window.innerWidth;
//console.log(e.type, e.target.keyName);

if (e.type === "touchstart" || e.type === "touchmove" || e.type === "touchend") {
if (isGameRunning()) {
keysDownTouch = 0;
for (var i = 0, l = e.touches.length; i < l; i++) {
var tX = e.touches[i].pageX, tY = e.touches[i].pageY;
var t = e.touches[i];
var tX = t.pageX, tY = t.pageY;

/*
var nearestbtn = null, mindist = Infinity;
for (var j = 0; j < touchButtons.length; j++) {
var btn = touchButtons[j];
if (tX>=btn.offsetLeft && tX<btn.offsetLeft+btn.offsetWidth &&
tY>=btn.offsetTop && tY<btn.offsetTop+btn.offsetHeight) {
keysDownTouch |= flags[btn.keyName];
var centerX = btn.offsetLeft + btn.offsetWidth/2;
var centerY = btn.offsetTop + btn.offsetHeight/2;
var dist = Math.sqrt((tX - centerX) * (tX - centerX) + (tY - centerY) * (tY - centerY));
if (dist < 96 && dist < mindist) {
nearestbtn = btn;
mindist = dist;
}
}
*/
if(nearestbtn !== null){
keysDownTouch |= flags[nearestbtn.keyName];
}
}
e.preventDefault();
}
}

//debug
var touchcollect=[],btncollect=[];
if(false && e.type=="touchstart"){
for (var i = 0, l = e.touches.length; i < l; i++) {
var t = e.touches[i];
var tX = t.pageX, tY = t.pageY;
touchcollect.push([tX,tY].join(","));
}
for (var j = 0; j < touchButtons.length; j++) {
var btn = touchButtons[j];
btncollect.push([btn.offsetLeft,btn.offsetTop,btn.offsetWidth,btn.offsetHeight,btn.keyName].join(","));
}
debugmsg(touchcollect.join("\n")+"\n"+btncollect.join("\n"));
}
}

function touchOnLayout(e){
Expand Down Expand Up @@ -278,6 +300,7 @@ touchLayout.addEventListener('click', touchOnLayout, false);
touchOverlay.addEventListener('gesturestart',preventDefault,false);
touchOverlay.addEventListener('gestureend',preventDefault,false);
touchOverlay.addEventListener('gesturechange',preventDefault,false);
document.addEventListener('gesturestart',preventDefault,false);
document.addEventListener('gestureend',preventDefault,false);
document.addEventListener('gesturechange',preventDefault,false);

document.body.addEventListener('gesturestart',preventDefault,false);
document.body.addEventListener('gestureend',preventDefault,false);
document.body.addEventListener('gesturechange',preventDefault,false);

0 comments on commit 675d412

Please sign in to comment.