• 还有多少人在玩2048现在都4096了


    《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  不玩的也欢迎!   【键盘上下左右键】 手机直接上下左右滑动!!!!!!!!!!!!!!!!

    谢谢

  • 相关阅读:
    最小生成树(prim算法)C语言实现
    图的十字链表存储(C语言)
    打算做一款给方便学生生活的APP,虽然已经有口袋小安了,但是并没有我想要的功能。。。
    腾讯云Ubuntu安装JDK和Tomcat
    新浪微博配图批量下载
    Algorithms in C第一章笔记
    Java笔记
    稍微记录一下effective c++的一些东西
    总结,并加油
    苹果Xcode帮助文档阅读指南
  • 原文地址:https://www.cnblogs.com/chinhi/p/play2048game.html
Copyright © 2020-2023  润新知