Class FireParticleSystem.Particle
java.lang.Object
it.polimi.ingsw.gc14.View.GUI.FireParticleSystem.Particle
- Enclosing class:
FireParticleSystem
A single fire particle with position, velocity, wobble, and JavaFX visual nodes.
Particles are typed: 0 = ember, 1 = spark, 2 = dust.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final javafx.scene.shape.CirclePrimary visible circle node.(package private) final javafx.scene.shape.CircleSoft glow halo circle behindcore; non-null only for embers (type 0).(package private) doubleRemaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks.(package private) final RandomShared random source used during physics updates.(package private) final doubleVisual radius of the particle's core circle.(package private) final intParticle type: 0 = ember, 1 = spark, 2 = dust.(package private) doubleHorizontal velocity component.(package private) doubleVertical velocity component.(package private) final doubleAmplitude factor of the wobble displacement.(package private) doubleCurrent phase of the sinusoidal wobble.(package private) final doubleAngular speed of the wobble oscillation.(package private) doubleCurrent X position in scene pixels.(package private) doubleCurrent Y position in scene pixels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddTo(javafx.scene.layout.Pane pane) Adds this particle's visual nodes topane(glow first so core renders on top).(package private) booleanisDead(double w, double h) Returnstruewhen this particle has left the scene bounds or, for sparks, its life reached zero.(package private) voidremoveFrom(javafx.scene.layout.Pane pane) Removes this particle's visual nodes frompane.(package private) voidupdate()Advances this particle by one physics step: applies wobble, moves, and decrements spark life.(package private) voidupdateVisual(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 intweightedType(Random rnd) Returns a particle type weighted toward embers (55% ember, 23% spark, 22% dust).
-
Field Details
-
x
double xCurrent X position in scene pixels. -
y
double yCurrent Y position in scene pixels. -
vx
double vxHorizontal velocity component. -
vy
double vyVertical velocity component. -
life
double lifeRemaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks. -
size
final double sizeVisual radius of the particle's core circle. -
wobblePhase
double wobblePhaseCurrent phase of the sinusoidal wobble. -
wobbleSpeed
final double wobbleSpeedAngular speed of the wobble oscillation. -
wobbleAmp
final double wobbleAmpAmplitude factor of the wobble displacement. -
type
final int typeParticle type: 0 = ember, 1 = spark, 2 = dust. -
rnd
Shared random source used during physics updates. -
core
final javafx.scene.shape.Circle corePrimary visible circle node. -
glow
final javafx.scene.shape.Circle glowSoft glow halo circle behindcore; 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 givencornertoward 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
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 topane(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 frompane.- 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) Returnstruewhen this particle has left the scene bounds or, for sparks, its life reached zero.- Parameters:
w- scene width.h- scene height.- Returns:
trueif 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.
-