Skip to content

The BasicGame class 0.8 release

Thomas Cashman edited this page Oct 30, 2013 · 3 revisions

To make it easy to get started with mini2Dx we've added a simplified game class called BasicGame. The following code shows how to extends the BasicGame class for your game.

import org.mini2Dx.core.game.BasicGame;
import org.mini2Dx.core.game.Mini2DxGame;
import org.mini2Dx.core.graphics.Graphics;

public class BasicGameExample extends BasicGame {

	@Override
	public void initialise() {
		//Initialise your objects here
	}

	@Override
	public void update(float delta) {
		//Game logic here
	}

	@Override
	public void render(Graphics g) {
		//Rendering here
	}
}

To launch your game via a desktop (PC/Mac/Linux) project, simply edit your main method with the following.

	public static void main(String [] args) {
		LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
		cfg.title = "A basic game";
		cfg.useGL20 = true;
		cfg.width = 800;
		cfg.height = 600;
		cfg.useCPUSynch = false;
		cfg.vSyncEnabled = true;
		new LwjglApplication(new Mini2DxGame(new BasicGameExample()), cfg);
	}

Clone this wiki locally