• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.badlogic.gdx.tests;
2 
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.graphics.GL20;
5 import com.badlogic.gdx.graphics.OrthographicCamera;
6 import com.badlogic.gdx.graphics.g2d.BitmapFont;
7 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
8 import com.badlogic.gdx.maps.tiled.TiledMap;
9 import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
10 import com.badlogic.gdx.maps.tiled.TmxMapLoader;
11 import com.badlogic.gdx.maps.tiled.renderers.IsometricTiledMapRenderer;
12 import com.badlogic.gdx.tests.utils.GdxTest;
13 import com.badlogic.gdx.tests.utils.OrthoCamController;
14 
15 public class TiledMapModifiedExternalTilesetTest extends GdxTest {
16 	private TiledMap map;
17 	private TiledMapRenderer renderer;
18 	private OrthographicCamera camera;
19 	private OrthoCamController cameraController;
20 	private BitmapFont font;
21 	private SpriteBatch batch;
22 
23 	@Override
create()24 	public void create () {
25 		float w = Gdx.graphics.getWidth();
26 		float h = Gdx.graphics.getHeight();
27 
28 		camera = new OrthographicCamera();
29 		camera.setToOrtho(false, (w / h) * 10, 10);
30 		camera.position.set(10.0f, 2.5f, 0.0f);
31 		camera.update();
32 
33 		cameraController = new OrthoCamController(camera);
34 		Gdx.input.setInputProcessor(cameraController);
35 
36 		font = new BitmapFont();
37 		batch = new SpriteBatch();
38 
39 		// These two maps should appear identical -- a ring of grass with water inside and out.
40 		// The original is correct, without the bug fix to TiledMapTileSets.java that acompanies
41 		// this test, the latter appears as all grass.
42 //		map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_original.tmx");
43 		map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_extended.tmx");
44 		renderer = new IsometricTiledMapRenderer(map, 1f / 32f);
45 	}
46 
47 	@Override
render()48 	public void render () {
49 		Gdx.gl.glClearColor(0.55f, 0.55f, 0.55f, 1f);
50 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
51 		camera.update();
52 		renderer.setView(camera);
53 		renderer.render();
54 		batch.begin();
55 		font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 10, 20);
56 		batch.end();
57 	}
58 
59 	@Override
dispose()60 	public void dispose () {
61 		map.dispose();
62 	}
63 }