Skip to content

Instantly share code, notes, and snippets.

@ariejan
Created May 8, 2013 19:13
Show Gist options
  • Save ariejan/5542843 to your computer and use it in GitHub Desktop.
Save ariejan/5542843 to your computer and use it in GitHub Desktop.
@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