I am wondering if there is any way to simulate light shading in Libgdx using an IsometricTiledMapRenderer.
Here is my code to draw an isometric map, it's able to be moved around with the mouse and you can zoom in and out with the mouse scroll wheel.
package com.iso.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.IsometricTiledMapRenderer;
import com.iso.game.Main;
public class GameScreen extends AbstractScreen
{
private TiledMap map;
private IsometricTiledMapRenderer renderer;
private OrthographicCamera camera;
public GameScreen(Main game)
{
super(game);
}
public void load()
{
map = new TmxMapLoader().load("map.tmx");
renderer = new IsometricTiledMapRenderer(map);
renderer.getSpriteBatch().setShader(null);
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
}
public void render(float delta)
{
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
renderer.setView(camera);
renderer.render();
}
public boolean scrolled(int amount)
{
camera.zoom += 0.1 * amount;
// Don't go below the map
if (camera.zoom < 0.01)
camera.zoom = (float) 0.01;
return false;
}
public boolean pan(float x, float y, float deltaX, float deltaY)
{
camera.position.add(camera.zoom * -deltaX, camera.zoom * deltaY, 0);
return false;
}
public boolean touchDown(int screenX, int screenY, int pointer, int button)
{
if (button == Buttons.MIDDLE)
camera.zoom = 1;
return false;
}
public void resize(int width, int height)
{
camera.viewportWidth = width;
camera.viewportHeight = height;
}
public void dispose()
{
map.dispose();
renderer.dispose();
}
}
And here is an image of what this code looks like (Note, this class is not the entirety of my code. If you need to rest for some reason please let me know).
Can anyone give me an example on how to simulate lighting with this map? Such as a point light that spreads out and looks isometric, perhaps choosing some tiles as objects that block or distort light. I have no idea how to get started and I couldn't really find anything useful online.
Thank you for your help in advance.