Konflikte behoben

master
Jonathan Hager 6 years ago
commit 5563a02a96

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@ -0,0 +1,86 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dungeoncrawler.view;
import com.badlogic.gdx.Gdx;
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;
/**
*
* @author jonathan
*/
public class Map {
private TiledMap map;
private Texture tiles;
public Map(){
map = new TiledMap();
tiles = new Texture(Gdx.files.internal("tiles.gif"));
generateMap();
}
private void generateMap(){
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;
}
}
Loading…
Cancel
Save