From 1e701a7a3cb9be4ce1714e90a79cbdfbebe57a46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=94=98=E7=9A=93=E7=8E=AE?= <1436619890@qq.com>
Date: Mon, 31 Oct 2022 17:43:09 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0new=20=E9=A1=B9=E7=9B=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 2 +
.jshintrc | 19 +
CONTRIBUTING.md | 33 +
LICENSE.txt | 21 +
README2.md | 40 +
Rakefile | 11 +
favicon.ico | Bin 0 -> 4286 bytes
index.html | 99 +
js/animframe_polyfill.js | 28 +
js/application.js | 4 +
js/bind_polyfill.js | 9 +
js/classlist_polyfill.js | 71 +
js/game_manager.js | 272 ++
js/grid.js | 117 +
js/html_actuator.js | 139 +
js/keyboard_input_manager.js | 144 +
js/local_storage_manager.js | 63 +
js/tile.js | 27 +
meta/apple-touch-icon.png | Bin 0 -> 5808 bytes
meta/apple-touch-startup-image-640x1096.png | Bin 0 -> 70707 bytes
meta/apple-touch-startup-image-640x920.png | Bin 0 -> 42020 bytes
package-lock.json | 3765 +++++++++++++++++++
package.json | 18 +
preview.yml | 10 +
style/fonts/ClearSans-Bold-webfont.eot | Bin 0 -> 23821 bytes
style/fonts/ClearSans-Bold-webfont.svg | 640 ++++
style/fonts/ClearSans-Bold-webfont.woff | Bin 0 -> 27120 bytes
style/fonts/ClearSans-Light-webfont.eot | Bin 0 -> 25570 bytes
style/fonts/ClearSans-Light-webfont.svg | 670 ++++
style/fonts/ClearSans-Light-webfont.woff | Bin 0 -> 28700 bytes
style/fonts/ClearSans-Regular-webfont.eot | Bin 0 -> 23490 bytes
style/fonts/ClearSans-Regular-webfont.svg | 669 ++++
style/fonts/ClearSans-Regular-webfont.woff | Bin 0 -> 26764 bytes
style/fonts/clear-sans.css | 30 +
style/helpers.scss | 82 +
style/main.css | 758 ++++
style/main.scss | 549 +++
37 files changed, 8290 insertions(+)
create mode 100644 .gitignore
create mode 100644 .jshintrc
create mode 100644 CONTRIBUTING.md
create mode 100644 LICENSE.txt
create mode 100644 README2.md
create mode 100644 Rakefile
create mode 100644 favicon.ico
create mode 100644 index.html
create mode 100644 js/animframe_polyfill.js
create mode 100644 js/application.js
create mode 100644 js/bind_polyfill.js
create mode 100644 js/classlist_polyfill.js
create mode 100644 js/game_manager.js
create mode 100644 js/grid.js
create mode 100644 js/html_actuator.js
create mode 100644 js/keyboard_input_manager.js
create mode 100644 js/local_storage_manager.js
create mode 100644 js/tile.js
create mode 100644 meta/apple-touch-icon.png
create mode 100644 meta/apple-touch-startup-image-640x1096.png
create mode 100644 meta/apple-touch-startup-image-640x920.png
create mode 100644 package-lock.json
create mode 100644 package.json
create mode 100644 preview.yml
create mode 100644 style/fonts/ClearSans-Bold-webfont.eot
create mode 100644 style/fonts/ClearSans-Bold-webfont.svg
create mode 100644 style/fonts/ClearSans-Bold-webfont.woff
create mode 100644 style/fonts/ClearSans-Light-webfont.eot
create mode 100644 style/fonts/ClearSans-Light-webfont.svg
create mode 100644 style/fonts/ClearSans-Light-webfont.woff
create mode 100644 style/fonts/ClearSans-Regular-webfont.eot
create mode 100644 style/fonts/ClearSans-Regular-webfont.svg
create mode 100644 style/fonts/ClearSans-Regular-webfont.woff
create mode 100644 style/fonts/clear-sans.css
create mode 100644 style/helpers.scss
create mode 100644 style/main.css
create mode 100644 style/main.scss
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..75856f8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.sass-cache/
+node_modules
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..87dbf9a
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,19 @@
+{
+ "esnext": true,
+ "indent": 2,
+ "maxlen": 80,
+ "freeze": true,
+ "camelcase": true,
+ "unused": true,
+ "eqnull": true,
+ "proto": true,
+ "supernew": true,
+ "noyield": true,
+ "evil": true,
+ "node": true,
+ "boss": true,
+ "expr": true,
+ "loopfunc": true,
+ "white": true,
+ "maxdepth": 4
+}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..8b269ae
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,33 @@
+# Contributing
+Changes and improvements are more than welcome! Feel free to fork and open a pull request.
+
+Please follow the house rules to have a bigger chance of your contribution being merged.
+
+## House rules
+
+### How to make changes
+ - To make changes, create a new branch based on `master` (do not create one from `gh-pages` unless strictly necessary) and make them there, then create a Pull Request to master.
+ `gh-pages` is different from master in that it contains sharing features, analytics and other things that have no direct bearing with the game. `master` is the "pure" version of the game.
+ - If you want to modify the CSS, please edit the SCSS files present in `style/`: `main.scss` and others. Don't edit the `main.css`, because it's supposed to be generated.
+ In order to compile your SCSS modifications, you need to use the `sass` gem (install it by running `gem install sass` once Ruby is installed).
+ To run SASS, simply use the following command:
+ `sass --unix-newlines --watch style/main.scss`
+ SASS will automatically recompile your css when changed.
+ - `Rakefile` contains some tasks that help during development. Feel free to add useful tasks if needed.
+ - Please use 2-space indentation when editing the JavaScript. A `.jshintrc` file is present, which will help your code to follow the guidelines if you install and run `jshint`.
+ - Please test your modification thoroughly before submitting your Pull Request.
+
+### Changes that might not be accepted
+We have to be conservative with the core game. This means that some modifications won't be merged, or will have to be evaluated carefully before being merged:
+
+ - Undo/redo features
+ - Save/reload features
+ - Changes to how the tiles look or their contents
+ - Changes to the layout
+ - Changes to the grid size
+
+### Changes that are welcome
+ - Bug fixes
+ - Compatibility improvements
+ - "Under the hood" enhancements
+ - Small changes that don't have an impact on the core gameplay
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..b0dbfa4
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Gabriele Cirulli
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README2.md b/README2.md
new file mode 100644
index 0000000..8f4bd71
--- /dev/null
+++ b/README2.md
@@ -0,0 +1,40 @@
+# 2048
+A small clone of [1024](https://play.google.com/store/apps/details?id=com.veewo.a1024), based on [Saming's 2048](http://saming.fr/p/2048/) (also a clone).
+
+Support Cloud IDE
+
+Made just for fun. [Play it here!](http://gabrielecirulli.github.io/2048/)
+
+The official app can also be found on the [Play Store](https://play.google.com/store/apps/details?id=com.gabrielecirulli.app2048) and [App Store!](https://itunes.apple.com/us/app/2048-by-gabriele-cirulli/id868076805)
+
+### Contributions
+
+[Anna Harren](https://github.com/iirelu/) and [sigod](https://github.com/sigod) are maintainers for this repository.
+
+Other notable contributors:
+
+ - [TimPetricola](https://github.com/TimPetricola) added best score storage
+ - [chrisprice](https://github.com/chrisprice) added custom code for swipe handling on mobile
+ - [marcingajda](https://github.com/marcingajda) made swipes work on Windows Phone
+ - [mgarciaisaia](https://github.com/mgarciaisaia) added support for Android 2.3
+
+Many thanks to [rayhaanj](https://github.com/rayhaanj), [Mechazawa](https://github.com/Mechazawa), [grant](https://github.com/grant), [remram44](https://github.com/remram44) and [ghoullier](https://github.com/ghoullier) for the many other good contributions.
+
+### Screenshot
+
+
+
+
+
+That screenshot is fake, by the way. I never reached 2048 :smile:
+
+## Contributing
+Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.
+
+You can find the same information in the [contributing guide.](https://github.com/gabrielecirulli/2048/blob/master/CONTRIBUTING.md)
+
+## License
+2048 is licensed under the [MIT license.](https://github.com/gabrielecirulli/2048/blob/master/LICENSE.txt)
+
+## Donations
+I made this in my spare time, and it's hosted on GitHub (which means I don't have any hosting costs), but if you enjoyed the game and feel like buying me coffee, you can donate at my BTC address: `1Ec6onfsQmoP9kkL3zkpB6c5sA4PVcXU2i`. Thank you very much!
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..3e9851e
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,11 @@
+require "date"
+
+namespace :appcache do
+ desc "update the date in the appcache file (in the gh-pages branch)"
+ task :update do
+ appcache = File.read("cache.appcache")
+ updated = "# Updated: #{DateTime.now}"
+
+ File.write("cache.appcache", appcache.sub(/^# Updated:.*$/, updated))
+ end
+end
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..22109e04a9f44bde18ec7b7a4b7410d0246521bc
GIT binary patch
literal 4286
zcmeI0u}T9$5QaxAZ4|*eSlRmm7M9V@SMU{VQ>5?}d;{?n1WA#?B1H-d3kAW#!e}&!
z290>`cj4E~-Q@zpx`i3p?A^})&p$J}fvjc=?ypiYKJ9qfY|YFz+;B^_
zFn$f<2q!J!u7@9~i@DVw36{n#zAi#L=w1qYr#f#FwA?@S$6_fB4AP=j)up
z&-xU9K1cfvmODrDz4%vq5%c#q+Oh8+)rjYPd=HIz|I|hJ=PnrXPDE_>yDHg+*KulwNh1`
literal 0
HcmV?d00001
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..0da0ee0
--- /dev/null
+++ b/index.html
@@ -0,0 +1,99 @@
+
+
+
+
+ 2048
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Join the numbers and get to the 2048 tile!
+
New Game
+
+
+
+
+
+ How to play: Use your arrow keys to move the tiles. When two tiles with the same number touch, they merge into one!
+
+
+
+ Note: This site is the official version of 2048. You can play it on your phone via http://git.io/2048. All other apps or sites are derivatives or fakes, and should be used with caution.
+
+
+
+ Created by Gabriele Cirulli. Based on 1024 by Veewo Studio and conceptually similar to Threes by Asher Vollmer.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/animframe_polyfill.js b/js/animframe_polyfill.js
new file mode 100644
index 0000000..c524a99
--- /dev/null
+++ b/js/animframe_polyfill.js
@@ -0,0 +1,28 @@
+(function () {
+ var lastTime = 0;
+ var vendors = ['webkit', 'moz'];
+ for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
+ window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
+ window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
+ window[vendors[x] + 'CancelRequestAnimationFrame'];
+ }
+
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = function (callback) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
+ var id = window.setTimeout(function () {
+ callback(currTime + timeToCall);
+ },
+ timeToCall);
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+ }
+
+ if (!window.cancelAnimationFrame) {
+ window.cancelAnimationFrame = function (id) {
+ clearTimeout(id);
+ };
+ }
+}());
diff --git a/js/application.js b/js/application.js
new file mode 100644
index 0000000..2c1108e
--- /dev/null
+++ b/js/application.js
@@ -0,0 +1,4 @@
+// Wait till the browser is ready to render the game (avoids glitches)
+window.requestAnimationFrame(function () {
+ new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
+});
diff --git a/js/bind_polyfill.js b/js/bind_polyfill.js
new file mode 100644
index 0000000..8d9c4a4
--- /dev/null
+++ b/js/bind_polyfill.js
@@ -0,0 +1,9 @@
+Function.prototype.bind = Function.prototype.bind || function (target) {
+ var self = this;
+ return function (args) {
+ if (!(args instanceof Array)) {
+ args = [args];
+ }
+ self.apply(target, args);
+ };
+};
diff --git a/js/classlist_polyfill.js b/js/classlist_polyfill.js
new file mode 100644
index 0000000..1789ae7
--- /dev/null
+++ b/js/classlist_polyfill.js
@@ -0,0 +1,71 @@
+(function () {
+ if (typeof window.Element === "undefined" ||
+ "classList" in document.documentElement) {
+ return;
+ }
+
+ var prototype = Array.prototype,
+ push = prototype.push,
+ splice = prototype.splice,
+ join = prototype.join;
+
+ function DOMTokenList(el) {
+ this.el = el;
+ // The className needs to be trimmed and split on whitespace
+ // to retrieve a list of classes.
+ var classes = el.className.replace(/^\s+|\s+$/g, '').split(/\s+/);
+ for (var i = 0; i < classes.length; i++) {
+ push.call(this, classes[i]);
+ }
+ }
+
+ DOMTokenList.prototype = {
+ add: function (token) {
+ if (this.contains(token)) return;
+ push.call(this, token);
+ this.el.className = this.toString();
+ },
+ contains: function (token) {
+ return this.el.className.indexOf(token) != -1;
+ },
+ item: function (index) {
+ return this[index] || null;
+ },
+ remove: function (token) {
+ if (!this.contains(token)) return;
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] == token) break;
+ }
+ splice.call(this, i, 1);
+ this.el.className = this.toString();
+ },
+ toString: function () {
+ return join.call(this, ' ');
+ },
+ toggle: function (token) {
+ if (!this.contains(token)) {
+ this.add(token);
+ } else {
+ this.remove(token);
+ }
+
+ return this.contains(token);
+ }
+ };
+
+ window.DOMTokenList = DOMTokenList;
+
+ function defineElementGetter(obj, prop, getter) {
+ if (Object.defineProperty) {
+ Object.defineProperty(obj, prop, {
+ get: getter
+ });
+ } else {
+ obj.__defineGetter__(prop, getter);
+ }
+ }
+
+ defineElementGetter(HTMLElement.prototype, 'classList', function () {
+ return new DOMTokenList(this);
+ });
+})();
diff --git a/js/game_manager.js b/js/game_manager.js
new file mode 100644
index 0000000..1c13d15
--- /dev/null
+++ b/js/game_manager.js
@@ -0,0 +1,272 @@
+function GameManager(size, InputManager, Actuator, StorageManager) {
+ this.size = size; // Size of the grid
+ this.inputManager = new InputManager;
+ this.storageManager = new StorageManager;
+ this.actuator = new Actuator;
+
+ this.startTiles = 2;
+
+ this.inputManager.on("move", this.move.bind(this));
+ this.inputManager.on("restart", this.restart.bind(this));
+ this.inputManager.on("keepPlaying", this.keepPlaying.bind(this));
+
+ this.setup();
+}
+
+// Restart the game
+GameManager.prototype.restart = function () {
+ this.storageManager.clearGameState();
+ this.actuator.continueGame(); // Clear the game won/lost message
+ this.setup();
+};
+
+// Keep playing after winning (allows going over 2048)
+GameManager.prototype.keepPlaying = function () {
+ this.keepPlaying = true;
+ this.actuator.continueGame(); // Clear the game won/lost message
+};
+
+// Return true if the game is lost, or has won and the user hasn't kept playing
+GameManager.prototype.isGameTerminated = function () {
+ return this.over || (this.won && !this.keepPlaying);
+};
+
+// Set up the game
+GameManager.prototype.setup = function () {
+ var previousState = this.storageManager.getGameState();
+
+ // Reload the game from a previous game if present
+ if (previousState) {
+ this.grid = new Grid(previousState.grid.size,
+ previousState.grid.cells); // Reload grid
+ this.score = previousState.score;
+ this.over = previousState.over;
+ this.won = previousState.won;
+ this.keepPlaying = previousState.keepPlaying;
+ } else {
+ this.grid = new Grid(this.size);
+ this.score = 0;
+ this.over = false;
+ this.won = false;
+ this.keepPlaying = false;
+
+ // Add the initial tiles
+ this.addStartTiles();
+ }
+
+ // Update the actuator
+ this.actuate();
+};
+
+// Set up the initial tiles to start the game with
+GameManager.prototype.addStartTiles = function () {
+ for (var i = 0; i < this.startTiles; i++) {
+ this.addRandomTile();
+ }
+};
+
+// Adds a tile in a random position
+GameManager.prototype.addRandomTile = function () {
+ if (this.grid.cellsAvailable()) {
+ var value = Math.random() < 0.9 ? 2 : 4;
+ var tile = new Tile(this.grid.randomAvailableCell(), value);
+
+ this.grid.insertTile(tile);
+ }
+};
+
+// Sends the updated grid to the actuator
+GameManager.prototype.actuate = function () {
+ if (this.storageManager.getBestScore() < this.score) {
+ this.storageManager.setBestScore(this.score);
+ }
+
+ // Clear the state when the game is over (game over only, not win)
+ if (this.over) {
+ this.storageManager.clearGameState();
+ } else {
+ this.storageManager.setGameState(this.serialize());
+ }
+
+ this.actuator.actuate(this.grid, {
+ score: this.score,
+ over: this.over,
+ won: this.won,
+ bestScore: this.storageManager.getBestScore(),
+ terminated: this.isGameTerminated()
+ });
+
+};
+
+// Represent the current game as an object
+GameManager.prototype.serialize = function () {
+ return {
+ grid: this.grid.serialize(),
+ score: this.score,
+ over: this.over,
+ won: this.won,
+ keepPlaying: this.keepPlaying
+ };
+};
+
+// Save all tile positions and remove merger info
+GameManager.prototype.prepareTiles = function () {
+ this.grid.eachCell(function (x, y, tile) {
+ if (tile) {
+ tile.mergedFrom = null;
+ tile.savePosition();
+ }
+ });
+};
+
+// Move a tile and its representation
+GameManager.prototype.moveTile = function (tile, cell) {
+ this.grid.cells[tile.x][tile.y] = null;
+ this.grid.cells[cell.x][cell.y] = tile;
+ tile.updatePosition(cell);
+};
+
+// Move tiles on the grid in the specified direction
+GameManager.prototype.move = function (direction) {
+ // 0: up, 1: right, 2: down, 3: left
+ var self = this;
+
+ if (this.isGameTerminated()) return; // Don't do anything if the game's over
+
+ var cell, tile;
+
+ var vector = this.getVector(direction);
+ var traversals = this.buildTraversals(vector);
+ var moved = false;
+
+ // Save the current tile positions and remove merger information
+ this.prepareTiles();
+
+ // Traverse the grid in the right direction and move tiles
+ traversals.x.forEach(function (x) {
+ traversals.y.forEach(function (y) {
+ cell = { x: x, y: y };
+ tile = self.grid.cellContent(cell);
+
+ if (tile) {
+ var positions = self.findFarthestPosition(cell, vector);
+ var next = self.grid.cellContent(positions.next);
+
+ // Only one merger per row traversal?
+ if (next && next.value === tile.value && !next.mergedFrom) {
+ var merged = new Tile(positions.next, tile.value * 2);
+ merged.mergedFrom = [tile, next];
+
+ self.grid.insertTile(merged);
+ self.grid.removeTile(tile);
+
+ // Converge the two tiles' positions
+ tile.updatePosition(positions.next);
+
+ // Update the score
+ self.score += merged.value;
+
+ // The mighty 2048 tile
+ if (merged.value === 2048) self.won = true;
+ } else {
+ self.moveTile(tile, positions.farthest);
+ }
+
+ if (!self.positionsEqual(cell, tile)) {
+ moved = true; // The tile moved from its original cell!
+ }
+ }
+ });
+ });
+
+ if (moved) {
+ this.addRandomTile();
+
+ if (!this.movesAvailable()) {
+ this.over = true; // Game over!
+ }
+
+ this.actuate();
+ }
+};
+
+// Get the vector representing the chosen direction
+GameManager.prototype.getVector = function (direction) {
+ // Vectors representing tile movement
+ var map = {
+ 0: { x: 0, y: -1 }, // Up
+ 1: { x: 1, y: 0 }, // Right
+ 2: { x: 0, y: 1 }, // Down
+ 3: { x: -1, y: 0 } // Left
+ };
+
+ return map[direction];
+};
+
+// Build a list of positions to traverse in the right order
+GameManager.prototype.buildTraversals = function (vector) {
+ var traversals = { x: [], y: [] };
+
+ for (var pos = 0; pos < this.size; pos++) {
+ traversals.x.push(pos);
+ traversals.y.push(pos);
+ }
+
+ // Always traverse from the farthest cell in the chosen direction
+ if (vector.x === 1) traversals.x = traversals.x.reverse();
+ if (vector.y === 1) traversals.y = traversals.y.reverse();
+
+ return traversals;
+};
+
+GameManager.prototype.findFarthestPosition = function (cell, vector) {
+ var previous;
+
+ // Progress towards the vector direction until an obstacle is found
+ do {
+ previous = cell;
+ cell = { x: previous.x + vector.x, y: previous.y + vector.y };
+ } while (this.grid.withinBounds(cell) &&
+ this.grid.cellAvailable(cell));
+
+ return {
+ farthest: previous,
+ next: cell // Used to check if a merge is required
+ };
+};
+
+GameManager.prototype.movesAvailable = function () {
+ return this.grid.cellsAvailable() || this.tileMatchesAvailable();
+};
+
+// Check for available matches between tiles (more expensive check)
+GameManager.prototype.tileMatchesAvailable = function () {
+ var self = this;
+
+ var tile;
+
+ for (var x = 0; x < this.size; x++) {
+ for (var y = 0; y < this.size; y++) {
+ tile = this.grid.cellContent({ x: x, y: y });
+
+ if (tile) {
+ for (var direction = 0; direction < 4; direction++) {
+ var vector = self.getVector(direction);
+ var cell = { x: x + vector.x, y: y + vector.y };
+
+ var other = self.grid.cellContent(cell);
+
+ if (other && other.value === tile.value) {
+ return true; // These two tiles can be merged
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+};
+
+GameManager.prototype.positionsEqual = function (first, second) {
+ return first.x === second.x && first.y === second.y;
+};
diff --git a/js/grid.js b/js/grid.js
new file mode 100644
index 0000000..29f0821
--- /dev/null
+++ b/js/grid.js
@@ -0,0 +1,117 @@
+function Grid(size, previousState) {
+ this.size = size;
+ this.cells = previousState ? this.fromState(previousState) : this.empty();
+}
+
+// Build a grid of the specified size
+Grid.prototype.empty = function () {
+ var cells = [];
+
+ for (var x = 0; x < this.size; x++) {
+ var row = cells[x] = [];
+
+ for (var y = 0; y < this.size; y++) {
+ row.push(null);
+ }
+ }
+
+ return cells;
+};
+
+Grid.prototype.fromState = function (state) {
+ var cells = [];
+
+ for (var x = 0; x < this.size; x++) {
+ var row = cells[x] = [];
+
+ for (var y = 0; y < this.size; y++) {
+ var tile = state[x][y];
+ row.push(tile ? new Tile(tile.position, tile.value) : null);
+ }
+ }
+
+ return cells;
+};
+
+// Find the first available random position
+Grid.prototype.randomAvailableCell = function () {
+ var cells = this.availableCells();
+
+ if (cells.length) {
+ return cells[Math.floor(Math.random() * cells.length)];
+ }
+};
+
+Grid.prototype.availableCells = function () {
+ var cells = [];
+
+ this.eachCell(function (x, y, tile) {
+ if (!tile) {
+ cells.push({ x: x, y: y });
+ }
+ });
+
+ return cells;
+};
+
+// Call callback for every cell
+Grid.prototype.eachCell = function (callback) {
+ for (var x = 0; x < this.size; x++) {
+ for (var y = 0; y < this.size; y++) {
+ callback(x, y, this.cells[x][y]);
+ }
+ }
+};
+
+// Check if there are any cells available
+Grid.prototype.cellsAvailable = function () {
+ return !!this.availableCells().length;
+};
+
+// Check if the specified cell is taken
+Grid.prototype.cellAvailable = function (cell) {
+ return !this.cellOccupied(cell);
+};
+
+Grid.prototype.cellOccupied = function (cell) {
+ return !!this.cellContent(cell);
+};
+
+Grid.prototype.cellContent = function (cell) {
+ if (this.withinBounds(cell)) {
+ return this.cells[cell.x][cell.y];
+ } else {
+ return null;
+ }
+};
+
+// Inserts a tile at its position
+Grid.prototype.insertTile = function (tile) {
+ this.cells[tile.x][tile.y] = tile;
+};
+
+Grid.prototype.removeTile = function (tile) {
+ this.cells[tile.x][tile.y] = null;
+};
+
+Grid.prototype.withinBounds = function (position) {
+ return position.x >= 0 && position.x < this.size &&
+ position.y >= 0 && position.y < this.size;
+};
+
+Grid.prototype.serialize = function () {
+ var cellState = [];
+
+ for (var x = 0; x < this.size; x++) {
+ var row = cellState[x] = [];
+
+ for (var y = 0; y < this.size; y++) {
+ row.push(this.cells[x][y] ? this.cells[x][y].serialize() : null);
+ }
+ }
+
+ return {
+ size: this.size,
+ cells: cellState
+ };
+};
diff --git a/js/html_actuator.js b/js/html_actuator.js
new file mode 100644
index 0000000..6b31f2d
--- /dev/null
+++ b/js/html_actuator.js
@@ -0,0 +1,139 @@
+function HTMLActuator() {
+ this.tileContainer = document.querySelector(".tile-container");
+ this.scoreContainer = document.querySelector(".score-container");
+ this.bestContainer = document.querySelector(".best-container");
+ this.messageContainer = document.querySelector(".game-message");
+
+ this.score = 0;
+}
+
+HTMLActuator.prototype.actuate = function (grid, metadata) {
+ var self = this;
+
+ window.requestAnimationFrame(function () {
+ self.clearContainer(self.tileContainer);
+
+ grid.cells.forEach(function (column) {
+ column.forEach(function (cell) {
+ if (cell) {
+ self.addTile(cell);
+ }
+ });
+ });
+
+ self.updateScore(metadata.score);
+ self.updateBestScore(metadata.bestScore);
+
+ if (metadata.terminated) {
+ if (metadata.over) {
+ self.message(false); // You lose
+ } else if (metadata.won) {
+ self.message(true); // You win!
+ }
+ }
+
+ });
+};
+
+// Continues the game (both restart and keep playing)
+HTMLActuator.prototype.continueGame = function () {
+ this.clearMessage();
+};
+
+HTMLActuator.prototype.clearContainer = function (container) {
+ while (container.firstChild) {
+ container.removeChild(container.firstChild);
+ }
+};
+
+HTMLActuator.prototype.addTile = function (tile) {
+ var self = this;
+
+ var wrapper = document.createElement("div");
+ var inner = document.createElement("div");
+ var position = tile.previousPosition || { x: tile.x, y: tile.y };
+ var positionClass = this.positionClass(position);
+
+ // We can't use classlist because it somehow glitches when replacing classes
+ var classes = ["tile", "tile-" + tile.value, positionClass];
+
+ if (tile.value > 2048) classes.push("tile-super");
+
+ this.applyClasses(wrapper, classes);
+
+ inner.classList.add("tile-inner");
+ inner.textContent = tile.value;
+
+ if (tile.previousPosition) {
+ // Make sure that the tile gets rendered in the previous position first
+ window.requestAnimationFrame(function () {
+ classes[2] = self.positionClass({ x: tile.x, y: tile.y });
+ self.applyClasses(wrapper, classes); // Update the position
+ });
+ } else if (tile.mergedFrom) {
+ classes.push("tile-merged");
+ this.applyClasses(wrapper, classes);
+
+ // Render the tiles that merged
+ tile.mergedFrom.forEach(function (merged) {
+ self.addTile(merged);
+ });
+ } else {
+ classes.push("tile-new");
+ this.applyClasses(wrapper, classes);
+ }
+
+ // Add the inner part of the tile to the wrapper
+ wrapper.appendChild(inner);
+
+ // Put the tile on the board
+ this.tileContainer.appendChild(wrapper);
+};
+
+HTMLActuator.prototype.applyClasses = function (element, classes) {
+ element.setAttribute("class", classes.join(" "));
+};
+
+HTMLActuator.prototype.normalizePosition = function (position) {
+ return { x: position.x + 1, y: position.y + 1 };
+};
+
+HTMLActuator.prototype.positionClass = function (position) {
+ position = this.normalizePosition(position);
+ return "tile-position-" + position.x + "-" + position.y;
+};
+
+HTMLActuator.prototype.updateScore = function (score) {
+ this.clearContainer(this.scoreContainer);
+
+ var difference = score - this.score;
+ this.score = score;
+
+ this.scoreContainer.textContent = this.score;
+
+ if (difference > 0) {
+ var addition = document.createElement("div");
+ addition.classList.add("score-addition");
+ addition.textContent = "+" + difference;
+
+ this.scoreContainer.appendChild(addition);
+ }
+};
+
+HTMLActuator.prototype.updateBestScore = function (bestScore) {
+ this.bestContainer.textContent = bestScore;
+};
+
+HTMLActuator.prototype.message = function (won) {
+ var type = won ? "game-won" : "game-over";
+ var message = won ? "You win!" : "Game over!";
+
+ this.messageContainer.classList.add(type);
+ this.messageContainer.getElementsByTagName("p")[0].textContent = message;
+};
+
+HTMLActuator.prototype.clearMessage = function () {
+ // IE only takes one value to remove at a time.
+ this.messageContainer.classList.remove("game-won");
+ this.messageContainer.classList.remove("game-over");
+};
diff --git a/js/keyboard_input_manager.js b/js/keyboard_input_manager.js
new file mode 100644
index 0000000..ca01b3c
--- /dev/null
+++ b/js/keyboard_input_manager.js
@@ -0,0 +1,144 @@
+function KeyboardInputManager() {
+ this.events = {};
+
+ if (window.navigator.msPointerEnabled) {
+ //Internet Explorer 10 style
+ this.eventTouchstart = "MSPointerDown";
+ this.eventTouchmove = "MSPointerMove";
+ this.eventTouchend = "MSPointerUp";
+ } else {
+ this.eventTouchstart = "touchstart";
+ this.eventTouchmove = "touchmove";
+ this.eventTouchend = "touchend";
+ }
+
+ this.listen();
+}
+
+KeyboardInputManager.prototype.on = function (event, callback) {
+ if (!this.events[event]) {
+ this.events[event] = [];
+ }
+ this.events[event].push(callback);
+};
+
+KeyboardInputManager.prototype.emit = function (event, data) {
+ var callbacks = this.events[event];
+ if (callbacks) {
+ callbacks.forEach(function (callback) {
+ callback(data);
+ });
+ }
+};
+
+KeyboardInputManager.prototype.listen = function () {
+ var self = this;
+
+ var map = {
+ 38: 0, // Up
+ 39: 1, // Right
+ 40: 2, // Down
+ 37: 3, // Left
+ 75: 0, // Vim up
+ 76: 1, // Vim right
+ 74: 2, // Vim down
+ 72: 3, // Vim left
+ 87: 0, // W
+ 68: 1, // D
+ 83: 2, // S
+ 65: 3 // A
+ };
+
+ // Respond to direction keys
+ document.addEventListener("keydown", function (event) {
+ var modifiers = event.altKey || event.ctrlKey || event.metaKey ||
+ event.shiftKey;
+ var mapped = map[event.which];
+
+ if (!modifiers) {
+ if (mapped !== undefined) {
+ event.preventDefault();
+ self.emit("move", mapped);
+ }
+ }
+
+ // R key restarts the game
+ if (!modifiers && event.which === 82) {
+ self.restart.call(self, event);
+ }
+ });
+
+ // Respond to button presses
+ this.bindButtonPress(".retry-button", this.restart);
+ this.bindButtonPress(".restart-button", this.restart);
+ this.bindButtonPress(".keep-playing-button", this.keepPlaying);
+
+ // Respond to swipe events
+ var touchStartClientX, touchStartClientY;
+ var gameContainer = document.getElementsByClassName("game-container")[0];
+
+ gameContainer.addEventListener(this.eventTouchstart, function (event) {
+ if ((!window.navigator.msPointerEnabled && event.touches.length > 1) ||
+ event.targetTouches.length > 1) {
+ return; // Ignore if touching with more than 1 finger
+ }
+
+ if (window.navigator.msPointerEnabled) {
+ touchStartClientX = event.pageX;
+ touchStartClientY = event.pageY;
+ } else {
+ touchStartClientX = event.touches[0].clientX;
+ touchStartClientY = event.touches[0].clientY;
+ }
+
+ event.preventDefault();
+ });
+
+ gameContainer.addEventListener(this.eventTouchmove, function (event) {
+ event.preventDefault();
+ });
+
+ gameContainer.addEventListener(this.eventTouchend, function (event) {
+ if ((!window.navigator.msPointerEnabled && event.touches.length > 0) ||
+ event.targetTouches.length > 0) {
+ return; // Ignore if still touching with one or more fingers
+ }
+
+ var touchEndClientX, touchEndClientY;
+
+ if (window.navigator.msPointerEnabled) {
+ touchEndClientX = event.pageX;
+ touchEndClientY = event.pageY;
+ } else {
+ touchEndClientX = event.changedTouches[0].clientX;
+ touchEndClientY = event.changedTouches[0].clientY;
+ }
+
+ var dx = touchEndClientX - touchStartClientX;
+ var absDx = Math.abs(dx);
+
+ var dy = touchEndClientY - touchStartClientY;
+ var absDy = Math.abs(dy);
+
+ if (Math.max(absDx, absDy) > 10) {
+ // (right : left) : (down : up)
+ self.emit("move", absDx > absDy ? (dx > 0 ? 1 : 3) : (dy > 0 ? 2 : 0));
+ }
+ });
+};
+
+KeyboardInputManager.prototype.restart = function (event) {
+ event.preventDefault();
+ this.emit("restart");
+};
+
+KeyboardInputManager.prototype.keepPlaying = function (event) {
+ event.preventDefault();
+ this.emit("keepPlaying");
+};
+
+KeyboardInputManager.prototype.bindButtonPress = function (selector, fn) {
+ var button = document.querySelector(selector);
+ button.addEventListener("click", fn.bind(this));
+ button.addEventListener(this.eventTouchend, fn.bind(this));
+};
diff --git a/js/local_storage_manager.js b/js/local_storage_manager.js
new file mode 100644
index 0000000..2ca9cc3
--- /dev/null
+++ b/js/local_storage_manager.js
@@ -0,0 +1,63 @@
+window.fakeStorage = {
+ _data: {},
+
+ setItem: function (id, val) {
+ return this._data[id] = String(val);
+ },
+
+ getItem: function (id) {
+ return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
+ },
+
+ removeItem: function (id) {
+ return delete this._data[id];
+ },
+
+ clear: function () {
+ return this._data = {};
+ }
+};
+
+function LocalStorageManager() {
+ this.bestScoreKey = "bestScore";
+ this.gameStateKey = "gameState";
+
+ var supported = this.localStorageSupported();
+ this.storage = supported ? window.localStorage : window.fakeStorage;
+}
+
+LocalStorageManager.prototype.localStorageSupported = function () {
+ var testKey = "test";
+
+ try {
+ var storage = window.localStorage;
+ storage.setItem(testKey, "1");
+ storage.removeItem(testKey);
+ return true;
+ } catch (error) {
+ return false;
+ }
+};
+
+// Best score getters/setters
+LocalStorageManager.prototype.getBestScore = function () {
+ return this.storage.getItem(this.bestScoreKey) || 0;
+};
+
+LocalStorageManager.prototype.setBestScore = function (score) {
+ this.storage.setItem(this.bestScoreKey, score);
+};
+
+// Game state getters/setters and clearing
+LocalStorageManager.prototype.getGameState = function () {
+ var stateJSON = this.storage.getItem(this.gameStateKey);
+ return stateJSON ? JSON.parse(stateJSON) : null;
+};
+
+LocalStorageManager.prototype.setGameState = function (gameState) {
+ this.storage.setItem(this.gameStateKey, JSON.stringify(gameState));
+};
+
+LocalStorageManager.prototype.clearGameState = function () {
+ this.storage.removeItem(this.gameStateKey);
+};
diff --git a/js/tile.js b/js/tile.js
new file mode 100644
index 0000000..92a670a
--- /dev/null
+++ b/js/tile.js
@@ -0,0 +1,27 @@
+function Tile(position, value) {
+ this.x = position.x;
+ this.y = position.y;
+ this.value = value || 2;
+
+ this.previousPosition = null;
+ this.mergedFrom = null; // Tracks tiles that merged together
+}
+
+Tile.prototype.savePosition = function () {
+ this.previousPosition = { x: this.x, y: this.y };
+};
+
+Tile.prototype.updatePosition = function (position) {
+ this.x = position.x;
+ this.y = position.y;
+};
+
+Tile.prototype.serialize = function () {
+ return {
+ position: {
+ x: this.x,
+ y: this.y
+ },
+ value: this.value
+ };
+};
diff --git a/meta/apple-touch-icon.png b/meta/apple-touch-icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3fd20f6092338ef464e440ec84a34c8850fd5d33
GIT binary patch
literal 5808
zcmaJ^bx<76l3v_pad&qM2?+#UBxtZ;3k$&s?kpA@f)m_=1zR-9!lJP9|mm09V3J
zUS3Pf*4e|^-PYNKNkv|s$;Hjt+U|oD0HEBLo93;nJ3|pU((3J3FeHSk9kJB>6EF@<
zF$I}tP(!%T2t~!}m-KHGRb0%JgA`TReW+d5QS=$7xDC3y9F1+JgvBc|6cT-Uv
zS#>8R!SJ9@6Ih)5lO=n#VOipWj@kv_;LZGPGXWmgp2%#W15g~_8H%j^83%#jVn5*D
z#l%EK?klt&JXL%dsIpCQb*}pQX~6U@5faLCqI=EA_JW!=8@AU+38$lAiN9**F~I`W
zw7mT6>c2{DibW0SnpX28uNko(JQ*-$b9@N%yGTJ{(O+W+REd9N_if=e+DX1lzsk?L
zChB@9?mbV8=eBDhra<3So|I4SkH^pNZ8}QU
z*h8~VB!=0!!iGssMJcbkM@YV)peUpABx3c;(C+}`A(*gWeiwA7pS0JZ#KbuIXcWrm
z<-tVtG7PimxU#~tIG4fpT39r)qP7@)vYan4hC@|XXc|$RLXi+MwO|_vMGGb#F}gXk
zh{DGWW^!fH@yJ0YOiLn!Y?~G_8BUKJ4lxmlobRZ085K`xMS))#^)16ooZQH2nb1+N
zEq+!+VB}HDAxYD89
z#KFWsn!*?=7W{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