Steps to include the LionEngine in your project:
- lionengine-core (minimum requirement)
- lionengine-core-awt (required if you use AWT as graphic renderer, target for computer)
- lionengine-core-swt (required if you use SWT as graphic renderer, target for computer)
- lionengine-core-android (required if you use Android 1.5, target for phones)
- lionengine-game (base for game development)
- lionengine-game-platform (specialized for platform games)
- lionengine-game-pathfinding (support for pathfinding)
- lionengine-game-strategy (specialized for strategy games)
- lionengine-network (support for network)
- lionengine-audio-wav (support for Wav sound)
- lionengine-audio-midi (support for Midi musics)
- lionengine-audio-sc68 (support for Sc68 Atari musics)
Once you installed the LionEngine in your project, you may would like to know how to prepare a quick sample as a first try.
.lionengine.Config;
import com.b3dgs.lionengine.Resolution;
import com.b3dgs.lionengine.Version;
import com.b3dgs.lionengine.core.Loader;
import com.b3dgs.lionengine.core.Verbose;
import com.b3dgs.lionengine.core.awt.Engine;
/**
* Program starts here. When you start the jvm, ensure that this main function is called.
*
* @author Pierre-Alexandre (contact@b3dgs.com)
*/
public final class AppJava
{
/**
* Main function called by the jvm.
*
* @param args The arguments.
*/
public static void main(String[] args)
{
// Start engine (name = "First Code", version = "1.0.0", resources directory = "resources")
// The engine is initialized with our parameters:
// - The name of our program: "First Code"
// - The program version: "1.0.0"
// - The main resources directory, relative to the execution directory: ./resources/
// This mean that any resources loaded with Media.get(...) will have this directory as prefix.
// To load resources from JAR, this alternative is preferred if external folder is not possible:
// Engine.start("AppJava", Version.create(1, 0, 0), Verbose.CRITICAL, AppJava.class);
Engine.start("AppJava", Version.create(1, 0, 0), Verbose.CRITICAL, "resources");
// Resolution configuration (output = 640*480 at 60Hz). This is the output configuration.
// As our native is in 320*240 (described in the Scene), the output will be scaled by 2.
// If the current frame rate is lower than the required in the native,
// the extrapolation value will allow to compensate any data calculation.
final Resolution output = new Resolution(640, 480, 60);
// Final configuration (rendering will be scaled by 2 considering source and output resolution).
// This is the final configuration container, including color depth and window mode.
final Config config = new Config(output, 16, true);
// Program starter, setup with our configuration. It just needs one sequence reference to start.
final Loader loader = new Loader(config);
loader.start(Scene.class);
}
}
import com.example.test.Menu;
public final class AppAndroid
extends Activity
{
@Override
protected void onPostCreate(Bundle savedInstanceState)
{
super.onPostCreate(savedInstanceState);
Engine.start("AppAndroid", Version.create(1, 0, 0), Verbose.CRITICAL, this);
final Resolution output = new Resolution(800, 480, 60);
final Config config = new Config(output, 32, false);
final Loader loader = new Loader(config);
loader.start(Menu.class);
}
@Override
public void finish()
{
super.finish();
Engine.terminate();
}
} .lionengine.Resolution;
import com.b3dgs.lionengine.core.Graphic;
import com.b3dgs.lionengine.core.Keyboard;
import com.b3dgs.lionengine.core.Loader;
import com.b3dgs.lionengine.core.Sequence;
/**
* This is where the game loop is running. A sequence represents a thread handled by the Loader. To link a sequence with
* another one, a simple call to {@link Sequence#end(Class, Object...)} is necessary. This will terminate the current
* sequence, and start the linked one.
*
* @author Pierre-Alexandre (contact@b3dgs.com)
*/
final class Scene
extends Sequence
{
/** Native resolution. */
private static final Resolution NATIVE = new Resolution(320, 240, 60);
/** Keyboard reference. */
private final Keyboard keyboard;
/**
* Constructor.
*
* @param loader The loader reference.
*/
Scene(Loader loader)
{
super(loader, Scene.NATIVE);
keyboard = getInputDevice(Keyboard.class);
}
/*
* Sequence
*/
@Override
protected void load()
{
// Load
}
@Override
protected void update(double extrp)
{
if (keyboard.isPressed(Keyboard.ESCAPE))
{
end();
}
// Update
}
@Override
protected void render(Graphic g)
{
// Render
}
}
Read next page: General architecture