Пример #1
0
  public static void main(String[] args) {
    LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
    System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
    cfg.fullscreen = false;
    cfg.resizable = false;
    cfg.title = "Our First Game";
    cfg.useGL20 = true;

    // get user's desktop screen resolution
    int desktopWidth = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
    int desktopHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;

    // calculate window size...
    int gameWidth = 1920; // default to 1920x1080
    int gameHeight = 1080;
    float gameAspectRatio = (float) gameWidth / (float) gameHeight;
    // if the user doesn't support 1920x1080, go for the greatest width possible (and retain the
    // widescreen aspect ratio)
    if (gameWidth > desktopWidth) {
      gameWidth = desktopWidth;
      gameHeight = (int) ((1.0f / gameAspectRatio) * gameWidth);
    }

    // handle an unlikely scenario where the user has a really high screen resolution (something
    // weird like 500x1500)
    if (gameHeight > desktopHeight) {
      gameWidth = (int) (desktopWidth * gameAspectRatio);
      gameHeight = desktopHeight;
    }

    cfg.width = gameWidth;
    cfg.height = gameHeight;

    new LwjglApplication(new OurFirstGame(), cfg);
  }
Пример #2
0
  public static void main(String[] arg) {
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    config.width = Main.WIDTH;
    config.height = Main.HEIGHT;
    config.title = Main.TITLE;
    config.fullscreen = false;
    config.resizable = false;

    new LwjglApplication(new Main(), config);
  }
 @Override
 public void setFullScreen(boolean fullScreen) throws GdxEngineException {
   config.fullscreen = fullScreen;
   if (gdxApplication != null) {
     if (fullScreen) {
       setFullScreenResolution(fullScreenResolution);
     } else {
       setWindowSize(windowWidth, windowHeight);
     }
   }
 }
Пример #4
0
 public static void main(String[] arg) {
   LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
   config.fullscreen = false;
   config.width = 1280;
   config.height = 720;
   // config.useGL30=true;
   config.x = 0;
   config.y = 0;
   config.title = "Domination Game";
   new LwjglApplication(new Game(), config);
 }
Пример #5
0
 public static void main(String[] arg) {
   width = 1;
   height = 1;
   LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
   config.fullscreen = false;
   config.vSyncEnabled = true;
   config.width = width;
   config.height = height;
   config.foregroundFPS = 60;
   config.allowSoftwareMode = true;
   config.samples = 2;
   new LwjglApplication(new LovePirates(), config);
   // config.fullscreen = true;
 }
Пример #6
0
  public static void main(String[] arg) {
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.foregroundFPS = 1000;
    config.vSyncEnabled = false;
    config.width = 1280;
    config.height = 720;
    config.resizable = false;
    config.title = "Burst";
    // config.setFromDisplayMode(LwjglApplicationConfiguration.getDesktopDisplayMode());
    config.fullscreen = false;

    config.addIcon("img/logo.png", FileType.Internal);
    config.addIcon("img/logo_64.png", FileType.Internal);
    config.addIcon("img/logo_32.png", FileType.Internal);
    config.addIcon("img/logo_16.png", FileType.Internal);

    new LwjglApplication(new Burst(), config);
  }
Пример #7
0
  public static void main(String[] args) {

    DisplayMode displayMode = LwjglApplicationConfiguration.getDesktopDisplayMode();

    //        try {
    //            // find first display mode that allows us 640*480*16
    //            int mode = -1;
    //            DisplayMode[] modes = LwjglApplicationConfiguration.getDisplayModes();
    //            for (int i = 0; i < modes.length; i++) {
    //                    if (modes[i].width == 800 && modes[i].height == 480) {
    //                            mode = i;
    //                            break;
    //                    }
    //            }
    //            if (mode != -1) {
    //                    // select above found displaymode
    //                    System.out.println("Setting display mode to " + modes[mode]);
    //                    displayMode = modes[mode];
    //                    System.out.println("Created display.");
    //            }
    //	    } catch (Exception e) {
    //	            System.err.println("Failed to create display due to " + e);
    //	    }
    //

    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    config.setFromDisplayMode(displayMode);

    config.width = 800;
    config.height = 480;
    config.title = "Qb";

    config.fullscreen = false;
    config.samples = 4;
    config.useGL20 = true;
    config.vSyncEnabled = true;
    config.useCPUSynch = true;
    new LwjglApplication(new DesktopStarter(), config);
  }
  /**
   * Create a new desktop game that is drawn using libGDX.
   *
   * @param gameListener the game listener that receives the updates regarding the game
   * @param width the width of the game container
   * @param height the height of the game container
   * @param fullScreen the full screen flag of the container
   * @throws GdxEngineException in case the initialization goes wrong
   */
  public ApplicationGameContainer(
      GameListener gameListener, int width, int height, boolean fullScreen)
      throws GdxEngineException {
    this.gameListener = gameListener;
    config = new LwjglApplicationConfiguration();
    config.forceExit = false;
    config.vSyncEnabled = true;
    config.backgroundFPS = 10;
    config.foregroundFPS = 60;

    windowHeight = height;
    windowWidth = width;
    fullScreenResolution = getFittingFullScreenResolution(width, height);
    if (fullScreen) {
      config.height = fullScreenResolution.getHeight();
      config.width = fullScreenResolution.getWidth();
    } else {
      config.height = height;
      config.width = width;
    }
    config.fullscreen = fullScreen;
  }