diff --git a/cache.appcache b/cache.appcache new file mode 100644 index 0000000..222df92 --- /dev/null +++ b/cache.appcache @@ -0,0 +1,46 @@ +# Updated: 2014-08-10T02:22:05+02:00 +CACHE MANIFEST + +# Adds the ability to play the game online. +# The following comment needs to be updated whenever a change is made. +# Run `rake appcache:update` to do so +# Updated: 2014-08-10T02:20:58+02:00 + +# Main page +index.html + +# CSS +style/main.css + +# Fonts +style/fonts/clear-sans.css +style/fonts/ClearSans-Bold-webfont.eot +style/fonts/ClearSans-Bold-webfont.svg +style/fonts/ClearSans-Bold-webfont.woff +style/fonts/ClearSans-Light-webfont.eot +style/fonts/ClearSans-Light-webfont.svg +style/fonts/ClearSans-Light-webfont.woff +style/fonts/ClearSans-Regular-webfont.eot +style/fonts/ClearSans-Regular-webfont.svg +style/fonts/ClearSans-Regular-webfont.woff + +# Other resources +meta/apple-touch-icon.png +meta/icon_bitcoin.svg +meta/icon_pp.svg +meta/og_image.png + +# JavaScript +js/animframe_polyfill.js +js/application.js +js/game_manager.js +js/grid.js +js/html_actuator.js +js/keyboard_input_manager.js +js/local_score_manager.js +js/tile.js + +favicon.ico + +NETWORK: +* diff --git a/favicon.ico b/favicon.ico index 22109e0..9f535e5 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/js/game_manager.js b/js/game_manager.js index 98c6f36..3e51cad 100644 --- a/js/game_manager.js +++ b/js/game_manager.js @@ -121,51 +121,45 @@ GameManager.prototype.move = function (direction) { cell = { x: x, y: y }; tile = self.grid.cellContent(cell); - if(tile && tile.merged) { - self.grid.removeTile(tile); - } - else if (tile) { + if (tile && tile.merged) { + self.grid.removeTile(tile); + } else if (tile) { var positions = self.findFarthestPosition(cell, vector); var next = self.grid.cellContent(positions.next); var pos2 = null; var next2 = null; - if(next) - { - pos2 = self.findFarthestPosition({x: next.x, y: next.y}, vector); - next2 = self.grid.cellContent(pos2.next); + if (next) { + pos2 = self.findFarthestPosition({x: next.x, y: next.y}, vector); + next2 = self.grid.cellContent(pos2.next); } - // Only one merger per row traversal? - if (next && next.value === tile.value && next2 && next2.value === tile.value && !next.mergedFrom && next != next2) { + if (next && next.value === tile.value && next2 && next2.value === tile.value && !next.mergedFrom && !next2.mergedFrom && next != next2) { var merged = new Tile(pos2.next, tile.value * 3); merged.mergedFrom = [next2, next, tile]; - tile.merged = true; - next.merged = true; - next2.merged = true; - + tile.merged = true; + next.merged = true; + next2.merged = true; + self.grid.removeTile(tile); - self.grid.removeTile(next); - self.grid.removeTile(next2); + self.grid.removeTile(next); + self.grid.removeTile(next2); - self.grid.insertTile(merged); + self.grid.insertTile(merged); // Converge the two tiles' positions tile.updatePosition(pos2.next); - next.updatePosition(pos2.next); + next.updatePosition(pos2.next); // Update the score self.score += merged.value; // The mighty 2048 tile if (merged.value === 243) self.won = true; - } - - else if (!tile.merged){ + } else if (!tile.merged){ self.moveTile(tile, positions.farthest); } if (tile && !self.positionsEqual(cell, tile)) { moved = true; // The tile moved from its original cell! } - } - + } }); }); diff --git a/meta/apple-touch-icon.png b/meta/apple-touch-icon.png index 3fd20f6..c061d67 100644 Binary files a/meta/apple-touch-icon.png and b/meta/apple-touch-icon.png differ