Android Open Source - blocks-game Axial






From Project

Back to project page blocks-game.

License

The source code is released under:

Apache License

If you think the Android project blocks-game 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 cz.kotu.game.blocks.hex;
/*w  w w . j  a v  a2  s.  c om*/
/**
 * @author Kotuc
 */
public class Axial {
    public int q; // == x
    public int r; // == y
    // x + y + z = 0

    public Axial() {
    }

    public Axial(int q, int r) {
        setAxial(q, r);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Axial other = (Axial) obj;
        if (this.q != other.q) {
            return false;
        }
        if (this.r != other.r) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 59 * hash + this.q;
        hash = 59 * hash + this.r;
        return hash;
    }


    @Override
    public String toString() {
        return "Axial(" + q + "," + r + ")";
    }

    public Axial setAxial(Axial axial) {
        return setAxial(axial.q, axial.r);
    }

    public Axial setAxial(int q, int r) {
        this.q = q;
        this.r = r;
        return this;
    }

    public Axial setCube(int x, int y, int z) {
        this.q = x;
        this.r = z;
        return this;
    }

    public Axial add(Axial dir) {
        this.q += dir.q;
        this.r += dir.r;
        return this;
    }

    int x() {
        return q;
    }

    int y() {
        return r;
    }

    int z() {
        return -q - r;
    }

    public int distance(Axial other) {
        return (Math.abs(this.x() - other.x()) + Math.abs(this.y() - other.y()) + Math.abs(this.z() - other.z())) / 2;
    }

}




Java Source Code List

com.badlogic.gradletest.DesktopLauncher.java
com.badlogicgames.gradletest.MainActivity.java
cz.kotu.game.blocks.BaseStage.java
cz.kotu.game.blocks.Block.java
cz.kotu.game.blocks.Draggable.java
cz.kotu.game.blocks.Follower.java
cz.kotu.game.blocks.GridStage.java
cz.kotu.game.blocks.GridUtils.java
cz.kotu.game.blocks.HelloApp.java
cz.kotu.game.blocks.MoveUtils.java
cz.kotu.game.blocks.Slider.java
cz.kotu.game.blocks.T.java
cz.kotu.game.blocks.hex.Axial.java
cz.kotu.game.blocks.hex.HexCoords3.java
cz.kotu.game.blocks.hex.HexGrid.java
cz.kotu.game.blocks.hex.HexGroup.java
cz.kotu.game.blocks.hex.HexPos.java
cz.kotu.game.blocks.hex.HexSet.java
cz.kotu.game.blocks.hex.HexStage.java
cz.kotu.game.blocks.hex.Hex.java
cz.kotu.grids.Dir.java
cz.kotu.grids.GenericGrid.java
cz.kotu.grids.LinPos.java
cz.kotu.grids.LinearGrid.java
cz.kotu.grids.Pos.java