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-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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | gs.lionengine.example.core.minimal; import com.b3dgs.lionengine.Config; import com.b3dgs.lionengine.Resolution; import com.b3dgs.lionengine.Version; import com.b3dgs.lionengine.core.Loader; 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 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), AppJava.class); Engine.start( "AppJava" , Version.create( 1 , 0 , 0 ), "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 ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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 ), 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(); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | gs.lionengine.example.core.minimal; import com.b3dgs.lionengine.Resolution; import com.b3dgs.lionengine.core.Graphic; import com.b3dgs.lionengine.core.Loader; import com.b3dgs.lionengine.core.Sequence; import com.b3dgs.lionengine.core.awt.Engine; import com.b3dgs.lionengine.core.awt.Keyboard; /** * 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) */ class Scene extends Sequence { /** Native resolution. */ private static final Resolution NATIVE = new Resolution( 320 , 240 , 60 ); /** Keyboard reference. */ private final Keyboard keyboard = getInputDevice(Keyboard. class ); /** * Constructor. * * @param loader The loader reference. */ public Scene(Loader loader) { super (loader, Scene.NATIVE); keyboard.addActionPressed(Keyboard.ESCAPE, new KeyboardAction() { @Override public void action() { end(); } }); } @Override protected void load() { // Load } @Override public void update( double extrp) { // Update } @Override public void render(Graphic g) { // Render } @Override protected void onTerminate( boolean hasNextSequence) { if (!hasNextSequence) { Engine.terminate(); } } } |
Lire la suite: Architecture Générale