I am making a top down style game using LibGdx that I want to be randomly generated each new game load.
I already have the algorithm to generate the array for what tile should be what.
But i'm stuck on how I should handle the tile classes.
I have this class called Tile
import com.badlogic.gdx.graphics.g2d.Sprite;
public class Tile extends Sprite{ // Should I use sprite??? Seems wrong..
public byte id;
public static Tile[] tiles = new Tile[256];
public static Tile grass = new GrassTile(0);
public Tile(int id) {
this.id = (byte) id;
if (tiles[id] != null)
throw new RuntimeException("Tile Already Exists....");
tiles[id] = this;
}
}
And I want to have multiple classes that exened this class for each tile. For example this is grass.
import com.badlogic.gdx.graphics.g2d.Sprite;
public class Tile extends Sprite{
public byte id;
public static Tile[] tiles = new Tile[256];
public static Tile grass = new GrassTile(0);
public Tile(int id) {
this.id = (byte) id;
if (tiles[id] != null)
throw new RuntimeException("Tile Already Exists....");
tiles[id] = this;
}
}
Should these classes be extended off of a sprite? Or some other class from libgdx?
Also These tiles are going to be 16 x 16 that are made up of 4 smaller 8x8 sprites.