diff --git a/apps/game1024/ChangeLog b/apps/game1024/ChangeLog index af0925b0f..ffb1f94bc 100644 --- a/apps/game1024/ChangeLog +++ b/apps/game1024/ChangeLog @@ -1,4 +1,5 @@ 0.01: Initial version 0.02: Temporary intermediate version 0.03: Basic colors -0.04: Bug fix score reset after Game Over, new icon \ No newline at end of file +0.04: Bug fix score reset after Game Over, new icon +0.05: Chevron marker on the randomly added square \ No newline at end of file diff --git a/apps/game1024/README.md b/apps/game1024/README.md index 474e8c97e..500453145 100644 --- a/apps/game1024/README.md +++ b/apps/game1024/README.md @@ -11,6 +11,8 @@ When two tiles with the same number are squashed together they will add up as ex **3 + 3 = 4** or **C + C = D** which is a representation of **2^3 + 2^3 = 2^4 = 16** +After each move a new tile will be added on a random empty square. The value can be 1 or 2, and will be marked with a chevron. + So you can continue till you reach **1024** which equals **2^(10)**. So when you reach tile **10** you have won. The score is maintained by adding the outcome of the sum of all pairs of squashed tiles (4+16+4+8 etc.) diff --git a/apps/game1024/app.js b/apps/game1024/app.js index 3b96b327f..9f6081376 100644 --- a/apps/game1024/app.js +++ b/apps/game1024/app.js @@ -17,7 +17,7 @@ const cellChars = [ const maxUndoLevels = 4; const noExceptions = true; let charIndex = 0; // plain numbers on the grid - +const themeBg = g.theme.bg; const scores = { @@ -304,13 +304,29 @@ class Cell { this.previousExpVals=[]; this.idx = idx; this.cb = cb; + this.isRndm = false; + this.ax = x0; + this.ay = Math.floor(0.2*width+y0); + this.bx = Math.floor(0.3*width+x0); + this.by = Math.floor(0.5*width+y0); + this.cx = x0; + this.cy = Math.floor(0.8*width+y0); } getColor(i) { return cellColors[i >= cellColors.length ? cellColors.length -1 : i]; } drawBg() { - g.setColor(this.getColor(this.expVal).bg) - .fillRect(this.x0, this.y0, this.x1, this.y1); + debug(()=>console.log("Drawbg!!")); + if (this.isRndm == true) { + debug(()=>console.log('Random: (ax)', this.ax)); + g.setColor(this.getColor(this.expVal).bg) + .fillRect(this.x0, this.y0, this.x1, this.y1) + .setColor(themeBg) + .fillPoly([this.cx,this.cy,this.bx,this.by,this.ax,this.ay]); + } else { + g.setColor(this.getColor(this.expVal).bg) + .fillRect(this.x0, this.y0, this.x1, this.y1); + } } drawNumber() { if (this.expVal !== 0) { @@ -346,6 +362,19 @@ class Cell { this.cb(this.expVal); } } + setRndmFalse() { + this.isRndm = false; + } + setRndmTrue() { + this.isRndm = true; + } + drawRndmIndicator(){ + if (this.isRndm == true) { + debug(()=>console.log('Random: (ax)', this.ax)); + g.setColor(this.getColor(0).bg) + .fillPoly(this.ax,this.ay,this.bx,this.by,this.cx,this.cy); + } + } } function undoGame() { @@ -387,11 +416,12 @@ function createGrid () { } } function messageGameOver () { - g.setColor("#1a0d00") + const c = (g.theme.dark) ? {"fg": "#FFFFFF", "bg": "#808080"} : {"fg": "#FF0000", "bg": "#000000"}; + g.setColor(c.bg) .setFont12x20(2).setFontAlign(0,0,0) .drawString("G A M E", middle.x+13, middle.y-24) .drawString("O V E R !", middle.x+13, middle.y+24); - g.setColor("#ffffff") + g.setColor(c.fg) .drawString("G A M E", middle.x+12, middle.y-25) .drawString("O V E R !", middle.x+12, middle.y+25); } @@ -417,11 +447,13 @@ function addRandomNumber() { if (emptySquaresIdxs.length > 0) { let randomIdx = Math.floor( emptySquaresIdxs.length * Math.random() ); allSquares[emptySquaresIdxs[randomIdx]].setExpVal(makeRandomNumber()); + allSquares[emptySquaresIdxs[randomIdx]].setRndmTrue(); } } function drawGrid() { allSquares.forEach(sq => { sq.drawBg(); + // sq.drawRndmIndicator(); sq.drawNumber(); }); } @@ -497,7 +529,7 @@ function handlePopUpClicks(btn) { function resetGame() { g.clear(); scores.reset(); - allSquares.forEach(sq => {sq.setExpVal(0);sq.removeUndo();}); + allSquares.forEach(sq => {sq.setExpVal(0);sq.removeUndo();sq.setRndmFalse();}); addRandomNumber(); addRandomNumber(); drawGrid(); @@ -614,6 +646,7 @@ function runGame(dir){ mover.nonEmptyCells(dir); mover.mergeEqlCells(dir); mover.nonEmptyCells(dir); + allSquares.forEach(sq => {sq.setRndmFalse();}); addRandomNumber(); drawGrid(); scores.check(); diff --git a/apps/game1024/game1024_sc_dump_dark.png b/apps/game1024/game1024_sc_dump_dark.png index 15ecb87d9..87577ecfa 100644 Binary files a/apps/game1024/game1024_sc_dump_dark.png and b/apps/game1024/game1024_sc_dump_dark.png differ diff --git a/apps/game1024/game1024_sc_dump_light.png b/apps/game1024/game1024_sc_dump_light.png index 286257be4..06ada65ac 100644 Binary files a/apps/game1024/game1024_sc_dump_light.png and b/apps/game1024/game1024_sc_dump_light.png differ diff --git a/apps/game1024/metadata.json b/apps/game1024/metadata.json index 6d72b9e9d..557d77b89 100644 --- a/apps/game1024/metadata.json +++ b/apps/game1024/metadata.json @@ -1,7 +1,7 @@ { "id": "game1024", "name": "1024 Game", "shortName" : "1024 Game", - "version": "0.04", + "version": "0.05", "icon": "game1024.png", "screenshots": [ {"url":"screenshot.png" } ], "readme":"README.md", diff --git a/apps/game1024/screenshot.png b/apps/game1024/screenshot.png index 5cc244bda..5537a5eb5 100644 Binary files a/apps/game1024/screenshot.png and b/apps/game1024/screenshot.png differ diff --git a/apps/game1024/scrnshot_dn_300.jpg b/apps/game1024/scrnshot_dn_300.jpg deleted file mode 100644 index 2f4cc4bda..000000000 Binary files a/apps/game1024/scrnshot_dn_300.jpg and /dev/null differ diff --git a/apps/game1024/scrnshot_lc_300.jpg b/apps/game1024/scrnshot_lc_300.jpg deleted file mode 100644 index 0a5e20bfb..000000000 Binary files a/apps/game1024/scrnshot_lc_300.jpg and /dev/null differ