Skip to content

Commit

Permalink
added dig zen, many minor fix..
Browse files Browse the repository at this point in the history
Signed-off-by: farter yang <farter yang>
  • Loading branch information
farter yang committed Mar 16, 2017
1 parent 8224974 commit 0b9fbf5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 37 deletions.
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="touchbutton" id="touchRotRight" style="display:none"><i class="material-icons">&#xE15A;</i></div>
<div class="touchbutton" id="touchRotLeft" style="display:none"><i class="material-icons">&#xE166;</i></div>
<div class="touchbutton" id="touchRot180" style="display:none"><i class="material-icons">&#xE5D5;</i></div>
<div class="touchbutton" id="touchLayout" style="display:none"><i class="material-icons">&#xE1BD;</i></div>
<div class="touchbutton" id="touchLayout" style="display:none"><i class="material-icons">&#xE913;</i></div>

<div id="content">

Expand Down Expand Up @@ -66,7 +66,7 @@ <h3>Hold</h3>
</div>

<nav class="menu on">
<h1>Tetr.js - Dig v0.53</h1>
<h1>Tetr.js - Dig v0.54</h1>

<p>forked from: <a class="link" href="http://simon.lc/tetr.js/">&gt;&gt;simonlc</a><br/>
farter's Dig Mod</p>
Expand All @@ -80,9 +80,9 @@ <h1>Tetr.js - Dig v0.53</h1>
<a class="btn" onclick="init(5)"><i class="material-icons">&#xE905;</i> Zen 修仙模式</a>

<a class="btn" onclick="menu(6,1)"><i class="material-icons">&#xE04A;</i> Replay 回放 (α)</a>
<a class="btn" onclick="menu(2)"><i class="material-icons">&#xE021;</i> Controls 调整按键</a>
<a class="btn" onclick="menu(2)" id="btnbinds"><i class="material-icons">&#xE021;</i> Controls 调整按键</a>
<a class="btn" onclick="menu(1)"><i class="material-icons">&#xE869;</i> Settings 调整设定</a>
<a class="btn" onclick="menu(7,1)"><i class="material-icons">&#xE8E5;</i> More 更多</a>
<a class="btn highlight" onclick="menu(7,1);this.classList.remove('highlight')"><i class="material-icons">&#xE8E5;</i> Harder 更厉害的</a>
</div>
</nav>

Expand Down Expand Up @@ -149,15 +149,15 @@ <h2>Controls 调整按键</h2>
<td id="pause">Esc</td>
</tr>
</table>
<a class="btn btn-bottom" onclick="menu(0)">Done 完成</a>
<a class="btn btn-bottom" onclick="menu(0);document.getElementById('btnbinds').classList.remove('highlight');">Done 完成</a>
</div>

<nav id="go" class="menu">
<div class="btn-container btn-container-bottom">
<a class="btn" onclick="init(gametype,gameparams)">Retry 再来</a>
<a class="btn btn-inline" onclick="init('replay')" style="width: 46%;">Replay 回放 </a>
<a class="btn btn-inline" onclick="showreplaydata()" style="width: 7%;"><i class="material-icons">grade</i></a>
<a class="btn" onclick="menu(5,1)">Rankings 排行</a>
<a class="btn highlight" onclick="menu(5,1);this.classList.remove('highlight')">Rankings 排行</a>
<a class="btn" onclick="menu(0)">Back 回菜单</a>
</div>
</nav>
Expand Down Expand Up @@ -198,6 +198,7 @@ <h1>Tetr.js - Dig</h1>
<a class="btn" onclick="init(3,{digOffset:2000})"><i class="material-icons">&#xE3E4;</i> NUKE 核能</a>
<a class="btn" onclick="init(4,{digraceType:'checker'})"><i class="material-icons">&#xE540;</i> Dig Hard 疯狂挖掘</a>
<a class="btn" onclick="init(6)"><i class="material-icons">&#xE01F;</i> 20G 瞬降模式(测试) </a>
<a class="btn" onclick="init(7)"><i class="material-icons"></i> Dig Zen 沉思挖掘(测试)</a>
<a class="btn" onclick="menu(void 0,-1)">Back 返回</a>
</div>
</nav>
Expand Down
34 changes: 23 additions & 11 deletions menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ var key = {
122: 'F11',
123: 'F12',
173: '-',
186: ';',
187: '=',
188: ',',
189: '-',
190: '.',
191: '/',
192: '`',
219: '[',
220: '\\',
221: ']',
222: "'"
222: "'",
undefined: "---",
0: "---"
};

/**
Expand Down Expand Up @@ -145,7 +149,7 @@ for (var i = 0, len = controlCells.length; i < len; i++) {
// TODO DRY
// Make this into a function and call it when we press Esc.
binds[currCell.id] = tempKey;
currCell.innerHTML = key[tempKey];
currCell.innerHTML = key[tempKey] || tempKey;
}
tempKey = binds[this.id];
this.innerHTML = 'Press key';
Expand All @@ -157,16 +161,22 @@ addEventListener('keyup', function (e) {
// if click outside of cell or press esc clear currCell
// reset binds button.
if (currCell) {
var newKey=e.keyCode;
if(newKey===8){
newKey=void 0;
}
// Checks if key already in use, and unbinds it.
for (var i in binds) {
if (e.keyCode === binds[i]) {
binds[i] = void 0;
document.getElementById(i).innerHTML = binds[i];
}
}
if(newKey){
for (var i in binds) {
if (newKey === binds[i]) {
binds[i] = void 0;
document.getElementById(i).innerHTML = key[binds[i]];
}
}
}
// Binds the key and saves the data.
binds[currCell.id] = e.keyCode;
currCell.innerHTML = key[e.keyCode];
binds[currCell.id] = newKey;
currCell.innerHTML = key[newKey] || newKey;
localStorage.setItem('binds', JSON.stringify(binds));
currCell = 0;
}
Expand Down Expand Up @@ -246,8 +256,10 @@ function loadLocalData() {
if (localStorage['binds']) {
binds = JSON.parse(localStorage.getItem('binds'));
for (var i = 0, len = controlCells.length; i < len; i++) {
controlCells[i].innerHTML = key[binds[controlCells[i].id]];
controlCells[i].innerHTML = key[binds[controlCells[i].id]] || binds[controlCells[i].id];
}
}else{
document.getElementById("btnbinds").classList.add("highlight");
}
// TODO When new version just update with new stuff, rest stays unchanged.
if (localStorage['version'] !== version) {
Expand Down
2 changes: 1 addition & 1 deletion ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ function XMLHTTP(url,obj)
function submitscore(obj)
{
console.log(obj);
XMLHTTP("http://xn--egt.tk:8888", obj);
XMLHTTP("http://farter.tk:8888", obj);
//XMLHTTP("http://localhost:8888", obj);
}
73 changes: 57 additions & 16 deletions tetris.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ touchRotRight.bindsMemberName = "rotRight";
touchRotLeft.bindsMemberName = "rotLeft";
touchRot180.bindsMemberName = "rot180";

var nLayouts = 8, currLayout = -1 /* auto */;
var nLayouts = 7, currLayout = -2 /* none */;

/**
* Piece data
Expand Down Expand Up @@ -568,12 +568,24 @@ var sprintRanks= [
];

var frame;
var frameSkipped;

/**
* for dig challenge mode
*/

var frameLastRise;
var frameLastHarddropDown;
var frameSkipped;

/**
*Pausing variables
* for dig zen mode
*/

var digZenBuffer;
var lastPiecesSet;

/**
* Pausing variables
*/

var startPauseTime;
Expand Down Expand Up @@ -860,7 +872,9 @@ function resize() {
};

setPos(touchLayout, 0, 0, buttonW, buttonH, 2, 0, 0, 0, winW, winH);
if(currLayout === -1) { // auto detection
if(currLayout === -2) { // none
layouts["NONE"]();
}else if(currLayout === -1) { // auto detection
if(winW<buttonW*3) {
layouts["NONE"]();
}
Expand All @@ -882,7 +896,7 @@ function resize() {
}
}
else {
layouts[["NONE","KBD_R","KBD_L","JOY","NARROW","NARROW_L","NARROW_LM","DELUXE"][currLayout]]();
layouts[["KBD_R","KBD_L","JOY","NARROW","NARROW_L","NARROW_LM","DELUXE"][currLayout]]();
}

}
Expand Down Expand Up @@ -1047,6 +1061,10 @@ function init(gt, params) {
}
//stack.draw(); //resize
}
if (gametype === 7){
lastPiecesSet = 0;
digZenBuffer = 0;
}

menu();

Expand Down Expand Up @@ -1469,15 +1487,10 @@ function touch(e)
//if (e.type==="touchmove")
//e.preventDefault();
if ((e.type === "touchstart" || e.type === "click") && e.target === touchLayout) {
if (currLayout === -1) {
currLayout = 0;
}
else {
currLayout++;
if (currLayout === nLayouts) {
currLayout = -1;
}
}
currLayout++;
if (currLayout === nLayouts) {
currLayout = -2; //none, auto, 0, 1, 2...
}
resize();
}
if (e.type === "touchstart" || e.type === "touchmove" || e.type === "touchend") {
Expand Down Expand Up @@ -1602,6 +1615,26 @@ function update() {
frameLastRise=frame;
sound.playse("garbage");
}
}else if(gametype===7) { //dig zen
for(;lastPiecesSet<piecesSet;lastPiecesSet++){
digZenBuffer++;
var curStage=~~(lines/30);
var piecePerRise=[
8,6.5,4,3.5,10/3,
3,2.8,2.6,2.4,2.2,
2][curStage>10?10:curStage];
if(digZenBuffer-piecePerRise > -0.000000001){
digZenBuffer-=piecePerRise;
if(Math.abs(digZenBuffer) < -0.000000001){
digZenBuffer = 0;
}
var arrRow=[8,8,8,8,8,8,8,8,8,8];
arrRow[~~(rng.next()*10)]=0;

stack.rowRise(arrRow, piece);
sound.playse("garbage");
}
}
}

// Win
Expand Down Expand Up @@ -1646,8 +1679,16 @@ function update() {
menu(3);
sound.playse("endingstart");
}
} else if (gametype === 6) { // Score Attack
if (lines>=300) { // exp
} else if (gametype === 6) { // 20G
if (lines>=300) { // 200 + 100
gameState = 1;
msg.innerHTML = 'GREAT!';
piece.dead = true;
menu(3);
sound.playse("endingstart");
}
} else if (gametype === 7) { // dig zen
if (lines>=400) { // 300 + 100
gameState = 1;
msg.innerHTML = 'GREAT!';
piece.dead = true;
Expand Down
9 changes: 6 additions & 3 deletions ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ a.btn {
margin: 1em auto;
width: 70%;
height: 1.4rem;
border: 2px solid #FFF;
border-radius: 5px;
border: .125rem solid #ccc;
border-radius: .3rem;
font-size: 1rem;
font-family: 'Trebuchet MS', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
font-weight: bold;
Expand All @@ -61,12 +61,15 @@ a.btn:hover {
background-color: #222;
transition: background-color .1s ease;
}
a.btn.highlight {
box-shadow: 0 0 .5rem #fff;
}
a.btn.btn-inline {
display: inline-block;
margin: 0 0.5rem;
}
div.btn-container {
margin: 1em auto;
margin: 1rem auto;
}
div.btn-container.btn-container-bottom {
position: absolute;
Expand Down

0 comments on commit 0b9fbf5

Please sign in to comment.