Class FireParticleSystem

java.lang.Object
it.polimi.ingsw.gc14.View.GUI.FireParticleSystem

public class FireParticleSystem extends Object
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.

Call start() after adding getPane() to the scene graph

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    A single fire particle with position, velocity, wobble, and JavaFX visual nodes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    Minimum nanoseconds between rendered frames (30 fps cap).
    private long
    Timestamp (ns) of the last rendered frame.
    private long
    Timestamp (ns) of the last particle spawn batch.
    private static final int
    Maximum number of live particles at any given time.
    private final javafx.scene.layout.Pane
    Mouse-transparent overlay pane that hosts all particle nodes.
    Currently live particles.
    private final Random
    Shared random source for particle initialization and physics noise.
    private final javafx.scene.Scene
    The scene whose dimensions are used to position and fade particles.
    private static final long
    Minimum nanoseconds between particle spawn batches.
    private static final int
    Physics update steps applied per rendered frame (multiplies effective speed).
    private boolean
    true after the first tick pre-populates the particle pool.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FireParticleSystem(javafx.scene.Scene scene)
    Creates the particle system bound to the given scene.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.scene.layout.Pane
    Returns the transparent overlay pane that holds all particle nodes.
    spawnParticle(double w, double h)
    Creates a new particle starting near one of the four screen corners.
    void
    Starts the animation timer.
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_PARTICLES

      private static final int MAX_PARTICLES
      Maximum number of live particles at any given time.
      See Also:
    • SPAWN_INTERVAL_NS

      private static final long SPAWN_INTERVAL_NS
      Minimum nanoseconds between particle spawn batches.
      See Also:
    • FRAME_INTERVAL_NS

      private static final long FRAME_INTERVAL_NS
      Minimum nanoseconds between rendered frames (30 fps cap).
      See Also:
    • STEPS_PER_FRAME

      private static final int STEPS_PER_FRAME
      Physics update steps applied per rendered frame (multiplies effective speed).
      See Also:
    • pane

      private final javafx.scene.layout.Pane pane
      Mouse-transparent overlay pane that hosts all particle nodes.
    • scene

      private final javafx.scene.Scene scene
      The scene whose dimensions are used to position and fade particles.
    • particles

      private final List<FireParticleSystem.Particle> particles
      Currently live particles.
    • rnd

      private final Random rnd
      Shared random source for particle initialization and physics noise.
    • lastSpawn

      private long lastSpawn
      Timestamp (ns) of the last particle spawn batch.
    • lastFrame

      private long lastFrame
      Timestamp (ns) of the last rendered frame.
    • warmedUp

      private boolean warmedUp
      true after 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 Pane overlay.
    • 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

      private FireParticleSystem.Particle spawnParticle(double w, double h)
      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.