《2048》是比較流行的一款數字游戲。原版2048首先在github上發布,原作者是Gabriele Cirulli。它是基於《1024》和《小3傳奇》的玩法開發而成的新型數字游戲[1] 。
隨后2048便出現各種版本,走各大平台。由Ketchapp公司移植到IOS的版本最為火熱,現在約有1000萬下載,其名字跟原版一模一樣。衍生版中最出名的是《2048六邊形》版本,
先后在全球81個國家中的board game中排進了前200。
安卓版非常火爆的有《挑戰2048》,其2.0.0版以后還加入了雙人對戰。
其次比較特別的有2048中國朝代版。更有2048自定義版,可以自己定義文字和圖片。《2048》是IOS中流行的一款。
大家好、開始
地址:http://10086bank.com/2048/index.html
首先就上圖:
我的思路:
獲取客戶端的ip--》找到ip的所屬地--》獲取該地方的下級區縣、顯示到頁面。
代碼:
Js:
if (province == "北京") { return ["東城", "西城", "朝陽", "豐台", "懷柔", "海淀", "密雲", "房山", "通州", "昌平", "北京"]; }
Function.prototype.bind = Function.prototype.bind || function (target) { var self = this; return function (args) { if (!(args instanceof Array)) { args = [args]; } self.apply(target, args); }; }; (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); }); })();
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]; // Ignore the event if it's happening in a text field if (self.targetIsInput(event)) return; 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 > 1 || self.targetIsInput(event)) { return; // Ignore if touching with more than 1 finger or touching input } 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(); });
需要代碼的加我微信:502048227 可愛/玫瑰
沒時間寫了、要玩的可以看看:http://10086bank.com/2048/index.html 不玩的也歡迎! 【鍵盤上下左右鍵】 手機直接上下左右滑動!!!!!!!!!!!!!!!!
謝謝