Package xyz.jeremynoesen.pseudo3d.core
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 SceneScene(java.util.LinkedList<Entity> entities, Camera camera, Sprite background, Vector gridScale)
Create a new Scene with pre-defined Entities, Camera, background Sprite, and grid scaleScene(Scene scene)
Copy constructor for Scene -
Method Summary
Modifier and Type Method Description Scene
addEntity(Entity... entity)
Add Entities to this SceneScene
addRenderRunnable(java.lang.Runnable... runnable)
Add a Runnable to the render loop for this SceneScene
addTickRunnable(java.lang.Runnable... runnable)
Add Runnables to the tick loop for this Sceneboolean
equals(java.lang.Object o)
Check if a Scene is identical to this SceneSprite
getBackground()
Get the background Sprite of the SceneCamera
getCamera()
Get the Camera for this Scenejava.util.LinkedList<Entity>
getEntities()
Get all the Entities in this Scene
Modifying this directly will cause problemsVector
getGridScale()
Get the Scene grid scalejava.util.HashSet<java.lang.Runnable>
getRenderRunnables()
Get all render Runnables for the Scenefloat
getSpeed()
Get the speed modifier of the Scene for physics and renderingjava.util.HashSet<java.lang.Runnable>
getTickRunnables()
Get all tick Runnables for the SceneScene
removeEntity(Entity... entity)
Remove Entities from this SceneScene
removeRenderRunnable(java.lang.Runnable... runnable)
Remove a Runnable from the render loop for the SceneScene
removeTickRunnable(java.lang.Runnable... runnable)
Remove Runnables from the tick loop for the Scenevoid
render(javafx.scene.canvas.GraphicsContext graphicsContext, float deltaTime)
Render this Scene to the main Canvas, as well as run any RunnablesScene
setBackground(Sprite background)
Set the background Sprite for the SceneScene
setCamera(Camera camera)
Give this Scene a different CameraScene
setGridScale(Vector gridScale)
Set a new grid scale for the SceneScene
setSpeed(float speed)
Set the speed modifier for the Scene for physics and renderingvoid
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 EntitiesMethods 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 Scenecamera
- Scene Camerabackground
- Background SpritegridScale
- Scene grid scale
-
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 todeltaTime
- How long the previous render took in seconds
-
getEntities
Get all the Entities in this Scene
Modifying this directly will cause problems- Returns:
- List of all Entities in this Scene
-
addEntity
Add Entities to this Scene- Parameters:
entity
- Entities to add- Returns:
- This Scene
-
removeEntity
Remove Entities from this Scene- Parameters:
entity
- Entities to remove- Returns:
- This Scene
-
getCamera
Get the Camera for this Scene- Returns:
- Scene's Camera
-
setCamera
Give this Scene a different Camera- Parameters:
camera
- New Camera- Returns:
- This Scene
-
getBackground
Get the background Sprite of the Scene- Returns:
- Background Sprite of Scene
-
setBackground
Set the background Sprite for the Scene- Parameters:
background
- Background Sprite- Returns:
- This Scene
-
addTickRunnable
Add Runnables to the tick loop for this Scene- Parameters:
runnable
- Runnables- Returns:
- This Scene
-
removeTickRunnable
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
Add a Runnable to the render loop for this Scene- Parameters:
runnable
- Runnable- Returns:
- This Scene
-
removeRenderRunnable
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
Get the Scene grid scale- Returns:
- Grid scale for the Scene
-
setGridScale
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
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 classjava.lang.Object
- Parameters:
o
- Scene to check- Returns:
- True if the Scene is equal to this Scene
-