Class FireParticleSystem
java.lang.Object
it.polimi.ingsw.gc14.View.GUI.FireParticleSystem
Ambient fire-particle effect rendered on a transparent overlay pane.
Three particle types float from the screen corners toward the center:
- embers (type 0) — slow, glowing orange circles with a soft halo.
- sparks (type 1) — fast, short-lived bright particles.
- dust (type 2) — large, translucent brown drifting circles.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA single fire particle with position, velocity, wobble, and JavaFX visual nodes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longMinimum nanoseconds between rendered frames (30 fps cap).private longTimestamp (ns) of the last rendered frame.private longTimestamp (ns) of the last particle spawn batch.private static final intMaximum number of live particles at any given time.private final javafx.scene.layout.PaneMouse-transparent overlay pane that hosts all particle nodes.private final List<FireParticleSystem.Particle> Currently live particles.private final RandomShared random source for particle initialization and physics noise.private final javafx.scene.SceneThe scene whose dimensions are used to position and fade particles.private static final longMinimum nanoseconds between particle spawn batches.private static final intPhysics update steps applied per rendered frame (multiplies effective speed).private booleantrueafter the first tick pre-populates the particle pool. -
Constructor Summary
ConstructorsConstructorDescriptionFireParticleSystem(javafx.scene.Scene scene) Creates the particle system bound to the given scene. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.layout.PanegetPane()Returns the transparent overlay pane that holds all particle nodes.private FireParticleSystem.ParticlespawnParticle(double w, double h) Creates a new particle starting near one of the four screen corners.voidstart()Starts the animation timer.private voidtick(long now) Advances the simulation by one frame: pre-warms on first call, spawns new particles, steps existing ones, removes dead ones, and updates their visual state.
-
Field Details
-
MAX_PARTICLES
private static final int MAX_PARTICLESMaximum number of live particles at any given time.- See Also:
-
SPAWN_INTERVAL_NS
private static final long SPAWN_INTERVAL_NSMinimum nanoseconds between particle spawn batches.- See Also:
-
FRAME_INTERVAL_NS
private static final long FRAME_INTERVAL_NSMinimum nanoseconds between rendered frames (30 fps cap).- See Also:
-
STEPS_PER_FRAME
private static final int STEPS_PER_FRAMEPhysics update steps applied per rendered frame (multiplies effective speed).- See Also:
-
pane
private final javafx.scene.layout.Pane paneMouse-transparent overlay pane that hosts all particle nodes. -
scene
private final javafx.scene.Scene sceneThe scene whose dimensions are used to position and fade particles. -
particles
Currently live particles. -
rnd
Shared random source for particle initialization and physics noise. -
lastSpawn
private long lastSpawnTimestamp (ns) of the last particle spawn batch. -
lastFrame
private long lastFrameTimestamp (ns) of the last rendered frame. -
warmedUp
private boolean warmedUptrueafter the first tick pre-populates the particle pool.
-
-
Constructor Details
-
FireParticleSystem
public FireParticleSystem(javafx.scene.Scene scene) Creates the particle system bound to the given scene. The internal overlay pane is transparent and mouse-transparent.- Parameters:
scene- the scene whose dimensions are used for particle positioning and fading.
-
-
Method Details
-
getPane
public javafx.scene.layout.Pane getPane()Returns the transparent overlay pane that holds all particle nodes.- Returns:
- the mouse-transparent
Paneoverlay.
-
start
public void start()Starts the animation timer. -
tick
private void tick(long now) Advances the simulation by one frame: pre-warms on first call, spawns new particles, steps existing ones, removes dead ones, and updates their visual state.- Parameters:
now- the current timestamp in nanoseconds from the animation timer.
-
spawnParticle
Creates a new particle starting near one of the four screen corners.- Parameters:
w- scene width in pixels.h- scene height in pixels.- Returns:
- the newly constructed
FireParticleSystem.Particle.
-