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 SceneaddEntity(Entity... entity)Add Entities to this SceneSceneaddRenderRunnable(java.lang.Runnable... runnable)Add a Runnable to the render loop for this SceneSceneaddTickRunnable(java.lang.Runnable... runnable)Add Runnables to the tick loop for this Scenebooleanequals(java.lang.Object o)Check if a Scene is identical to this SceneSpritegetBackground()Get the background Sprite of the SceneCameragetCamera()Get the Camera for this Scenejava.util.LinkedList<Entity>getEntities()Get all the Entities in this Scene
Modifying this directly will cause problemsVectorgetGridScale()Get the Scene grid scalejava.util.HashSet<java.lang.Runnable>getRenderRunnables()Get all render Runnables for the ScenefloatgetSpeed()Get the speed modifier of the Scene for physics and renderingjava.util.HashSet<java.lang.Runnable>getTickRunnables()Get all tick Runnables for the SceneSceneremoveEntity(Entity... entity)Remove Entities from this SceneSceneremoveRenderRunnable(java.lang.Runnable... runnable)Remove a Runnable from the render loop for the SceneSceneremoveTickRunnable(java.lang.Runnable... runnable)Remove Runnables from the tick loop for the Scenevoidrender(javafx.scene.canvas.GraphicsContext graphicsContext, float deltaTime)Render this Scene to the main Canvas, as well as run any RunnablesScenesetBackground(Sprite background)Set the background Sprite for the SceneScenesetCamera(Camera camera)Give this Scene a different CameraScenesetGridScale(Vector gridScale)Set a new grid scale for the SceneScenesetSpeed(float speed)Set the speed modifier for the Scene for physics and renderingvoidtick(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:
equalsin classjava.lang.Object- Parameters:
o- Scene to check- Returns:
- True if the Scene is equal to this Scene
-