Class Scene

java.lang.Object
xyz.jeremynoesen.pseudo3d.core.Scene

public class Scene
extends java.lang.Object
Scene to place Entities, a Camera, and Runnables in and modify them
  • Constructor Summary

    Constructors
    Constructor Description
    Scene()
    Create a new default Scene
    Scene​(java.util.LinkedList<Entity> entities, Camera camera, Sprite background, Vector gridScale)
    Create a new Scene with pre-defined Entities, Camera, background Sprite, and grid scale
    Scene​(Scene scene)
    Copy constructor for Scene
  • Method Summary

    Modifier and Type Method Description
    Scene addEntity​(Entity... entity)
    Add Entities to this Scene
    Scene addRenderRunnable​(java.lang.Runnable... runnable)
    Add a Runnable to the render loop for this Scene
    Scene addTickRunnable​(java.lang.Runnable... runnable)
    Add Runnables to the tick loop for this Scene
    boolean equals​(java.lang.Object o)
    Check if a Scene is identical to this Scene
    Sprite getBackground()
    Get the background Sprite of the Scene
    Camera getCamera()
    Get the Camera for this Scene
    java.util.LinkedList<Entity> getEntities()
    Get all the Entities in this Scene
    Modifying this directly will cause problems
    Vector getGridScale()
    Get the Scene grid scale
    java.util.HashSet<java.lang.Runnable> getRenderRunnables()
    Get all render Runnables for the Scene
    float getSpeed()
    Get the speed modifier of the Scene for physics and rendering
    java.util.HashSet<java.lang.Runnable> getTickRunnables()
    Get all tick Runnables for the Scene
    Scene removeEntity​(Entity... entity)
    Remove Entities from this Scene
    Scene removeRenderRunnable​(java.lang.Runnable... runnable)
    Remove a Runnable from the render loop for the Scene
    Scene removeTickRunnable​(java.lang.Runnable... runnable)
    Remove Runnables from the tick loop for the Scene
    void render​(javafx.scene.canvas.GraphicsContext graphicsContext, float deltaTime)
    Render this Scene to the main Canvas, as well as run any Runnables
    Scene setBackground​(Sprite background)
    Set the background Sprite for the Scene
    Scene setCamera​(Camera camera)
    Give this Scene a different Camera
    Scene setGridScale​(Vector gridScale)
    Set a new grid scale for the Scene
    Scene setSpeed​(float speed)
    Set the speed modifier for the Scene for physics and rendering
    void tick​(float deltaTime)
    Tick all entities in the Scene
    Ticking will do the following in order: run any Runnables, update motion for all Entities, then update collisions for all Entities

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Scene

      public Scene()
      Create a new default Scene
    • Scene

      public Scene​(java.util.LinkedList<Entity> entities, Camera camera, Sprite background, Vector gridScale)
      Create a new Scene with pre-defined Entities, Camera, background Sprite, and grid scale
      Parameters:
      entities - Entities to put in the Scene
      camera - Scene Camera
      background - Background Sprite
      gridScale - Scene grid scale
    • Scene

      public Scene​(Scene scene)
      Copy constructor for Scene
      Parameters:
      scene - Scene to copy
  • Method Details

    • tick

      public void tick​(float deltaTime)
      Tick all entities in the Scene
      Ticking will do the following in order: run any Runnables, update motion for all Entities, then update collisions for all Entities
      Parameters:
      deltaTime - How long the previous tick took in seconds
    • render

      public void render​(javafx.scene.canvas.GraphicsContext graphicsContext, float deltaTime)
      Render this Scene to the main Canvas, as well as run any Runnables
      Parameters:
      graphicsContext - GraphicsContext to render to
      deltaTime - How long the previous render took in seconds
    • getEntities

      public java.util.LinkedList<Entity> getEntities()
      Get all the Entities in this Scene
      Modifying this directly will cause problems
      Returns:
      List of all Entities in this Scene
    • addEntity

      public Scene addEntity​(Entity... entity)
      Add Entities to this Scene
      Parameters:
      entity - Entities to add
      Returns:
      This Scene
    • removeEntity

      public Scene removeEntity​(Entity... entity)
      Remove Entities from this Scene
      Parameters:
      entity - Entities to remove
      Returns:
      This Scene
    • getCamera

      public Camera getCamera()
      Get the Camera for this Scene
      Returns:
      Scene's Camera
    • setCamera

      public Scene setCamera​(Camera camera)
      Give this Scene a different Camera
      Parameters:
      camera - New Camera
      Returns:
      This Scene
    • getBackground

      public Sprite getBackground()
      Get the background Sprite of the Scene
      Returns:
      Background Sprite of Scene
    • setBackground

      public Scene setBackground​(Sprite background)
      Set the background Sprite for the Scene
      Parameters:
      background - Background Sprite
      Returns:
      This Scene
    • addTickRunnable

      public Scene addTickRunnable​(java.lang.Runnable... runnable)
      Add Runnables to the tick loop for this Scene
      Parameters:
      runnable - Runnables
      Returns:
      This Scene
    • removeTickRunnable

      public Scene removeTickRunnable​(java.lang.Runnable... runnable)
      Remove Runnables from the tick loop for the Scene
      Parameters:
      runnable - Runnables
      Returns:
      This Scene
    • getTickRunnables

      public java.util.HashSet<java.lang.Runnable> getTickRunnables()
      Get all tick Runnables for the Scene
      Returns:
      All tick Runnables for the Scene
    • addRenderRunnable

      public Scene addRenderRunnable​(java.lang.Runnable... runnable)
      Add a Runnable to the render loop for this Scene
      Parameters:
      runnable - Runnable
      Returns:
      This Scene
    • removeRenderRunnable

      public Scene removeRenderRunnable​(java.lang.Runnable... runnable)
      Remove a Runnable from the render loop for the Scene
      Parameters:
      runnable - Runnable
      Returns:
      This Scene
    • getRenderRunnables

      public java.util.HashSet<java.lang.Runnable> getRenderRunnables()
      Get all render Runnables for the Scene
      Returns:
      All render Runnables for the Scene
    • getGridScale

      public Vector getGridScale()
      Get the Scene grid scale
      Returns:
      Grid scale for the Scene
    • setGridScale

      public Scene setGridScale​(Vector gridScale)
      Set a new grid scale for the Scene
      Parameters:
      gridScale - Grid scales
      Returns:
      This Scene
    • getSpeed

      public float getSpeed()
      Get the speed modifier of the Scene for physics and rendering
      Returns:
      Speed modifier
    • setSpeed

      public Scene setSpeed​(float speed)
      Set the speed modifier for the Scene for physics and rendering
      Parameters:
      speed - Speed modifier
      Returns:
      This Scene
    • equals

      public boolean equals​(java.lang.Object o)
      Check if a Scene is identical to this Scene
      Overrides:
      equals in class java.lang.Object
      Parameters:
      o - Scene to check
      Returns:
      True if the Scene is equal to this Scene