mirror of https://github.com/espruino/BangleApps
commit
e071597a16
|
@ -1,3 +1,4 @@
|
||||||
0.01: New app!
|
0.01: New app!
|
||||||
0.02: Better controls, implement game over.
|
0.02: Better controls, implement game over.
|
||||||
0.03: Implement mode and level selection screens.
|
0.03: Implement mode and level selection screens.
|
||||||
|
0.04: Bring back old controls as "swipe" in menu, exit with button press
|
||||||
|
|
|
@ -4,5 +4,10 @@ Bangle version of the classic game of Tetris.
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
||||||
|
##### Normal:
|
||||||
Tap top part of screen to rotate and move down, tap bottom part to
|
Tap top part of screen to rotate and move down, tap bottom part to
|
||||||
move left/right.
|
move left/right.
|
||||||
|
|
||||||
|
#### Swipe:
|
||||||
|
Tapping the screen rotates the pieces once, swiping left, right or down moves the
|
||||||
|
piece in that direction, if possible.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "tetris",
|
{ "id": "tetris",
|
||||||
"name": "Tetris",
|
"name": "Tetris",
|
||||||
"shortName":"Tetris",
|
"shortName":"Tetris",
|
||||||
"version":"0.03",
|
"version":"0.04",
|
||||||
"description": "Tetris",
|
"description": "Tetris",
|
||||||
"icon": "tetris.png",
|
"icon": "tetris.png",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
|
|
|
@ -200,59 +200,80 @@ function linear(x) {
|
||||||
|
|
||||||
function newGame() {
|
function newGame() {
|
||||||
E.showMenu();
|
E.showMenu();
|
||||||
Bangle.setUI();
|
Bangle.setUI({mode : "custom", btn: () => load()});
|
||||||
if (control == 2) {
|
if (control == 4) { // Swipe
|
||||||
Bangle.on("accel", (e) => {
|
Bangle.on("touch", (e) => {
|
||||||
|
t = rotateTile(ct, 3);
|
||||||
|
if (moveOk(t, 0, 0)) {
|
||||||
|
drawTile(ct, ctn, ox+px*8, oy+py*8, true);
|
||||||
|
ct = t;
|
||||||
|
drawTile(ct, ctn, ox+px*8, oy+py*8, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Bangle.on("swipe", (x,y) => {
|
||||||
|
if (y<0) y = 0;
|
||||||
|
if (moveOk(ct, x, y)) {
|
||||||
|
drawTile(ct, ctn, ox+px*8, oy+py*8, true);
|
||||||
|
px += x;
|
||||||
|
py += y;
|
||||||
|
drawTile(ct, ctn, ox+px*8, oy+py*8, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else { // control != 4
|
||||||
|
if (control == 2) { // Tilt
|
||||||
|
Bangle.on("accel", (e) => {
|
||||||
|
if (state != 1) return;
|
||||||
|
if (control != 2) return;
|
||||||
|
print(e.x);
|
||||||
|
linear((0.2-e.x) * 2.5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (control == 3) { // Move
|
||||||
|
Bangle.setBarometerPower(true);
|
||||||
|
Bangle.on("pressure", (e) => {
|
||||||
if (state != 1) return;
|
if (state != 1) return;
|
||||||
if (control != 2) return;
|
if (control != 3) return;
|
||||||
print(e.x);
|
let a = e.altitude;
|
||||||
linear((0.2-e.x) * 2.5);
|
if (alt_start == -9999)
|
||||||
|
alt_start = a;
|
||||||
|
a = a - alt_start;
|
||||||
|
print(e.altitude, a);
|
||||||
|
linear(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Bangle.on("drag", (e) => {
|
||||||
|
let h = 176/2;
|
||||||
|
if (state == 2) {
|
||||||
|
if (e.b)
|
||||||
|
selectGame();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!e.b)
|
||||||
|
return;
|
||||||
|
if (state == 0) return;
|
||||||
|
if (e.y < h) {
|
||||||
|
if (e.x < h)
|
||||||
|
rotate();
|
||||||
|
else {
|
||||||
|
let i = 0;
|
||||||
|
for (i=0; i<10; i++) {
|
||||||
|
move(0, 1);
|
||||||
|
g.flip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (control == 1)
|
||||||
|
linear((e.x - 20) / 156);
|
||||||
|
if (control != 0)
|
||||||
|
return;
|
||||||
|
if (e.x < h)
|
||||||
|
move(-1, 0);
|
||||||
|
else
|
||||||
|
move(1, 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (control == 3) {
|
|
||||||
Bangle.setBarometerPower(true);
|
|
||||||
Bangle.on("pressure", (e) => {
|
|
||||||
if (state != 1) return;
|
|
||||||
if (control != 3) return;
|
|
||||||
let a = e.altitude;
|
|
||||||
if (alt_start == -9999)
|
|
||||||
alt_start = a;
|
|
||||||
a = a - alt_start;
|
|
||||||
print(e.altitude, a);
|
|
||||||
linear(a);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Bangle.on("drag", (e) => {
|
|
||||||
let h = 176/2;
|
|
||||||
if (state == 2) {
|
|
||||||
if (e.b)
|
|
||||||
selectGame();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!e.b)
|
|
||||||
return;
|
|
||||||
if (state == 0) return;
|
|
||||||
if (e.y < h) {
|
|
||||||
if (e.x < h)
|
|
||||||
rotate();
|
|
||||||
else {
|
|
||||||
let i = 0;
|
|
||||||
for (i=0; i<10; i++) {
|
|
||||||
move(0, 1);
|
|
||||||
g.flip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (control == 1)
|
|
||||||
linear((e.x - 20) / 156);
|
|
||||||
if (control != 0)
|
|
||||||
return;
|
|
||||||
if (e.x < h)
|
|
||||||
move(-1, 0);
|
|
||||||
else
|
|
||||||
move(1, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
initGame();
|
initGame();
|
||||||
drawGame();
|
drawGame();
|
||||||
|
@ -278,9 +299,10 @@ function selectLevel() {
|
||||||
print("Level selection menu");
|
print("Level selection menu");
|
||||||
|
|
||||||
var menu = {};
|
var menu = {};
|
||||||
menu["Level 1"] = () => { level = 0; selectGame(); };
|
menu["< Back"] = () => {selectGame();};
|
||||||
menu["Level 2"] = () => { level = 1; selectGame(); };
|
menu[/*LANG*/"Level 1"] = () => { level = 0; selectGame(); };
|
||||||
menu["Level 3"] = () => { level = 2; selectGame(); };
|
menu[/*LANG*/"Level 2"] = () => { level = 1; selectGame(); };
|
||||||
|
menu[/*LANG*/"Level 3"] = () => { level = 2; selectGame(); };
|
||||||
E.showMenu(menu);
|
E.showMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,11 +312,12 @@ function selectGame() {
|
||||||
//for (let i = 0; i < 100000; i++) ;
|
//for (let i = 0; i < 100000; i++) ;
|
||||||
|
|
||||||
var menu = {};
|
var menu = {};
|
||||||
menu["Normal"] = () => { control = 0; newGame(); };
|
menu[/*LANG*/"Normal"] = () => { control = 0; newGame(); };
|
||||||
menu["Drag"] = () => { control = 1; newGame(); };
|
menu[/*LANG*/"Drag"] = () => { control = 1; newGame(); };
|
||||||
menu["Tilt"] = () => { control = 2; newGame(); };
|
menu[/*LANG*/"Tilt"] = () => { control = 2; newGame(); };
|
||||||
menu["Move"] = () => { control = 3; newGame(); };
|
menu[/*LANG*/"Move"] = () => { control = 3; newGame(); };
|
||||||
menu["Level"] = () => { selectLevel(); };
|
menu[/*LANG*/"Swipe"] = () => { control = 4; newGame(); };
|
||||||
|
menu[/*LANG*/"Level"] = () => { selectLevel(); };
|
||||||
E.showMenu(menu);
|
E.showMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue