Search in sources :

Example 16 with TiledMapTile

use of com.badlogic.gdx.maps.tiled.TiledMapTile in project high-flyer by sangngh.

the class LandingDetectorTest method testDetect_noLanding.

@Test
public void testDetect_noLanding() {
    GameState state = new GameState();
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    Mockito.when(mockScreenManager.getScreen(Mockito.anyInt())).thenReturn(Mockito.mock(Screen.class));
    List<Cell> nextCells = new ArrayList<>();
    Cell landingCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("notlanding", true);
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    landingCell.setTile(mockTile);
    nextCells.add(landingCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    assertEquals("Mismatching game level", 1, game.getState().getLvl());
    Mockito.verifyZeroInteractions(mockSoundPlayer);
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Screen(com.badlogic.gdx.Screen) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 17 with TiledMapTile

use of com.badlogic.gdx.maps.tiled.TiledMapTile in project high-flyer by sangngh.

the class LandingDetectorTest method testDetect_hasLanding.

@Test
public void testDetect_hasLanding() {
    GameState state = new GameState();
    // state.setScore(110);
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    Mockito.when(mockScreenManager.getScreen(Mockito.anyInt())).thenReturn(Mockito.mock(Screen.class));
    List<Cell> nextCells = new ArrayList<>();
    Cell landingCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("landing", true);
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    landingCell.setTile(mockTile);
    nextCells.add(landingCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    assertEquals("Mismatching game level", 2, game.getState().getLvl());
    Mockito.verify(mockPlayer).setX(Mockito.eq(0f));
    Mockito.verify(mockPlayer).setY(Mockito.eq(260f));
    Mockito.verify(mockSoundPlayer).playSound(Mockito.eq("data/sounds/Finish.wav"));
// assertEquals("Mismatching game score", 10, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Screen(com.badlogic.gdx.Screen) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 18 with TiledMapTile

use of com.badlogic.gdx.maps.tiled.TiledMapTile in project high-flyer by sangngh.

the class PowerUpDetectorTest method testDetect_noCollistion.

@Test
public void testDetect_noCollistion() {
    GameState state = new GameState();
    state.setScore(100);
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    List<Cell> nextCells = new ArrayList<>();
    Cell collisionCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("notpower", "star");
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    collisionCell.setTile(mockTile);
    nextCells.add(collisionCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    Mockito.verifyZeroInteractions(mockSoundPlayer);
    assertEquals("Mismatching game score", 100, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 19 with TiledMapTile

use of com.badlogic.gdx.maps.tiled.TiledMapTile in project ultimate-java by pantinor.

the class UltimaTiledMapLoader method load.

public TiledMap load() {
    TiledMap map = new TiledMap();
    MapProperties mapProperties = map.getProperties();
    mapProperties.put("name", gameMap.toString());
    mapProperties.put("id", gameMap.getId());
    mapProperties.put("orientation", "orthogonal");
    mapProperties.put("width", mapWidth);
    mapProperties.put("height", mapHeight);
    mapProperties.put("tilewidth", tileWidth);
    mapProperties.put("tileheight", tileHeight);
    mapProperties.put("backgroundcolor", "#000000");
    TiledMapTileLayer layer = new TiledMapTileLayer(mapWidth, mapHeight, tileWidth, tileHeight);
    layer.setName("Map Layer");
    layer.setVisible(true);
    for (int y = 0; y < mapHeight; y++) {
        for (int x = 0; x < mapWidth; x++) {
            Tile ct = gameMap.getMap().getTile(x, y);
            Cell cell = new Cell();
            Array<TextureAtlas.AtlasRegion> tileRegions = atlas.findRegions(ct.getName());
            Array<StaticTiledMapTile> ar = new Array<>();
            for (TextureAtlas.AtlasRegion r : tileRegions) {
                ar.add(new StaticTiledMapTile(r));
            }
            if (ar.size == 0) {
                System.out.println(ct.getName());
            }
            TiledMapTile tmt = null;
            if (tileRegions.size > 1) {
                tmt = new AnimatedTiledMapTile(.7f, ar);
            } else {
                tmt = ar.first();
            }
            tmt.setId(y * mapWidth + x);
            cell.setTile(tmt);
            layer.setCell(x, mapHeight - 1 - y, cell);
        }
    }
    map.getLayers().add(layer);
    if (gameMap.getMap().getType() == MapType.combat) {
        try {
            loadCombatPositions(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return map;
}
Also used : AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) MapProperties(com.badlogic.gdx.maps.MapProperties) AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) Tile(objects.Tile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Array(com.badlogic.gdx.utils.Array) TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)

Example 20 with TiledMapTile

use of com.badlogic.gdx.maps.tiled.TiledMapTile in project ultimate-java by pantinor.

the class GameScreen method replaceTile.

public void replaceTile(String name, int x, int y) {
    if (name == null) {
        return;
    }
    TextureRegion texture = Ultima4.standardAtlas.findRegion(name);
    TiledMapTileLayer layer = (TiledMapTileLayer) context.getCurrentTiledMap().getLayers().get("Map Layer");
    Cell cell = layer.getCell(x, context.getCurrentMap().getWidth() - 1 - y);
    TiledMapTile tmt = new StaticTiledMapTile(texture);
    tmt.setId(y * context.getCurrentMap().getWidth() + x);
    cell.setTile(tmt);
    context.getCurrentMap().setTile(Ultima4.baseTileSet.getTileByName(name), x, y);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)

Aggregations

TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)21 Cell (com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)17 TiledMapTileLayer (com.badlogic.gdx.maps.tiled.TiledMapTileLayer)12 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 MapProperties (com.badlogic.gdx.maps.MapProperties)10 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)7 GameEngine (com.relic.highflyer.GameEngine)7 GameSettings (com.relic.highflyer.GameSettings)7 GameState (com.relic.highflyer.GameState)7 ScreenManager (com.relic.highflyer.screens.ScreenManager)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Color (com.badlogic.gdx.graphics.Color)4 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)4 AnimatedTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile)4 Screen (com.badlogic.gdx.Screen)3 Tile (objects.Tile)3 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)2 Texture (com.badlogic.gdx.graphics.Texture)2 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2