Class FireParticleSystem.Particle

java.lang.Object
it.polimi.ingsw.gc14.View.GUI.FireParticleSystem.Particle
Enclosing class:
FireParticleSystem

private static class FireParticleSystem.Particle extends Object
A single fire particle with position, velocity, wobble, and JavaFX visual nodes. Particles are typed: 0 = ember, 1 = spark, 2 = dust.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final javafx.scene.shape.Circle
    Primary visible circle node.
    (package private) final javafx.scene.shape.Circle
    Soft glow halo circle behind core; non-null only for embers (type 0).
    (package private) double
    Remaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks.
    (package private) final Random
    Shared random source used during physics updates.
    (package private) final double
    Visual radius of the particle's core circle.
    (package private) final int
    Particle type: 0 = ember, 1 = spark, 2 = dust.
    (package private) double
    Horizontal velocity component.
    (package private) double
    Vertical velocity component.
    (package private) final double
    Amplitude factor of the wobble displacement.
    (package private) double
    Current phase of the sinusoidal wobble.
    (package private) final double
    Angular speed of the wobble oscillation.
    (package private) double
    Current X position in scene pixels.
    (package private) double
    Current Y position in scene pixels.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Particle(double x, double y, double w, double h, int corner, Random rnd)
    Initializes the particle at position (x, y) with velocity aimed roughly from the given corner toward the scene center.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    addTo(javafx.scene.layout.Pane pane)
    Adds this particle's visual nodes to pane (glow first so core renders on top).
    (package private) boolean
    isDead(double w, double h)
    Returns true when this particle has left the scene bounds or, for sparks, its life reached zero.
    (package private) void
    removeFrom(javafx.scene.layout.Pane pane)
    Removes this particle's visual nodes from pane.
    (package private) void
    Advances this particle by one physics step: applies wobble, moves, and decrements spark life.
    (package private) void
    updateVisual(double w, double h)
    Updates color, opacity, and translate position of this particle's visual nodes based on distance from scene edges and remaining life.
    private static int
    Returns a particle type weighted toward embers (55% ember, 23% spark, 22% dust).

    Methods inherited from class Object

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

    • x

      double x
      Current X position in scene pixels.
    • y

      double y
      Current Y position in scene pixels.
    • vx

      double vx
      Horizontal velocity component.
    • vy

      double vy
      Vertical velocity component.
    • life

      double life
      Remaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks.
    • size

      final double size
      Visual radius of the particle's core circle.
    • wobblePhase

      double wobblePhase
      Current phase of the sinusoidal wobble.
    • wobbleSpeed

      final double wobbleSpeed
      Angular speed of the wobble oscillation.
    • wobbleAmp

      final double wobbleAmp
      Amplitude factor of the wobble displacement.
    • type

      final int type
      Particle type: 0 = ember, 1 = spark, 2 = dust.
    • rnd

      final Random rnd
      Shared random source used during physics updates.
    • core

      final javafx.scene.shape.Circle core
      Primary visible circle node.
    • glow

      final javafx.scene.shape.Circle glow
      Soft glow halo circle behind core; non-null only for embers (type 0).
  • Constructor Details

    • Particle

      Particle(double x, double y, double w, double h, int corner, Random rnd)
      Initializes the particle at position (x, y) with velocity aimed roughly from the given corner toward the scene center.
      Parameters:
      x - spawn X coordinate.
      y - spawn Y coordinate.
      w - scene width (used to compute target direction).
      h - scene height (used to compute target direction).
      corner - spawn corner index: 0 = bottom-left, 1 = bottom-right, 2 = top-left, 3 = top-right.
      rnd - shared random source.
  • Method Details

    • weightedType

      private static int weightedType(Random rnd)
      Returns a particle type weighted toward embers (55% ember, 23% spark, 22% dust).
      Parameters:
      rnd - the random source.
      Returns:
      particle type: 0, 1, or 2.
    • addTo

      void addTo(javafx.scene.layout.Pane pane)
      Adds this particle's visual nodes to pane (glow first so core renders on top).
      Parameters:
      pane - the overlay pane to add nodes to.
    • removeFrom

      void removeFrom(javafx.scene.layout.Pane pane)
      Removes this particle's visual nodes from pane.
      Parameters:
      pane - the overlay pane to remove nodes from.
    • update

      void update()
      Advances this particle by one physics step: applies wobble, moves, and decrements spark life.
    • isDead

      boolean isDead(double w, double h)
      Returns true when this particle has left the scene bounds or, for sparks, its life reached zero.
      Parameters:
      w - scene width.
      h - scene height.
      Returns:
      true if the particle should be removed.
    • updateVisual

      void updateVisual(double w, double h)
      Updates color, opacity, and translate position of this particle's visual nodes based on distance from scene edges and remaining life.
      Parameters:
      w - scene width.
      h - scene height.