Class Application

java.lang.Object
dev.prozilla.pine.core.Application
All Implemented Interfaces:
Lifecycle

public class Application extends Object implements Lifecycle
2D application using the LWJGL library.
  • Field Details

    • initialized

      public boolean initialized
      True if the application has been initialized
    • initializedOpenGL

      public static boolean initializedOpenGL
      True if OpenGL has been initialized
    • isRunning

      public boolean isRunning
    • shouldStop

      protected boolean shouldStop
    • isPaused

      public boolean isPaused
    • isPreview

      protected boolean isPreview
    • currentScene

      public Scene currentScene
    • config

      protected final Config config
    • logger

      protected final AppLogger logger
    • timer

      protected final Timer timer
    • renderer

      protected final Renderer renderer
    • window

      protected final Window window
    • input

      protected Input input
    • tracker

      protected final Tracker tracker
    • modManager

      protected final ModManager modManager
    • DEFAULT_TITLE

      public static final String DEFAULT_TITLE
      See Also:
    • DEFAULT_TARGET_FPS

      public static final int DEFAULT_TARGET_FPS
      See Also:
  • Constructor Details

    • Application

      public Application(int width, int height)
      Creates an application titled "Application".
      Parameters:
      width - Width of the window
      height - height of the window
    • Application

      public Application(String title, int width, int height)
      Creates an application.
      Parameters:
      title - Title of the application
      width - Width of the window
      height - height of the window
    • Application

      public Application(String title, int width, int height, Scene scene)
      Creates an application.
      Parameters:
      title - Title of the application
      width - Width of the window
      height - height of the window
      scene - Starting scene
    • Application

      public Application(String title, int width, int height, Scene scene, int targetFps)
      Creates an application.
      Parameters:
      title - Title of the application
      width - Width of the window
      height - height of the window
      scene - Starting scene
      targetFps - Amount of frames per second to target
  • Method Details

    • run

      public void run()
      Initializes and starts the application and handles exceptions.
    • init

      public void init() throws RuntimeException
      Initializes the application.
      Specified by:
      init in interface Lifecycle
      Throws:
      RuntimeException
    • initPreview

      public void initPreview(Input input, int width, int height)
    • start

      public void start()
      Starts the application loop. Destroys the application after the application loop has been stopped.
      Specified by:
      start in interface Lifecycle
    • input

      public void input(float deltaTime)
      Handles input for the application.
      Specified by:
      input in interface Lifecycle
      Parameters:
      deltaTime - Delta time in seconds
    • update

      public void update(float deltaTime)
      Updates the application.
      Specified by:
      update in interface Lifecycle
      Parameters:
      deltaTime - Delta time in seconds
    • updatePreview

      public void updatePreview(float deltaTime)
    • render

      public void render(Renderer renderer)
      Renders the application.
      Specified by:
      render in interface Lifecycle
      Parameters:
      renderer - Reference to the renderer
    • renderPreview

      public void renderPreview()
    • pause

      public void pause()
      Pauses the application.
    • resume

      public void resume()
      Resumes the application panel.
    • togglePause

      public void togglePause()
      Pauses or resumes the application panel based on the current state.
    • stop

      public void stop()
      Tells the application to stop after the current frame.
    • destroy

      public void destroy()
      Stops the application and cleans up resources. This should not be called before the application loop ends.
      Specified by:
      destroy in interface Lifecycle
    • printVersions

      public static void printVersions()
      Logs versions of libraries to the console
    • addScene

      public int addScene(Scene scene)
      Adds a scene and returns its ID.
      Parameters:
      scene - Scene
      Returns:
      Scene ID
    • reloadScene

      public void reloadScene()
      Reloads the current scene.
    • loadScene

      public void loadScene(Scene scene)
      Loads a scene by reference.
      Parameters:
      scene - Reference to the scene
    • nextScene

      public void nextScene()
      Loads the next scene.
    • previousScene

      public void previousScene()
      Loads the previous scene.
    • loadScene

      public void loadScene(int id)
      Loads a scene by ID.
      Parameters:
      id - Scene ID
    • unloadScene

      public void unloadScene()
      Unloads the current scene.
    • setIcons

      public void setIcons(String... icons)
    • loadIcons

      public void loadIcons()
      Loads the window icons.
    • setDefaultFont

      public void setDefaultFont(String fontPath)
    • getDefaultFont

      public Font getDefaultFont()
    • resize

      public void resize()
      Resizes the application window.
    • isPreview

      public boolean isPreview()
    • isStandalone

      public boolean isStandalone()
    • getInput

      public Input getInput()
    • getWindow

      public Window getWindow()
    • getRenderer

      public Renderer getRenderer()
    • getTimer

      public Timer getTimer()
    • getTracker

      public Tracker getTracker()
    • getConfig

      public Config getConfig()
    • getModManager

      public ModManager getModManager()
    • getLogger

      public Logger getLogger()