diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e30f41d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Jonathan Hager + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/core/assets/tiles.gif b/core/assets/tiles.gif new file mode 100644 index 0000000..94870e6 Binary files /dev/null and b/core/assets/tiles.gif differ diff --git a/core/src/com/dungeoncrawler/view/Map.java b/core/src/com/dungeoncrawler/view/Map.java new file mode 100644 index 0000000..7d2ad04 --- /dev/null +++ b/core/src/com/dungeoncrawler/view/Map.java @@ -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; + } + + + +}