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);
}
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());
}
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());
}
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;
}
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);
}
Aggregations