Example usage for com.badlogic.gdx.maps.tiled.renderers OrthogonalTiledMapRenderer OrthogonalTiledMapRenderer

List of usage examples for com.badlogic.gdx.maps.tiled.renderers OrthogonalTiledMapRenderer OrthogonalTiledMapRenderer

Introduction

In this page you can find the example usage for com.badlogic.gdx.maps.tiled.renderers OrthogonalTiledMapRenderer OrthogonalTiledMapRenderer.

Prototype

public OrthogonalTiledMapRenderer(TiledMap map, float unitScale) 

Source Link

Usage

From source file:MyGdxGame.java

License:Apache License

@Override
public void create() {
    // load the koala frames, split them, and assign them to Animations
    koalaTexture = new Texture("koalio.png");
    TextureRegion[] regions = TextureRegion.split(koalaTexture, 18, 26)[0];
    stand = new Animation(0, regions[0]);
    jump = new Animation(0, regions[1]);
    walk = new Animation(0.15f, regions[2], regions[3], regions[4]);
    walk.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

    // figure out the width and height of the koala for collision
    // detection and rendering by converting a koala frames pixel
    // size into world units (1 unit == 16 pixels)
    Koala.WIDTH = 1 / 16f * regions[0].getRegionWidth();
    Koala.HEIGHT = 1 / 16f * regions[0].getRegionHeight();

    // load the map, set the unit scale to 1/16 (1 unit == 16 pixels)
    map = new TmxMapLoader().load("level1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f);

    // create an orthographic camera, shows us 30x20 units of the world
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 30, 20);/*from w w  w.j av a 2s  .c  o  m*/
    camera.update();

    // create the Koala we want to move around the world
    koala = new Koala();
    koala.position.set(20, 20);
}

From source file:com.badlogic.gdx.tests.superkoalio.SuperKoalio.java

License:Apache License

@Override
public void create() {
    // load the koala frames, split them, and assign them to Animations
    koalaTexture = new Texture("data/maps/tiled/super-koalio/koalio.png");
    TextureRegion[] regions = TextureRegion.split(koalaTexture, 18, 26)[0];
    stand = new Animation(0, regions[0]);
    jump = new Animation(0, regions[1]);
    walk = new Animation(0.15f, regions[2], regions[3], regions[4]);
    walk.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

    // figure out the width and height of the koala for collision
    // detection and rendering by converting a koala frames pixel
    // size into world units (1 unit == 16 pixels)
    Koala.WIDTH = 1 / 16f * regions[0].getRegionWidth();
    Koala.HEIGHT = 1 / 16f * regions[0].getRegionHeight();

    // load the map, set the unit scale to 1/16 (1 unit == 16 pixels)
    map = new TmxMapLoader().load("data/maps/tiled/super-koalio/level1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f);

    // create an orthographic camera, shows us 30x20 units of the world
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 30, 20);/*from  www  .  j a  v  a  2 s. c o m*/
    camera.update();

    // create the Koala we want to move around the world
    koala = new Koala();
    koala.position.set(20, 20);
}

From source file:com.battleforbronze.game.Screens.WorldRenderer.java

public WorldRenderer(Player1Hand h, Player2Hand h2, HUD p1HUD, HUD p2HUD, HUD turnNew) {
    p1Health = 20;//from ww  w .  j  a  v a  2 s .co  m
    p2Health = 20;
    cardOnFieldP1 = 0;
    RedTilesOnMapP1 = false;
    RedTilesOnMapP2 = false;
    highLightP1 = false;
    highLightP2 = false;
    p1OnFieldCards = new Array<Card>();
    p2OnFieldCards = new Array<Card>();
    p1OnFieldXY = new Array<OnField>();
    p2OnFieldXY = new Array<OnField>();
    playerOneHUD = p1HUD;
    playerTwoHUD = p2HUD;
    checkTurn = turnNew;
    cardSelected = false;
    menutime = true;
    instructiontime = false;
    gametime = false;
    playCard = new Card();
    instructions = new Texture("instructions.png");
    menu = new Texture("menu.png");
    p1Turn = new Texture("turnP1.png");
    p2Turn = new Texture("turnP2.png");
    border = new Texture("border.png");
    manaUsed = new Texture("manaUsed.png");
    map = new TmxMapLoader().load("map.tmx");
    buttonNotPressed = new Texture("button_notpressed.png");
    buttonPressed = new Texture("button_pressed.png");
    mana = new Texture("mana.png");
    clicked = new Cell();
    afterClick = new Cell();
    checkCell = new Cell();
    placeTile = new Cell();
    deckOne = new Deck1();
    deckTwo = new Deck2();
    click = new Vector3();
    deckThree = new Deck3();
    hand = h;
    hand2 = h2;
    gameSet = map.getTileSets().getTileSet("tiles");
    path = (TiledMapTileLayer) map.getLayers().get("path");
    base = (TiledMapTileLayer) map.getLayers().get("base");
    card = new Texture("Card.png");
    font = new BitmapFont();
    HealthP1 = new BitmapFont();
    HealthP2 = new BitmapFont();
    int mapWidth = map.getProperties().get("width", Integer.class);
    int mapHeight = map.getProperties().get("height", Integer.class);

    attkNum1 = new Texture("Numbers/Attack/A1.png");
    attkNum2 = new Texture("Numbers/Attack/A2.png");
    attkNum3 = new Texture("Numbers/Attack/A3.png");
    attkNum4 = new Texture("Numbers/Attack/A4.png");
    attkNum5 = new Texture("Numbers/Attack/A5.png");
    attkNum6 = new Texture("Numbers/Attack/A6.png");
    attkNum7 = new Texture("Numbers/Attack/A7.png");
    attkNum8 = new Texture("Numbers/Attack/A8.png");
    attkNum9 = new Texture("Numbers/Attack/A9.png");

    defNum1 = new Texture("Numbers/Defence/D1.png");
    defNum2 = new Texture("Numbers/Defence/D2.png");
    defNum3 = new Texture("Numbers/Defence/D3.png");
    defNum4 = new Texture("Numbers/Defence/D4.png");
    defNum5 = new Texture("Numbers/Defence/D5.png");
    defNum6 = new Texture("Numbers/Defence/D6.png");
    defNum7 = new Texture("Numbers/Defence/D7.png");
    defNum8 = new Texture("Numbers/Defence/D8.png");
    defNum9 = new Texture("Numbers/Defence/D9.png");

    frcNum1 = new Texture("Numbers/Force/F1.png");
    frcNum2 = new Texture("Numbers/Force/F2.png");
    frcNum3 = new Texture("Numbers/Force/F3.png");
    frcNum4 = new Texture("Numbers/Force/F4.png");
    frcNum5 = new Texture("Numbers/Force/F5.png");
    frcNum6 = new Texture("Numbers/Force/F6.png");
    frcNum7 = new Texture("Numbers/Force/F7.png");
    frcNum8 = new Texture("Numbers/Force/F8.png");
    frcNum9 = new Texture("Numbers/Force/F9.png");

    font.setColor(Color.BLACK);

    //        picture = new Texture("Player1.png");
    camera = new OrthographicCamera();
    guiCam = new OrthographicCamera();
    viewport = new FitViewport(V_WIDTH * 0.5f, V_HEIGHT * 0.5f, camera);
    guiViewport = new FitViewport(V_WIDTH * 0.5f, V_HEIGHT * 0.5f, guiCam);
    batch = new SpriteBatch();
    render = new OrthogonalTiledMapRenderer(map, batch);

    // move the x position of the camera
    camera.position.x = 432 / 2;
    guiCam.position.x = V_WIDTH / 2;
    // move the y position of the camera
    camera.position.y = 0 + (592 / 4);
    guiCam.position.y = V_HEIGHT / 2;
    // update the camera
    camera.update();

    // loads in the images
    //AssetManager.load();
}

From source file:com.gdx.game.screens.PlayScreen.java

public PlayScreen(GdxGame game, AssetManager assetManager) {
    atlas = new TextureAtlas("Mario_and_Enemies.pack");

    this.game = game;
    this.assetManager = assetManager;
    this.gameCam = new OrthographicCamera();
    this.gamePort = new FitViewport(GdxGame.V_WIDTH / GdxGame.PPM, GdxGame.V_HEIGHT / GdxGame.PPM, gameCam);

    // create HUD
    this.hud = new Hud(game.getBatch());

    // load map and setup renderer
    this.mapLoader = new TmxMapLoader();
    this.map = mapLoader.load("level1.tmx");
    this.renderer = new OrthogonalTiledMapRenderer(this.map, 1 / GdxGame.PPM);

    this.gameCam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2, 0);

    this.world = new World(new Vector2(0, -10), true);
    this.box2DDebugRenderer = new Box2DDebugRenderer();

    new b2WorldCreator(world, map, this.assetManager);

    this.player = new Player(this.world, this);

    music = this.assetManager.get("audio/music/mario_music.ogg", Music.class);
    music.setLooping(true);/*from  w  w w.  jav  a 2s  .  co m*/
    music.play();

    world.setContactListener(new WolrdContactListener());

}

From source file:com.holotrash.lazerdeath2.lazerdeath2.java

License:Open Source License

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, w, h);//w  w  w  . j  a v a2  s.  co m
    camera.update();
    mapData = null;
    try {
        mapData = new Map(0, this);
    } catch (IOException e) {
        System.out.println("loading map data failed for level 0");
        e.printStackTrace();
    }
    gm = new GameMaster(this, mapData);
    initializeDudes();
    initializeEnemies();

    lastClickedCell = new Coord(-1, -1);
    highlightTiles = new HashMap<Coord, HighlightTile>();
    highlightOn = false;
    interactedTiles = new ArrayList<InteractedTile>();

    dudesTurnSprite = new Sprite(new Texture(Gdx.files.internal("gfx/dudes_turn.png")));
    enemiesTurnSprite = new Sprite(new Texture(Gdx.files.internal("gfx/enemy_turn.png")));
    this.leftStatusBox = new Sprite(new Texture(Gdx.files.internal("gfx/left_status_box.png")));
    this.rightStatusBox = new Sprite(new Texture(Gdx.files.internal("gfx/right_status_box.png")));
    this.rightStatusBoxFade = new Sprite(new Texture(Gdx.files.internal("gfx/right_status_box_fade_out.png")));
    this.defaultGlamourShot = new Sprite(new Texture(Gdx.files.internal("gfx/default_glamourshot.png")));
    this.glamourShot = defaultGlamourShot;
    this.endTurnButton = new Sprite(new Texture(Gdx.files.internal("gfx/end_turn.png")));
    this.attackButton = new Sprite(new Texture(Gdx.files.internal("gfx/attack_button.png")));
    this.exitGameButton = new Sprite(new Texture(Gdx.files.internal("gfx/exit_game.png")));
    this.menuButton = new Sprite(new Texture(Gdx.files.internal("gfx/menu_button.png")));
    this.unitCursor = new Sprite(new Texture(Gdx.files.internal("gfx/unit_cursor.png")));
    tiledMap = new TmxMapLoader().load("gfx/" + mapData.tmxFileName + ".tmx");
    spriteBatch = new SpriteBatch();
    highlightBatch = new SpriteBatch();
    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, spriteBatch);
    Gdx.input.setInputProcessor(this);
    menuDialog = new MenuDialog(this);
    dialogBox = new DialogBox();
    dialogFont = new BitmapFont(Gdx.files.internal("fonts/bank.fnt"));
    uiFont = new BitmapFont(Gdx.files.internal("fonts/hack.fnt"));
    layout = new GlyphLayout();
    this.ynDialog = new SimpleBooleanDialog("Will you eat my shit?", "Answer immediately!", "", "Jeah!",
            "Nah...");
    gm.showLevelStartDialog();
    selectedUnit = null;

    currentUnitStats = new ArrayList<String>();
    currentUnitStats.add("SELECT A UNIT TO");
    currentUnitStats.add("BEGIN PERPETUATING");
    currentUnitStats.add("THE CYCLE OF");
    currentUnitStats.add("VIOLENCE");
    currentUnitStats.add("...");

    uiConsole = new ArrayDeque<String>();
    uiConsole.push("Battle start...");

    this.screenOrigin = new Vector3(0, 768, 0);
    this.screenOrigin = camera.unproject(this.screenOrigin);

}

From source file:com.johnberg.spacebooty.Play.java

License:Apache License

@Override
public void show() {
    batch = new SpriteBatch();

    camera = new OrthographicCamera();

    tiledMap = new TmxMapLoader().load("fortress.tmx");

    //Create the Game Layer
    gameLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Game");

    //Create the Marker layer
    markerLayer = (TiledMapTileLayer) tiledMap.getLayers().get("Markers");

    cell = new Array<TiledMapTileLayer.Cell>();
    cell.add(markerLayer.getCell(2, 3));
    cell.add(markerLayer.getCell(6, 3));
    cell.add(markerLayer.getCell(8, 3));
    cell.add(markerLayer.getCell(12, 3));
    cell.add(markerLayer.getCell(1, 14));
    cell.add(markerLayer.getCell(2, 14));
    cell.add(markerLayer.getCell(6, 14));
    cell.add(markerLayer.getCell(8, 14));
    cell.add(markerLayer.getCell(12, 14));
    cell.add(markerLayer.getCell(13, 14));

    //Create the renderer
    float unitScale = 1f / 48f;
    renderer = new OrthogonalTiledMapRenderer(tiledMap, unitScale);

    tex = new Texture("background.png");
    background = new Sprite(tex);
}

From source file:com.mygdx.game.DesertGame.java

License:Apache License

@Override
public void create() {
    // load the wanderer frames, split them, and assign them to Animations
    wandererTexture = new Texture("4LinkGreen1.png");
    TextureRegion[][] regions = TextureRegion.split(wandererTexture, 24, 32);

    // Animations (standing, walking) in the four directions
    standNorth = new Animation(0, regions[0][0]);
    standEast = new Animation(0, regions[1][0]);
    standSouth = new Animation(0, regions[2][0]);
    standWest = new Animation(0, regions[3][0]);
    walkNorth = new Animation(0.07f, Arrays.copyOfRange(regions[0], 1, 11));
    walkNorth.setPlayMode(Animation.PlayMode.LOOP);
    walkEast = new Animation(0.07f, Arrays.copyOfRange(regions[1], 1, 11));
    walkEast.setPlayMode(Animation.PlayMode.LOOP);
    walkSouth = new Animation(0.07f, Arrays.copyOfRange(regions[2], 1, 11));
    walkSouth.setPlayMode(Animation.PlayMode.LOOP);
    walkWest = new Animation(0.07f, Arrays.copyOfRange(regions[3], 1, 11));
    walkWest.setPlayMode(Animation.PlayMode.LOOP);

    // figure out the width and height of the wanderer for collision
    // detection and rendering by converting a wanderer frames pixel
    // size into world units (1 unit == 16 pixels)
    Wanderer.WIDTH = 1 / 16f * regions[0][0].getRegionWidth();
    Wanderer.HEIGHT = 1 / 16f * regions[0][0].getRegionHeight();

    // load the map, set the unit scale to 1/16 (1 unit == 16 pixels)
    map[0] = new TmxMapLoader().load("level1.tmx");
    map[1] = new TmxMapLoader().load("level2.tmx");

    renderer = new OrthogonalTiledMapRenderer(map[0], 1 / 16f);

    // create an orthographic camera, shows us 30x20 units of the world
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 30, 20);/* ww  w. j  a  va  2s .  co m*/
    camera.update();

    // create the Wanderer we want to move around the world
    wanderer = new Wanderer();
    wanderer.position.set(20, 20);
}

From source file:com.mygdx.game.Tools.PlayScreen.PlayScreen1_1.java

public PlayScreen1_1(AdventureGame game) {

    super(game);/*www. ja  v a  2 s . com*/

    map = mapLoader.load("levels/Level1_1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1 / AdventureGame.PPM);
    creator = new B2WorldCreator1_1(this);
    enemies = creator.getEnemies();

    player = new Player(this, 64 / AdventureGame.PPM, 64 / AdventureGame.PPM);

    AdventureGame.manager.get("music/Music 1_1.mp3", Music.class).play();
    AdventureGame.manager.get("music/Music 1_1.mp3", Music.class).setLooping(true);
    AdventureGame.manager.get("music/Music 1_1.mp3", Music.class).setVolume(0.5f);

}

From source file:com.mygdx.game.Tools.PlayScreen.PlayScreen1_2.java

public PlayScreen1_2(AdventureGame game) {

    super(game);//from  w  w w .j a  v  a  2 s  . co  m

    map = mapLoader.load("levels/Level1_2.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1 / AdventureGame.PPM);
    creator = new B2WorldCreator1_2(this);
    enemies = creator.getEnemies();

    player = new Player(this, 64 / AdventureGame.PPM, 900 / AdventureGame.PPM);

    AdventureGame.manager.get("music/Music 1_2.mp3", Music.class).play();
    AdventureGame.manager.get("music/Music 1_2.mp3", Music.class).setLooping(true);
    AdventureGame.manager.get("music/Music 1_2.mp3", Music.class).setVolume(0.5f);

}

From source file:com.mygdx.game.Tools.PlayScreen.PlayScreenBossLevel.java

public PlayScreenBossLevel(AdventureGame game) {
    super(game);//from   ww w .  java 2s .c o  m

    map = mapLoader.load("levels/BossLevel.tmx");
    renderer = new OrthogonalTiledMapRenderer(map, 1 / AdventureGame.PPM);
    creator = new B2WorldCreatorBossLevel(this);
    enemies = creator.getEnemies();

    player = new Player(this, 64 / AdventureGame.PPM, 100 / AdventureGame.PPM);
    boss = new Boss(this, 205 / AdventureGame.PPM, 100 / AdventureGame.PPM);

    AdventureGame.manager.get("music/Music BossLevel.mp3", Music.class).play();
    AdventureGame.manager.get("music/Music BossLevel.mp3", Music.class).setLooping(true);
    AdventureGame.manager.get("music/Music BossLevel.mp3", Music.class).setVolume(0.5f);
}