Android Open Source - 2048GameAndroid Position






From Project

Back to project page 2048GameAndroid.

License

The source code is released under:

Apache License

If you think the Android project 2048GameAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package zhengxiao.myapplication.game;
// w ww.j a  v a2  s.  c o m
import java.text.MessageFormat;

/**
 * Created by zhengxiao on 12/15/14.
 */
public class Position {
    public int x;
    public int y;

    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Position(Position that){
        this.x = that.x;
        this.y = that.y;
    }

    public void move(Direction direction) {
        switch (direction) {
            case UP:
                y -= 1;
            case DOWN:
                y += 1;
            case LEFT:
                x -=1;
            case RIGHT:
                x += 1;
        }
    }

    @Override
    public String toString() {
        return MessageFormat.format("({0},{1})",x,y);
    }

}




Java Source Code List

zhengxiao.myapplication.ApplicationTest.java
zhengxiao.myapplication.GameActivity.java
zhengxiao.myapplication.MainActivity.java
zhengxiao.myapplication.game.BoardTest.java
zhengxiao.myapplication.game.Board.java
zhengxiao.myapplication.game.Direction.java
zhengxiao.myapplication.game.GameTest.java
zhengxiao.myapplication.game.Game.java
zhengxiao.myapplication.game.Position.java
zhengxiao.myapplication.game.Utils.java
zhengxiao.myapplication.utils.OnGestureListenerAdapter.java