Voici les étapes pour ajouter le LionEngine dans votre projet:
- lionengine-core (minimum requis)
- lionengine-core-awt (requis si vous utilisez AWT pour le rendu graphique, en cible pour ordinateur)
- lionengine-core-swt (requis si vous utilisez SWT pour le rendu graphique, en cible pour ordinateur)
- lionengine-core-android (requis si vous utilisez Android 1.5, en cible pour mobile)
- lionengine-game (base pour le développement de jeux)
- lionengine-game-platform (spécialisé pour les jeux de plateforme)
- lionengine-game-pathfinding (support du pathfinding)
- lionengine-game-strategy (spécialisé pour les jeux de stratégie)
- lionengine-network (support du réseau)
- lionengine-audio-wav (support du format de son Wav)
- lionengine-audio-midi (support du format de musique Midi)
- lionengine-audio-sc68 (support du format de musique Atari Sc68)
Après avoir installé le LionEngine dans votre projet, vous aimeriez peut être l'essayer avec un petit exemple:
.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 } }
Lire la suite: Architecture Générale