Flipper
namespace Griff.Modules.PhysicsGames;
public sealed class Flipper : Component, IPlaytestReportA pinball flipper, with no code: a paddle on a HingeJoint that snaps up while its button is held and drops back as it’s let go, hitting the ball hard and the same every time. How far it swings is its hinge’s limits (it rests against one and swings up to the other; a hinge without limits is given its side’s, resting as it starts and swinging 55 degrees up); how fast and how hard are its Speed and Strength. Its body rotates, and should be heavier than the ball (Entity > Genres > Physics Games > Flippers makes a pair).
It’s held up by its Action (Left Flipper: Left Shift, Z, the left shoulder or trigger; Right Flipper: Right Shift, /, the right shoulder or trigger), by the mouse or a finger held down on its side of the flippers, by a switch or a wire into its Power, or for a moment by its Flip action. A Tilt that has tilted drops it and keeps it down until the ball drains. A fast ball doesn’t go through it: the game works out where the two will meet within each step.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Action
Section titled “Action”public string? Action { get; set; }The input action that holds it up. Empty: Left Flipper or Right Flipper by its Side (Left or Right Shift, Z or /, a shoulder or trigger of the gamepad).
Controllable
Section titled “Controllable”public bool Controllable { get; set; }Untick it to have it ignore the keys, mouse and gamepad (its actions, a wire and scripts still work): another part of the scene has the player’s input. Its Focus action ticks it and unticks it on everything else the player plays.
FlipFor
Section titled “FlipFor”public float FlipFor { get; set; }Seconds its Flip action still holds it up. Set by the game.
public int Flips { get; set; }How many times it has swung up.
InputAction
Section titled “InputAction”public string InputAction { get; }The input action that holds it up: its Action, or Left Flipper or Right Flipper by its side.
Message
Section titled “Message”public string? Message { get; set; }A message sent with Game.Send as it swings up, with the flipper as its data, e.g. “Flipped”.
Pressed
Section titled “Pressed”public bool Pressed { get; set; }True while its button (the keys, the mouse, a finger) is held down. Set by the game.
Raised
Section titled “Raised”public bool Raised { get; set; }Held up by a switch or a wire into its Power (or a script), whatever the buttons say.
public FlipperSide Side { get; set; }Which way it swings up: Left (a flipper pointing right, swinging up anticlockwise) or Right.
public string? Sound { get; set; }A sound played as it swings up, e.g. “Sounds/flip.wav”.
public float Speed { get; set; }How fast it swings, in degrees a second, up as it’s pressed and down as it’s let go: 2,000 snaps it up in a few hundredths of a second, as a real flipper does.
Strength
Section titled “Strength”public float Strength { get; set; }How hard it swings (the most its hinge’s motor turns it with): enough to hold the ball cradled on it, and to hit it as hard each time whatever it was doing. Lower, a heavy ball slows it down.
public bool Touch { get; set; }The mouse button or a finger held down on its side of the flippers (left of the middle between them, for one on the left) holds it up too: on a phone, a finger on the left of the screen flips the left flipper, and a finger on each side holds both up.
public bool Up { get; set; }True while it’s swinging up or held up: pressed, powered or flipped, and not tilted. Set by the game.
Methods
Section titled “Methods”public void Flip()Swings it up for a moment and lets it drop: a flipper a Trigger, a wire or the beat flips.
public void Lower()Lets it drop, held up by its Raise action or a wire no longer.
public void Raise()Holds it up until its Lower action (or until it’s tilted).
public override bool Uses(string property)Events
Section titled “Events”Flipped
Section titled “Flipped”public event Action<Flipper>? FlippedRaised as it swings up.