Android Open Source - blocks-game Generic Grid






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.grids;
// w  w w  . j  a v a2 s .  c  o m
/**
 * @author Kotuc
 */
public class GenericGrid<T> {

    private final LinearGrid lingrid;
    private final T[] tiles;

    public GenericGrid(LinearGrid lingrid) {
        this.lingrid = lingrid;
        tiles = (T[]) new Object[lingrid.getTotalNum()];
    }

    public T get(int index) {
        return tiles[index];
    }

    public T get(int x, int y) {
        if (lingrid.isOutOfBounds(x, y)) {
            return null;
        }
        return tiles[lingrid.index(x, y)];
    }

    public void set(int index, T obj) {
        tiles[index] = obj;
    }

    public void set(int x, int y, T obj) {
        tiles[lingrid.index(x, y)] = obj;
    }

    public T get(Pos pos) {

        return get(pos.x, pos.y);
    }

    public void set(Pos p, T obj) {
        set(p.x, p.y, obj);
    }

    public LinearGrid getLinGrid() {
        return lingrid;
    }

    public T[] getTiles() {
        return tiles;
    }
}




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