class: Bomber
[51:7] extends: object
A bomber crosses the AGR FXGL window and drops a stick of bombs. Build one and call run(). The plane comes in off the left edge, flies level at a random height in the top half of the window, and leaves off the right. Somewhere in the left half it lets go of a short string of bombs. Each bomb takes half the plane's forward speed with it and falls under gravity, so it arcs away ahead of where it was dropped while the plane draws ahead of it, and bursts when it reaches the bottom of the window. The numbers at the top of the class are the dials. Change them to alter the flight, the bombs, or the blasts.
Members
- planeScale
- minFlightSeconds
- maxFlightSeconds
- minHeightFraction
- minBombs
- maxBombs
- minDropFraction
- maxDropFraction
- bombSpacing
- minCarry
- maxCarry
- bombSpeedShare
- bombLength
- bombThickness
- bombFin
- bombColor
- blastSpeed
- blastSparks
- minSparkSize
- maxSparkSize
- blastSeconds
- blastColors
- picturePaths
- bombs
- dropped
- nextDrop
- nextBlast
- bodyX
- bodyY
- finX
Methods
-
run ()
Flies the plane across the window and drops its bombs on the way. The plane, the bombs, and the blasts all clear themselves out of the game world when they are done. Only works inside AGR, which has the FXGL game already running.
- @r
Entity- the plane, already attached to the game world.
- @r
-
dropNext ()
Lets go of the next bomb on the list. The timer calls this once per bomb, so each call takes the next one along.
- @r
thisobject
- @r
-
blastNext ()
Lands the next bomb: takes it out of the world and sets off a blast where it came down. The timer calls this once per bomb, a fall's worth of time after the matching drop.
- @r
thisobject
- @r
-
sparkLife (
Index)FXGL asks how long each spark should burn as it spawns it.
- @p
Indexis the spark's number within the blast. - @r
AJavaFX Duration.
- @p
-
findPicture ()
Returns the first path in picturePaths that exists.
- @r
string- the path to the picture file.
- @r
-
planStick (
double Width, double Height, double BayX, double DropY, double Speed)Works out the whole stick of bombs and puts it on timers: when each one is let go, where it lands, and how hard gravity has to pull to bring it down there. The arithmetic runs backwards from the landing. The room ahead of the stick, measured at the plane's speed, gives the fall time; the bombs cross their own share of that room in the same time; and a drop of
Depthpixels in that time needs a pull of 2 x Depth / time squared.- @p
Widthis the window width in pixels. - @p
Heightis the window height in pixels. - @p
BayXis where the bomb bay sits at the moment the plane spawns. - @p
DropYis the height the bombs leave the plane at, in pixels. - @p
Speedis the plane's speed in pixels per second. - @r
thisobject
- @p
-
buildBomb ()
Builds a bomb's look: a rounded body at the local origin with a fin behind it. The projectile component turns the entity to face the way it is travelling, which points local +X forward, so the fin stays at the back the whole way down.
- @r
Group- the bomb's view node.
- @r
-
blast (
double X, double Y)Sets off one blast: a ring of sparks in a single colour that fades out. The sparks belong to the emitter, so the entity only has to outlive the longest burning one.
- @p
Xis the blast's horizontal position in pixels. - @p
Yis the blast's vertical position in pixels. - @r
Entity- the blast, already attached to the game world.
- @p