earwax.rumble_effects module¶
Provides various rumble effect classes.
Please note:
When we talk about a rumble value, we mean a value from 0.0
(nothing),
to 1.0
(full on).
In reality, values on the lower end can barely be felt with some controllers.
-
class
earwax.rumble_effects.
RumbleEffect
(start_value: float, increase_interval: float, increase_value: float, peak_duration: float, peak_value: float, decrease_interval: float, decrease_value: float, end_value: float)¶ Bases:
object
A rumble effect.
Instances of this class create rumble “waves”, with a start, a climb in effect to an eventual peak, then, after some time at the peak, a gradual drop back to stillness.
For example, you could have an effect that started at 0.5 (half power), then climbed in increments of 0.1 every 10th of a second to a peak value of 1.0 (full power), then stayed there for 1 second, before reducing back down to 0.7 (70% power), with 0.1 decrements every 0.2 seconds.
The code for this effect would be:
effect: RumbleEffect = RumbleEffect( 0.5, # start_value 0.1, # increase_interval 0.1, # increase_value 1., # peak_duration 1.0, # peak_value 0.2, # decrease_interval 0.1, # decrease_value 0.7, # end_value )
The
start()
method returns an instance ofStaggeredPromise
. This gives you the ability to save your effect, then use it at will:effect: RumbleEffect = RumbleEffect( 0.2, # start_value 0.3, # increase_interval 0.1, # increase_value 1.5, # peak_duration 1.0, # peak_value 0.3, # decrease_interval 0.1, # decrease_value 0.1, # end_value ) # ... promise: StaggeredPromise = effect.start(game, 0) promise.run()
Variables: - start_value – The initial rumble value.
- increase_interval – How many seconds should elapse between each increase.
- increase_value – How much should be added to the rumble value each increase.
- peak_duration – How many seconds the
peak_value
rumble should be felt. - peak_value – The highest rumble value this effect will achieve.
- decrease_interval – The number of seconds between decreases.
- decrease_value – How much should be subtracted from the rumble value each decrease.
- end_value – The last value that will be felt.
-
start
(game: Game, joystick: pyglet.input.base.Joystick) → earwax.promises.staggered_promise.StaggeredPromise¶ Start this effect.
Parameters: - game – The game which will provide the
start_rumble()
, andstop_rumble()
methods. - joystick – The joystick to rumble.
- game – The game which will provide the
-
class
earwax.rumble_effects.
RumbleSequence
(lines: List[earwax.rumble_effects.RumbleSequenceLine])¶ Bases:
object
A sequence of rumbles.
Variables: lines – A list of rumble lines that make up effect. -
start
(game: Game, joystick: pyglet.input.base.Joystick) → earwax.promises.staggered_promise.StaggeredPromise¶ Start this effect.
Parameters: - game – The game which will provide the
start_rumble()
, andstop_rumble()
methods. - joystick – The joystick to rumble.
- game – The game which will provide the
-
-
class
earwax.rumble_effects.
RumbleSequenceLine
(power: float, duration: int, after: Optional[float])¶ Bases:
object
A line of rumble.
This class should be used in conjunction with the
RumbleSequence
class.Variables: - power – The power of the rumble.
- duration – The duration of the rumble.
- after –
The time to wait before proceeding to the next line.
If this value is
None
, then no time will elapse.Set this value to
None
for the last line in the sequence, to avoid the promise suspending unnecessarily.