src/neon/critical/NeonEngine.java
/**
   * Creates a window for the game and initializes the engine.
   *
   * @param game a class which implements the IGame interface and contains the main logic of a game
   * @param settings the basic settings used for a game
   */
Creates a window for the game and initializes the engine.
@param game a class which implements the IGame interface and contains the main logic of a game
@param settings the basic settings used for a game
Creates a window for the game and initializes the engine . @param game a class which implements the IGame interface and contains the main logic of a game @param settings the basic settings used for a game
public static void init(Game game, GameSettings settings) {
    WindowSettings windowSettings = settings.windowSettings;
    if (windowSettings != null) {
      instance.setPreferredSize(new Dimension(windowSettings.width, windowSettings.height));
      instance.requestFocus();
      frame = new JFrame(windowSettings.title);
      frame.add(instance);
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      GraphicsDevice graphicsDevice =
          GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
      if (windowSettings.windowOption.doFullscreen
          && GeneralUtils.getOsType() == OsType.MAC_OS
          && graphicsDevice.isFullScreenSupported()) {
        graphicsDevice.setFullScreenWindow(frame);
      }
      frame.setUndecorated(windowSettings.windowOption.doFullscreen);
      frame.setResizable(false);
      frame.pack();
      frame.setVisible(true);
      instance.createBufferStrategy(windowSettings.bufferCount);
    }
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                () -> {
                  terminate();
                  game.onExit();
                }));
    instance.game = game;
    NeonEngine.settings = settings;
    instance.addMouseListener(new InputSystem.MouseInput());
    instance.addKeyListener(new InputSystem.KeyInput());
    game.init();
    instance.start();
  }
public static void init ( Game game , GameSettings settings ) { WindowSettings windowSettings = settings . windowSettings ; if ( windowSettings != null ) { instance . setPreferredSize ( new Dimension ( windowSettings . width , windowSettings . height ) ) ; instance . requestFocus ( ) ; frame = new JFrame ( windowSettings . title ) ; frame . add ( instance ) ; frame . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE ) ; GraphicsDevice graphicsDevice = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) . getDefaultScreenDevice ( ) ; if ( windowSettings . windowOption . doFullscreen && GeneralUtils . getOsType ( ) == OsType . MAC_OS && graphicsDevice . isFullScreenSupported ( ) ) { graphicsDevice . setFullScreenWindow ( frame ) ; } frame . setUndecorated ( windowSettings . windowOption . doFullscreen ) ; frame . setResizable ( false ) ; frame . pack ( ) ; frame . setVisible ( true ) ; instance . createBufferStrategy ( windowSettings . bufferCount ) ; } Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ( ) -> { terminate ( ) ; game . onExit ( ) ; } ) ) ; instance . game = game ; NeonEngine . settings = settings ; instance . addMouseListener ( new InputSystem . MouseInput ( ) ) ; instance . addKeyListener ( new InputSystem . KeyInput ( ) ) ; game . init ( ) ; instance . start ( ) ; }
Creates a window for the game and initializes the engine.
Creates a window for the game and initializes the engine .