From 287cbf6eea1376f02e1d5472a1c9b9956c953205 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 14:56:07 -0400 Subject: [PATCH 1/6] New app 2047++ --- apps/2047++/2047++.app.js | 129 ++++++++++++++++++++++++++++++++++++++ apps/2047++/README.md | 6 ++ apps/2047++/app-icon.js | 1 + apps/2047++/app.png | Bin 0 -> 759 bytes apps/2047++/metadata.json | 14 +++++ 5 files changed, 150 insertions(+) create mode 100644 apps/2047++/2047++.app.js create mode 100644 apps/2047++/README.md create mode 100644 apps/2047++/app-icon.js create mode 100644 apps/2047++/app.png create mode 100644 apps/2047++/metadata.json diff --git a/apps/2047++/2047++.app.js b/apps/2047++/2047++.app.js new file mode 100644 index 000000000..b508d8f07 --- /dev/null +++ b/apps/2047++/2047++.app.js @@ -0,0 +1,129 @@ + + +class TwoK { + constructor() { + this.b = Array(4).fill().map(() => Array(4).fill(0)); + this.score = 0; + this.cmap = {0: "#caa", 2:"#ccc", 4: "#bcc", 8: "#ba6", 16: "#e61", 32: "#d20", 64: "#d00", 128: "#da0", 256: "#ec0", 512: "#dd0"}; + } + drawBRect(x1, y1, x2, y2, th, c, cf) { + g.setColor(c); + for (i=0; i 4) g.setColor(1, 1, 1); + else g.setColor(0, 0, 0); + g.setFont("Vector", bh*(b>8 ? (b>64 ? (b>512 ? 0.32 : 0.4) : 0.6) : 0.7)); + if (b>0) g.drawString(b.toString(), xo+(x+0.5)*bw+1, yo+(y+0.5)*bh); + } + } + shift(d) { // +/-1: shift x, +/- 2: shift y + var crc = E.CRC32(this.b.toString()); + if (d==-1) { // shift x left + for (y=0; y<4; ++y) { + for (x=2; x>=0; x--) + if (this.b[y][x]==0) { + for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; + this.b[y][3] = 0; moved = true; + } + for (x=0; x<3; ++x) + if (this.b[y][x]==this.b[y][x+1]) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y][x+1]; + for (j=x+1; j<3; ++j) this.b[y][j] = this.b[y][j+1]; + this.b[y][3] = 0; moved = true; + } + } + } + else if (d==1) { // shift x right + for (y=0; y<4; ++y) { + for (x=1; x<4; x++) + if (this.b[y][x]==0) { + for (i=x; i>0; i--) this.b[y][i] = this.b[y][i-1]; + this.b[y][0] = 0; + } + for (x=3; x>0; --x) + if (this.b[y][x]==this.b[y][x-1]) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y][x-1] ; + for (j=x-1; j>0; j--) this.b[y][j] = this.b[y][j-1]; + this.b[y][0] = 0; + } + } + } + else if (d==-2) { // shift y down + for (x=0; x<4; ++x) { + for (y=1; y<4; y++) + if (this.b[y][x]==0) { + for (i=y; i>0; i--) this.b[i][x] = this.b[i-1][x]; + this.b[0][x] = 0; + } + for (y=3; y>0; y--) + if (this.b[y][x]==this.b[y-1][x] || this.b[y][x]==0) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y-1][x]; + for (j=y-1; j>0; j--) this.b[j][x] = this.b[j-1][x]; + this.b[0][x] = 0; + } + } + } + else if (d==2) { // shift y up + for (x=0; x<4; ++x) { + for (y=2; y>=0; y--) + if (this.b[y][x]==0) { + for (i=y; i<3; i++) this.b[i][x] = this.b[i+1][x]; + this.b[3][x] = 0; + } + for (y=0; y<3; ++y) + if (this.b[y][x]==this.b[y+1][x] || this.b[y][x]==0) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y+1][x]; + for (j=y+1; j<3; ++j) this.b[j][x] = this.b[j+1][x]; + this.b[3][x] = 0; + } + } + } + return (E.CRC32(this.b.toString())!=crc); + } + addDigit() { + var d = Math.random()>0.9 ? 4 : 2; + var id = Math.floor(Math.random()*16); + while (this.b[Math.floor(id/4)][id%4] > 0) id = Math.floor(Math.random()*16); + this.b[Math.floor(id/4)][id%4] = d; + } +} + +function dragHandler(e) { + if (e.b && (Math.abs(e.dx)>7 || Math.abs(e.dy)>7)) { + var res = false; + if (Math.abs(e.dx)>Math.abs(e.dy)) { + if (e.dx>0) res = twok.shift(1); + if (e.dx<0) res = twok.shift(-1); + } + else { + if (e.dy>0) res = twok.shift(-2); + if (e.dy<0) res = twok.shift(2); + } + if (res) twok.addDigit(); + twok.render(); + } +} + +var twok = new TwoK(); +twok.addDigit(); twok.addDigit(); +twok.render(); +Bangle.on("drag", dragHandler); diff --git a/apps/2047++/README.md b/apps/2047++/README.md new file mode 100644 index 000000000..5b70423e4 --- /dev/null +++ b/apps/2047++/README.md @@ -0,0 +1,6 @@ + +# Game of 2047++ + +Tile shifting game inspired by the well known 2048 game. Also very similar to another Bangle game, Game1024. + +Attempt to combine equal numbers by swiping left, right, up or down. diff --git a/apps/2047++/app-icon.js b/apps/2047++/app-icon.js new file mode 100644 index 000000000..4086d1879 --- /dev/null +++ b/apps/2047++/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4A31gAeFtoxPF9wujGBYQG1YAWF6ur5gAYGIovOFzIABF6ReaMAwv/F/4v/F7ejv9/0Yvq1Eylksv4vqvIuBF9ZeDF9ZeBqovr1AsB0YvrLwXMF9ReDF9ZeBq1/v4vBqowKF7lWFYIAFF/7vXAAa/qF+jxB0YvsABov/F/4v/F6WsF7YgEF5xgaLwgvPGIQAWDwwvQADwvJGEguKF+AxhFpoA/AH4A/AFI=")) \ No newline at end of file diff --git a/apps/2047++/app.png b/apps/2047++/app.png new file mode 100644 index 0000000000000000000000000000000000000000..d1fb4a5e5cbadce3da7b36806d4907f680f8f1bb GIT binary patch literal 759 zcmVYCuD-J|F04S(qype>Ll^oVPK(#&(MEqX}dr+-4N41U&D6G<#pk8p=ry~PL z8P~wDv0Fxk@G(D*-Esf`5DS+uaYFpJB+Wpns^Zb}E7&tzFF7%tm102J6nd69|4+P3 zr1VfMt5{y0fI>`0^KD2mu=F8{y6M673*Til--d7lyX64hte$~F4EL^Xh;F_M;RY5n zQPi8Q(T|*z{|6UpV5c0w+w9;*9}v8ZE@h%j4t73gCg!Qfe`}$Ac#sB~}C%=m9 zQmlcEAIAXzTR($HE?;WPt>nU3$%Ta*5c>_tUp2cB`Ud77yzh$Lczg#y>rX6t^Z|D> zcQA?REP&Q#P6pBq$e1?!8Tl#X8W=W?3|OSe*3omHjttb47#RG02|5f6e$ zObTJ!ml%i%20ylab9U#WUDz$7W@n({nZhq+5~`IO*5Pi07qm053E*;P(4-Kmo@>1; z>;uNw7hc?M3Z*1!=?Nlw%8PRi7>4l#z$>YW4#!KwFcx?T+e^N5I_>#$tusSJ+zSuc p5YZ-MEM*wRg54#bi;K&M^BdjW!v$Q*XjK3J002ovPDHLkV1lLySIGbX literal 0 HcmV?d00001 diff --git a/apps/2047++/metadata.json b/apps/2047++/metadata.json new file mode 100644 index 000000000..f887d95d9 --- /dev/null +++ b/apps/2047++/metadata.json @@ -0,0 +1,14 @@ +{ "id": "2047++", + "name": "2047++", + "shortName":"2047++", + "icon": "app.png", + "version":"0.01", + "description": "Bangle version of a tile shifting game", + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "tags": "game", + "storage": [ + {"name":"2047++.app.js","url":"2047++.app.js"}, + {"name":"2047++.img","url":"app-icon.js","evaluate":true} + ] +} From 1e10f4a25eb1c7a48513694b71fa1b0aee623217 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 14:59:23 -0400 Subject: [PATCH 2/6] Change name of new app --- apps/2047++/2047++.app.js | 129 -------------------------------------- apps/2047++/README.md | 6 -- apps/2047++/app-icon.js | 1 - apps/2047++/app.png | Bin 759 -> 0 bytes apps/2047++/metadata.json | 14 ----- 5 files changed, 150 deletions(-) delete mode 100644 apps/2047++/2047++.app.js delete mode 100644 apps/2047++/README.md delete mode 100644 apps/2047++/app-icon.js delete mode 100644 apps/2047++/app.png delete mode 100644 apps/2047++/metadata.json diff --git a/apps/2047++/2047++.app.js b/apps/2047++/2047++.app.js deleted file mode 100644 index b508d8f07..000000000 --- a/apps/2047++/2047++.app.js +++ /dev/null @@ -1,129 +0,0 @@ - - -class TwoK { - constructor() { - this.b = Array(4).fill().map(() => Array(4).fill(0)); - this.score = 0; - this.cmap = {0: "#caa", 2:"#ccc", 4: "#bcc", 8: "#ba6", 16: "#e61", 32: "#d20", 64: "#d00", 128: "#da0", 256: "#ec0", 512: "#dd0"}; - } - drawBRect(x1, y1, x2, y2, th, c, cf) { - g.setColor(c); - for (i=0; i 4) g.setColor(1, 1, 1); - else g.setColor(0, 0, 0); - g.setFont("Vector", bh*(b>8 ? (b>64 ? (b>512 ? 0.32 : 0.4) : 0.6) : 0.7)); - if (b>0) g.drawString(b.toString(), xo+(x+0.5)*bw+1, yo+(y+0.5)*bh); - } - } - shift(d) { // +/-1: shift x, +/- 2: shift y - var crc = E.CRC32(this.b.toString()); - if (d==-1) { // shift x left - for (y=0; y<4; ++y) { - for (x=2; x>=0; x--) - if (this.b[y][x]==0) { - for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; - this.b[y][3] = 0; moved = true; - } - for (x=0; x<3; ++x) - if (this.b[y][x]==this.b[y][x+1]) { - this.score += 2*this.b[y][x]; - this.b[y][x] += this.b[y][x+1]; - for (j=x+1; j<3; ++j) this.b[y][j] = this.b[y][j+1]; - this.b[y][3] = 0; moved = true; - } - } - } - else if (d==1) { // shift x right - for (y=0; y<4; ++y) { - for (x=1; x<4; x++) - if (this.b[y][x]==0) { - for (i=x; i>0; i--) this.b[y][i] = this.b[y][i-1]; - this.b[y][0] = 0; - } - for (x=3; x>0; --x) - if (this.b[y][x]==this.b[y][x-1]) { - this.score += 2*this.b[y][x]; - this.b[y][x] += this.b[y][x-1] ; - for (j=x-1; j>0; j--) this.b[y][j] = this.b[y][j-1]; - this.b[y][0] = 0; - } - } - } - else if (d==-2) { // shift y down - for (x=0; x<4; ++x) { - for (y=1; y<4; y++) - if (this.b[y][x]==0) { - for (i=y; i>0; i--) this.b[i][x] = this.b[i-1][x]; - this.b[0][x] = 0; - } - for (y=3; y>0; y--) - if (this.b[y][x]==this.b[y-1][x] || this.b[y][x]==0) { - this.score += 2*this.b[y][x]; - this.b[y][x] += this.b[y-1][x]; - for (j=y-1; j>0; j--) this.b[j][x] = this.b[j-1][x]; - this.b[0][x] = 0; - } - } - } - else if (d==2) { // shift y up - for (x=0; x<4; ++x) { - for (y=2; y>=0; y--) - if (this.b[y][x]==0) { - for (i=y; i<3; i++) this.b[i][x] = this.b[i+1][x]; - this.b[3][x] = 0; - } - for (y=0; y<3; ++y) - if (this.b[y][x]==this.b[y+1][x] || this.b[y][x]==0) { - this.score += 2*this.b[y][x]; - this.b[y][x] += this.b[y+1][x]; - for (j=y+1; j<3; ++j) this.b[j][x] = this.b[j+1][x]; - this.b[3][x] = 0; - } - } - } - return (E.CRC32(this.b.toString())!=crc); - } - addDigit() { - var d = Math.random()>0.9 ? 4 : 2; - var id = Math.floor(Math.random()*16); - while (this.b[Math.floor(id/4)][id%4] > 0) id = Math.floor(Math.random()*16); - this.b[Math.floor(id/4)][id%4] = d; - } -} - -function dragHandler(e) { - if (e.b && (Math.abs(e.dx)>7 || Math.abs(e.dy)>7)) { - var res = false; - if (Math.abs(e.dx)>Math.abs(e.dy)) { - if (e.dx>0) res = twok.shift(1); - if (e.dx<0) res = twok.shift(-1); - } - else { - if (e.dy>0) res = twok.shift(-2); - if (e.dy<0) res = twok.shift(2); - } - if (res) twok.addDigit(); - twok.render(); - } -} - -var twok = new TwoK(); -twok.addDigit(); twok.addDigit(); -twok.render(); -Bangle.on("drag", dragHandler); diff --git a/apps/2047++/README.md b/apps/2047++/README.md deleted file mode 100644 index 5b70423e4..000000000 --- a/apps/2047++/README.md +++ /dev/null @@ -1,6 +0,0 @@ - -# Game of 2047++ - -Tile shifting game inspired by the well known 2048 game. Also very similar to another Bangle game, Game1024. - -Attempt to combine equal numbers by swiping left, right, up or down. diff --git a/apps/2047++/app-icon.js b/apps/2047++/app-icon.js deleted file mode 100644 index 4086d1879..000000000 --- a/apps/2047++/app-icon.js +++ /dev/null @@ -1 +0,0 @@ -require("heatshrink").decompress(atob("mEwxH+AH4A/AH4A31gAeFtoxPF9wujGBYQG1YAWF6ur5gAYGIovOFzIABF6ReaMAwv/F/4v/F7ejv9/0Yvq1Eylksv4vqvIuBF9ZeDF9ZeBqovr1AsB0YvrLwXMF9ReDF9ZeBq1/v4vBqowKF7lWFYIAFF/7vXAAa/qF+jxB0YvsABov/F/4v/F6WsF7YgEF5xgaLwgvPGIQAWDwwvQADwvJGEguKF+AxhFpoA/AH4A/AFI=")) \ No newline at end of file diff --git a/apps/2047++/app.png b/apps/2047++/app.png deleted file mode 100644 index d1fb4a5e5cbadce3da7b36806d4907f680f8f1bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 759 zcmVYCuD-J|F04S(qype>Ll^oVPK(#&(MEqX}dr+-4N41U&D6G<#pk8p=ry~PL z8P~wDv0Fxk@G(D*-Esf`5DS+uaYFpJB+Wpns^Zb}E7&tzFF7%tm102J6nd69|4+P3 zr1VfMt5{y0fI>`0^KD2mu=F8{y6M673*Til--d7lyX64hte$~F4EL^Xh;F_M;RY5n zQPi8Q(T|*z{|6UpV5c0w+w9;*9}v8ZE@h%j4t73gCg!Qfe`}$Ac#sB~}C%=m9 zQmlcEAIAXzTR($HE?;WPt>nU3$%Ta*5c>_tUp2cB`Ud77yzh$Lczg#y>rX6t^Z|D> zcQA?REP&Q#P6pBq$e1?!8Tl#X8W=W?3|OSe*3omHjttb47#RG02|5f6e$ zObTJ!ml%i%20ylab9U#WUDz$7W@n({nZhq+5~`IO*5Pi07qm053E*;P(4-Kmo@>1; z>;uNw7hc?M3Z*1!=?Nlw%8PRi7>4l#z$>YW4#!KwFcx?T+e^N5I_>#$tusSJ+zSuc p5YZ-MEM*wRg54#bi;K&M^BdjW!v$Q*XjK3J002ovPDHLkV1lLySIGbX diff --git a/apps/2047++/metadata.json b/apps/2047++/metadata.json deleted file mode 100644 index f887d95d9..000000000 --- a/apps/2047++/metadata.json +++ /dev/null @@ -1,14 +0,0 @@ -{ "id": "2047++", - "name": "2047++", - "shortName":"2047++", - "icon": "app.png", - "version":"0.01", - "description": "Bangle version of a tile shifting game", - "supports" : ["BANGLEJS2"], - "readme": "README.md", - "tags": "game", - "storage": [ - {"name":"2047++.app.js","url":"2047++.app.js"}, - {"name":"2047++.img","url":"app-icon.js","evaluate":true} - ] -} From 80246d2398a93311aaa131886f873b54da705a66 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 15:00:54 -0400 Subject: [PATCH 3/6] New app 2047pp --- apps/2047pp/2047pp.app.js | 129 ++++++++++++++++++++++++++++++++++++++ apps/2047pp/README.md | 6 ++ apps/2047pp/app-icon.js | 1 + apps/2047pp/app.png | Bin 0 -> 759 bytes apps/2047pp/metadata.json | 14 +++++ 5 files changed, 150 insertions(+) create mode 100644 apps/2047pp/2047pp.app.js create mode 100644 apps/2047pp/README.md create mode 100644 apps/2047pp/app-icon.js create mode 100644 apps/2047pp/app.png create mode 100644 apps/2047pp/metadata.json diff --git a/apps/2047pp/2047pp.app.js b/apps/2047pp/2047pp.app.js new file mode 100644 index 000000000..b508d8f07 --- /dev/null +++ b/apps/2047pp/2047pp.app.js @@ -0,0 +1,129 @@ + + +class TwoK { + constructor() { + this.b = Array(4).fill().map(() => Array(4).fill(0)); + this.score = 0; + this.cmap = {0: "#caa", 2:"#ccc", 4: "#bcc", 8: "#ba6", 16: "#e61", 32: "#d20", 64: "#d00", 128: "#da0", 256: "#ec0", 512: "#dd0"}; + } + drawBRect(x1, y1, x2, y2, th, c, cf) { + g.setColor(c); + for (i=0; i 4) g.setColor(1, 1, 1); + else g.setColor(0, 0, 0); + g.setFont("Vector", bh*(b>8 ? (b>64 ? (b>512 ? 0.32 : 0.4) : 0.6) : 0.7)); + if (b>0) g.drawString(b.toString(), xo+(x+0.5)*bw+1, yo+(y+0.5)*bh); + } + } + shift(d) { // +/-1: shift x, +/- 2: shift y + var crc = E.CRC32(this.b.toString()); + if (d==-1) { // shift x left + for (y=0; y<4; ++y) { + for (x=2; x>=0; x--) + if (this.b[y][x]==0) { + for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; + this.b[y][3] = 0; moved = true; + } + for (x=0; x<3; ++x) + if (this.b[y][x]==this.b[y][x+1]) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y][x+1]; + for (j=x+1; j<3; ++j) this.b[y][j] = this.b[y][j+1]; + this.b[y][3] = 0; moved = true; + } + } + } + else if (d==1) { // shift x right + for (y=0; y<4; ++y) { + for (x=1; x<4; x++) + if (this.b[y][x]==0) { + for (i=x; i>0; i--) this.b[y][i] = this.b[y][i-1]; + this.b[y][0] = 0; + } + for (x=3; x>0; --x) + if (this.b[y][x]==this.b[y][x-1]) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y][x-1] ; + for (j=x-1; j>0; j--) this.b[y][j] = this.b[y][j-1]; + this.b[y][0] = 0; + } + } + } + else if (d==-2) { // shift y down + for (x=0; x<4; ++x) { + for (y=1; y<4; y++) + if (this.b[y][x]==0) { + for (i=y; i>0; i--) this.b[i][x] = this.b[i-1][x]; + this.b[0][x] = 0; + } + for (y=3; y>0; y--) + if (this.b[y][x]==this.b[y-1][x] || this.b[y][x]==0) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y-1][x]; + for (j=y-1; j>0; j--) this.b[j][x] = this.b[j-1][x]; + this.b[0][x] = 0; + } + } + } + else if (d==2) { // shift y up + for (x=0; x<4; ++x) { + for (y=2; y>=0; y--) + if (this.b[y][x]==0) { + for (i=y; i<3; i++) this.b[i][x] = this.b[i+1][x]; + this.b[3][x] = 0; + } + for (y=0; y<3; ++y) + if (this.b[y][x]==this.b[y+1][x] || this.b[y][x]==0) { + this.score += 2*this.b[y][x]; + this.b[y][x] += this.b[y+1][x]; + for (j=y+1; j<3; ++j) this.b[j][x] = this.b[j+1][x]; + this.b[3][x] = 0; + } + } + } + return (E.CRC32(this.b.toString())!=crc); + } + addDigit() { + var d = Math.random()>0.9 ? 4 : 2; + var id = Math.floor(Math.random()*16); + while (this.b[Math.floor(id/4)][id%4] > 0) id = Math.floor(Math.random()*16); + this.b[Math.floor(id/4)][id%4] = d; + } +} + +function dragHandler(e) { + if (e.b && (Math.abs(e.dx)>7 || Math.abs(e.dy)>7)) { + var res = false; + if (Math.abs(e.dx)>Math.abs(e.dy)) { + if (e.dx>0) res = twok.shift(1); + if (e.dx<0) res = twok.shift(-1); + } + else { + if (e.dy>0) res = twok.shift(-2); + if (e.dy<0) res = twok.shift(2); + } + if (res) twok.addDigit(); + twok.render(); + } +} + +var twok = new TwoK(); +twok.addDigit(); twok.addDigit(); +twok.render(); +Bangle.on("drag", dragHandler); diff --git a/apps/2047pp/README.md b/apps/2047pp/README.md new file mode 100644 index 000000000..e685946c1 --- /dev/null +++ b/apps/2047pp/README.md @@ -0,0 +1,6 @@ + +# Game of 2047pp (2047++) + +Tile shifting game inspired by the well known 2048 game. Also very similar to another Bangle game, Game1024. + +Attempt to combine equal numbers by swiping left, right, up or down. diff --git a/apps/2047pp/app-icon.js b/apps/2047pp/app-icon.js new file mode 100644 index 000000000..4086d1879 --- /dev/null +++ b/apps/2047pp/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4A31gAeFtoxPF9wujGBYQG1YAWF6ur5gAYGIovOFzIABF6ReaMAwv/F/4v/F7ejv9/0Yvq1Eylksv4vqvIuBF9ZeDF9ZeBqovr1AsB0YvrLwXMF9ReDF9ZeBq1/v4vBqowKF7lWFYIAFF/7vXAAa/qF+jxB0YvsABov/F/4v/F6WsF7YgEF5xgaLwgvPGIQAWDwwvQADwvJGEguKF+AxhFpoA/AH4A/AFI=")) \ No newline at end of file diff --git a/apps/2047pp/app.png b/apps/2047pp/app.png new file mode 100644 index 0000000000000000000000000000000000000000..d1fb4a5e5cbadce3da7b36806d4907f680f8f1bb GIT binary patch literal 759 zcmVYCuD-J|F04S(qype>Ll^oVPK(#&(MEqX}dr+-4N41U&D6G<#pk8p=ry~PL z8P~wDv0Fxk@G(D*-Esf`5DS+uaYFpJB+Wpns^Zb}E7&tzFF7%tm102J6nd69|4+P3 zr1VfMt5{y0fI>`0^KD2mu=F8{y6M673*Til--d7lyX64hte$~F4EL^Xh;F_M;RY5n zQPi8Q(T|*z{|6UpV5c0w+w9;*9}v8ZE@h%j4t73gCg!Qfe`}$Ac#sB~}C%=m9 zQmlcEAIAXzTR($HE?;WPt>nU3$%Ta*5c>_tUp2cB`Ud77yzh$Lczg#y>rX6t^Z|D> zcQA?REP&Q#P6pBq$e1?!8Tl#X8W=W?3|OSe*3omHjttb47#RG02|5f6e$ zObTJ!ml%i%20ylab9U#WUDz$7W@n({nZhq+5~`IO*5Pi07qm053E*;P(4-Kmo@>1; z>;uNw7hc?M3Z*1!=?Nlw%8PRi7>4l#z$>YW4#!KwFcx?T+e^N5I_>#$tusSJ+zSuc p5YZ-MEM*wRg54#bi;K&M^BdjW!v$Q*XjK3J002ovPDHLkV1lLySIGbX literal 0 HcmV?d00001 diff --git a/apps/2047pp/metadata.json b/apps/2047pp/metadata.json new file mode 100644 index 000000000..7c120efec --- /dev/null +++ b/apps/2047pp/metadata.json @@ -0,0 +1,14 @@ +{ "id": "2047pp", + "name": "2047pp", + "shortName":"2047pp", + "icon": "app.png", + "version":"0.01", + "description": "Bangle version of a tile shifting game", + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "tags": "game", + "storage": [ + {"name":"2047pp.app.js","url":"2047pp.app.js"}, + {"name":"2047pp.img","url":"app-icon.js","evaluate":true} + ] +} From 0342b131249937c8a692f0a500748d264b3ab05e Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 15:38:16 -0400 Subject: [PATCH 4/6] Support Bangles 1&2 --- apps/2047pp/2047pp.app.js | 31 +++++++++++++++++++++---------- apps/2047pp/README.md | 3 ++- apps/2047pp/metadata.json | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/apps/2047pp/2047pp.app.js b/apps/2047pp/2047pp.app.js index b508d8f07..9b2283036 100644 --- a/apps/2047pp/2047pp.app.js +++ b/apps/2047pp/2047pp.app.js @@ -1,15 +1,13 @@ - - class TwoK { constructor() { this.b = Array(4).fill().map(() => Array(4).fill(0)); this.score = 0; this.cmap = {0: "#caa", 2:"#ccc", 4: "#bcc", 8: "#ba6", 16: "#e61", 32: "#d20", 64: "#d00", 128: "#da0", 256: "#ec0", 512: "#dd0"}; } - drawBRect(x1, y1, x2, y2, th, c, cf) { + drawBRect(x1, y1, x2, y2, th, c, cf, fill) { g.setColor(c); for (i=0; i 4) g.setColor(1, 1, 1); else g.setColor(0, 0, 0); g.setFont("Vector", bh*(b>8 ? (b>64 ? (b>512 ? 0.32 : 0.4) : 0.6) : 0.7)); @@ -38,14 +36,14 @@ class TwoK { for (x=2; x>=0; x--) if (this.b[y][x]==0) { for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; - this.b[y][3] = 0; moved = true; + this.b[y][3] = 0; } for (x=0; x<3; ++x) if (this.b[y][x]==this.b[y][x+1]) { this.score += 2*this.b[y][x]; this.b[y][x] += this.b[y][x+1]; for (j=x+1; j<3; ++j) this.b[y][j] = this.b[y][j+1]; - this.b[y][3] = 0; moved = true; + this.b[y][3] = 0; } } } @@ -123,7 +121,20 @@ function dragHandler(e) { } } +function swipeHandler() { + +} + +function buttonHandler() { + +} + var twok = new TwoK(); twok.addDigit(); twok.addDigit(); twok.render(); -Bangle.on("drag", dragHandler); +if (process.env.HWVERSION==2) Bangle.on("drag", dragHandler); +else if (process.env.HWVERSION==1) { + Bangle.on("swipe", (e) => { res = twok.shift(e); if (res) twok.addDigit(); twok.render(); }); + setWatch(() => { res = twok.shift(2); if (res) twok.addDigit(); twok.render(); }, BTN1, {repeat: true}); + setWatch(() => { res = twok.shift(-2); if (res) twok.addDigit(); twok.render(); }, BTN3, {repeat: true}); +} diff --git a/apps/2047pp/README.md b/apps/2047pp/README.md index e685946c1..8228892fd 100644 --- a/apps/2047pp/README.md +++ b/apps/2047pp/README.md @@ -3,4 +3,5 @@ Tile shifting game inspired by the well known 2048 game. Also very similar to another Bangle game, Game1024. -Attempt to combine equal numbers by swiping left, right, up or down. +Attempt to combine equal numbers by swiping left, right, up or down (on Bangle 2) or swiping left/right and using +the top/bottom button (Bangle 1). diff --git a/apps/2047pp/metadata.json b/apps/2047pp/metadata.json index 7c120efec..0241e9933 100644 --- a/apps/2047pp/metadata.json +++ b/apps/2047pp/metadata.json @@ -4,7 +4,7 @@ "icon": "app.png", "version":"0.01", "description": "Bangle version of a tile shifting game", - "supports" : ["BANGLEJS2"], + "supports" : ["BANGLEJS1","BANGLEJS2"], "readme": "README.md", "tags": "game", "storage": [ From 0c24bd397aeb82f5d3d1af2794e95942e9039c5f Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 15:40:28 -0400 Subject: [PATCH 5/6] Use correct string for supported devices --- apps/2047pp/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/2047pp/metadata.json b/apps/2047pp/metadata.json index 0241e9933..0a362c583 100644 --- a/apps/2047pp/metadata.json +++ b/apps/2047pp/metadata.json @@ -4,7 +4,7 @@ "icon": "app.png", "version":"0.01", "description": "Bangle version of a tile shifting game", - "supports" : ["BANGLEJS1","BANGLEJS2"], + "supports" : ["BANGLEJS","BANGLEJS2"], "readme": "README.md", "tags": "game", "storage": [ From fd8cc60283512c3aa649f525a4d01482af79e531 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 23 Mar 2022 17:24:42 -0400 Subject: [PATCH 6/6] Make border thicknesses more consistent; add screenshot; allow running in emulator. --- apps/2047pp/2047pp.app.js | 8 ++++---- apps/2047pp/2047pp_screenshot.png | Bin 0 -> 4541 bytes apps/2047pp/README.md | 2 ++ apps/2047pp/metadata.json | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 apps/2047pp/2047pp_screenshot.png diff --git a/apps/2047pp/2047pp.app.js b/apps/2047pp/2047pp.app.js index 9b2283036..58738d04a 100644 --- a/apps/2047pp/2047pp.app.js +++ b/apps/2047pp/2047pp.app.js @@ -18,11 +18,11 @@ class TwoK { bw = Math.floor(w/4); g.clearRect(0, 0, g.getWidth()-1, yo).setFontAlign(0, 0, 0); g.setFont("Vector", 16).setColor("#fff").drawString("Score:"+this.score.toString(), g.getWidth()/2, 8); - this.drawBRect(xo-2, yo-2, xo+w+2, yo+h, 2, "#a88", "#caa", false); + this.drawBRect(xo-3, yo-3, xo+w+2, yo+h+2, 4, "#a88", "#caa", false); for (y=0; y<4; ++y) for (x=0; x<4; ++x) { b = this.b[y][x]; - this.drawBRect(xo+x*bw, yo+y*bh-2, xo+(x+1)*bh, yo+(y+1)*bh-2, 4, "#a88", this.cmap[b], true); + this.drawBRect(xo+x*bw, yo+y*bh-1, xo+(x+1)*bh-1, yo+(y+1)*bh-2, 4, "#a88", this.cmap[b], true); if (b > 4) g.setColor(1, 1, 1); else g.setColor(0, 0, 0); g.setFont("Vector", bh*(b>8 ? (b>64 ? (b>512 ? 0.32 : 0.4) : 0.6) : 0.7)); @@ -35,7 +35,7 @@ class TwoK { for (y=0; y<4; ++y) { for (x=2; x>=0; x--) if (this.b[y][x]==0) { - for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; + for (i=x; i<3; i++) this.b[y][i] = this.b[y][i+1]; this.b[y][3] = 0; } for (x=0; x<3; ++x) @@ -133,7 +133,7 @@ var twok = new TwoK(); twok.addDigit(); twok.addDigit(); twok.render(); if (process.env.HWVERSION==2) Bangle.on("drag", dragHandler); -else if (process.env.HWVERSION==1) { +if (process.env.HWVERSION==1) { Bangle.on("swipe", (e) => { res = twok.shift(e); if (res) twok.addDigit(); twok.render(); }); setWatch(() => { res = twok.shift(2); if (res) twok.addDigit(); twok.render(); }, BTN1, {repeat: true}); setWatch(() => { res = twok.shift(-2); if (res) twok.addDigit(); twok.render(); }, BTN3, {repeat: true}); diff --git a/apps/2047pp/2047pp_screenshot.png b/apps/2047pp/2047pp_screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..8c407fb6fe4b78d2f60c30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%17S?9Yp2z~UWnX#_V(u*KA8AbGjFX+^F+i?C- zNAM)&DX)J{M{qZ=<{Wx%a8z9mK2aTx$spEiD_463;lPxz{UtKzd}i`vl}|0pV}TDCMZ4XwL;Du7ItOT3=1r z&ADFm`z?s>NJKb%ISA5g{Z>gg1XB~9-!?rFRGIh(B_OX9mjUI>~iCb3=#x?A+Dq1(j{OfVyu7rq{zpyT3bU&p@eDa-JVVeG-zx zkc0ceLwH_l;_D#gg85xcI~@CfgQgsHB_>b_dXZ}fVpWOit)+kYBeG=aqAbBk2KS4~ zD=X)8lWs>UD7>6VcMv2x=N`jw4XdK#5rVPM1#p$-{Yms93{IvyTI;P>UATv+pFTTx zlGEt1TqLuI!ug+w=fMD68E}Po6Hd@xP&XzmLs#g=w^r3`<#i$AplgpM&QWt81m1Kc q>N+taF@Qa-*aRuo?PU@q^JpbV050Y_HX{GWfSubMwmzUSWB(7cyXRm4 literal 0 HcmV?d00001 diff --git a/apps/2047pp/README.md b/apps/2047pp/README.md index 8228892fd..cac3323a6 100644 --- a/apps/2047pp/README.md +++ b/apps/2047pp/README.md @@ -5,3 +5,5 @@ Tile shifting game inspired by the well known 2048 game. Also very similar to an Attempt to combine equal numbers by swiping left, right, up or down (on Bangle 2) or swiping left/right and using the top/bottom button (Bangle 1). + +![Screenshot](./2047pp_screenshot.png) diff --git a/apps/2047pp/metadata.json b/apps/2047pp/metadata.json index 0a362c583..f0fd6c1e3 100644 --- a/apps/2047pp/metadata.json +++ b/apps/2047pp/metadata.json @@ -5,6 +5,7 @@ "version":"0.01", "description": "Bangle version of a tile shifting game", "supports" : ["BANGLEJS","BANGLEJS2"], + "allow_emulator": true, "readme": "README.md", "tags": "game", "storage": [