Giter Club home page Giter Club logo

game2048's Introduction

Game2048


大学期间这个游戏每个人都应该玩过一段时间,简单但是好玩 《Android群英传》一书最后就是这个例子,看了下源码简单做个总结


作者源码: https://github.com/xuyisheng/AndroidHeroes/tree/master/13.%E5%AE%9E%E4%BE%8B%E6%8F%90%E9%AB%98/Game2048

基本流程

第一步: 每次开始刷新出来2个随机位置的数字,2或者4

第二步: 玩家可以上下左右滑动,玩家滑动后需要做处理

2.1判断上下左右那个方向做相应的处理,下面会举一个向右滑动的情况来介绍,因为不同方向的滑动算法不一样

2.2每次滑动后要增加一个新的数字

2.3判断游戏是否结束(达到目标或者失败),还是继续

如果左右滑动就一行一行进行处理,上下滑动就一列一列处理 向那边滑动从那边开始遍历

game2048's People

Contributors

liloqian avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.