Repository navigation
BasicGame class
Thomas Cashman edited this page Oct 15, 2016
·
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 {
public static final String GAME_IDENTIFIER = "com.basic.game.example";
@Override
public void initialise() {
//Initialise your objects here
}
@Override
public void update(float delta) {
//Game logic here
}
@Override
public void interpolate(float alpha) {
//Calculate render coordinates 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. Note that an identifier for your game, e.g. 'org.mini2dx.sample.basicgameexample', is required so that mini2Dx can initialise some of the features that will be explained in later tutorials.
public static void main(String [] args) {
DesktopMini2DxConfig cfg = new DesktopMini2DxConfig(BasicGameExample.GAME_IDENTIFIER);
cfg.title = "Basic Game Example";
cfg.width = 800;
cfg.height = 600;
cfg.vSyncEnabled = true;
new DesktopMini2DxGame(new BasicGameExample(), cfg);
}Getting Started
Graphics
Gameplay
Data
- Asset Management
- Saving and loading player data
- Converting objects to/from JSON
- Converting objects to/from XML
User Interfaces / HUDs
Structuring your code
Releasing your game