I'd really like to use LibGDX for this jam, but I'm not quite sure how to emulate the 64x64 resolution in this engine. Does anyone have any idea how to do this?
Glad to see people using LibGDX :D
It's quite simple actually, you need to take advantage of the Viewports, more specifically FitViewport.
Documentation: https://github.com/libgdx/libgdx/wiki/Viewports
Let me show you some snippet for a Screen class which will always maintain the 64x64 aspect:
public class LowResTest implements Screen {
private Color color = Color.BLACK;
private Viewport gameView;
private SpriteBatch batch;
private Texture texture;
@Override
public void show() {
gameView = new FitViewport(64, 64); // This is the internal resolution your game will display regardless of window size
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("badlogic.jpg"));
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(color.r, color.g, color.b, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
gameView.apply(); // we set this as the current viewport (we could have more viewports, for example a hudView)
OrthographicCamera cam = (OrthographicCamera) gameView.getCamera();
batch.setProjectionMatrix(cam.combined); // Don't forget this else your viewport won't be used when rendering
batch.begin();
batch.draw(texture, 0, 0);
batch.end();
}
@Override
public void resize(int width, int height) {
gameView.update(width, height); // also don't forget this
} ...
Hope this helps!
And good jamming to all! I still have to spend some day to brainstorm ideas :P
@Ben
Are you using Tiled maps? This is common if you're using a spritesheet that has no padding between each tile. If you modify your image to add a 1px padding between each tile and import it on tiled as such (telling it has a 1px pad) it should display fine.
In case you already made some tiles and don't want to manually rearrange it, I've used this gimp plugin in the past to automatically add padding (or do other modifications) to spritesheets:
http://registry.gimp.org/node/26044
It had padding, but the padding was white. Apparently each tile needs to have padding of the same color as the pixel next to it. That seems a completely backwards way to deal with this -- isn't this simply a bug in libGDX that shouldn't occur?
Anyway, I wasn't using a TiledMap but I am planning to implement that soon
LibGDX seems to be very bad at this. Look what happens when you try to use ShapeRenderer with a low resolution FitViewport:
I was thinking of looking at trying to force it to use Bresenham's line algorithm to draw lines in this but then I discovered this happening:
What the hell is this!? commit that shows this problem is here
Xoppa on the freenode #libgdx IRC said that the solution to this is to first render everything inside a FrameBufferObject and only then write that to the screen. I will be experimenting with that soon