|
|
|
|
@ -11,6 +11,9 @@ import com.badlogic.gdx.graphics.Texture;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
|
|
|
import com.badlogic.gdx.maps.MapLayers;
|
|
|
|
|
import com.badlogic.gdx.maps.tiled.TiledMap;
|
|
|
|
|
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
|
|
|
|
|
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
|
|
|
|
|
import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@ -28,8 +31,56 @@ public class Map {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateMap(){
|
|
|
|
|
TextureRegion[][] splitTiles = TextureRegion.split(tiles, 48, 48);
|
|
|
|
|
MapLayers layers = map.getLayers();
|
|
|
|
|
TextureRegion[][] splitTiles = TextureRegion.split(getTiles(), 48, 48);
|
|
|
|
|
MapLayers layers = getMap().getLayers();
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<6;i++){
|
|
|
|
|
TiledMapTileLayer layer = new TiledMapTileLayer(6, 6, 48, 48);
|
|
|
|
|
|
|
|
|
|
for(int x=0;x<6;x++){
|
|
|
|
|
for(int y=0;y<6;y++){
|
|
|
|
|
|
|
|
|
|
int ty = (int)(Math.random() * splitTiles.length);
|
|
|
|
|
int tx = (int)(Math.random() * splitTiles[ty].length);
|
|
|
|
|
|
|
|
|
|
Cell cell = new Cell();
|
|
|
|
|
cell.setTile(new StaticTiledMapTile(splitTiles[ty][tx]));
|
|
|
|
|
layer.setCell(x, y, cell);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
layers.add(layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return the map
|
|
|
|
|
*/
|
|
|
|
|
public TiledMap getMap() {
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param map the map to set
|
|
|
|
|
*/
|
|
|
|
|
public void setMap(TiledMap map) {
|
|
|
|
|
this.map = map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return the tiles
|
|
|
|
|
*/
|
|
|
|
|
public Texture getTiles() {
|
|
|
|
|
return tiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param tiles the tiles to set
|
|
|
|
|
*/
|
|
|
|
|
public void setTiles(Texture tiles) {
|
|
|
|
|
this.tiles = tiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|