Created
May 8, 2013 19:13
-
-
Save ariejan/5542843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void render(float delta) { | |
// Clear screen | |
Gdx.gl20.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); | |
Gdx.gl20.glClearColor(0f, 0f, 0.2f, 1f); | |
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); | |
// Set camera position | |
camera.position.set(new Vector3(player.getPosition().x, player.getPosition().y, 0)); | |
camera.update(); | |
// Render the map | |
tileMapRenderer.setView(camera); | |
tileMapRenderer.render(); | |
// Render sprites | |
batch.setProjectionMatrix(camera.combined); | |
batch.begin(); | |
player.render(batch); | |
batch.end(); | |
} | |
@Override | |
public void resize(int width, int height) { | |
} | |
@Override | |
public void show() { | |
// Create the player | |
player = new Player(); | |
// Setup camera | |
float w = Gdx.graphics.getWidth(); | |
float h = Gdx.graphics.getHeight(); | |
camera = new OrthographicCamera(); | |
camera.setToOrtho(false, (w / Settings.TILE_SIZE), (h / Settings.TILE_SIZE)); | |
camera.zoom = 1f / 3f; | |
camera.update(); | |
// Setup input handling | |
gameInputProcessor = new GameInputProcessor(player); | |
inputMultiplexer = new InputMultiplexer(); | |
inputMultiplexer.addProcessor(gameInputProcessor); | |
Gdx.input.setInputProcessor(inputMultiplexer); | |
// Load map | |
map = VortexAssets.getAssetManager().get("assets/levels/level-sample.tmx"); | |
tileMapRenderer = new OrthogonalTiledMapRenderer(map, Settings.UNIT_SCALE); | |
player.move(3, 26); | |
batch = new SpriteBatch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment