ENTRY | DOWNLOAD | MANUAL | ONGOING | |
ThrustThrust is closest to the concept of impulse. When a sprite is pushed in that fashion it keeps moving/rotating (or scaling, although the real world analogy lacks here) until the thrust changes. The simplest form of thrust leads to a constant transformation. Other forms of thrust change over time. With these, one can implement effects of drag or propulsion.
Slut currently defines the following thrust classes:
Since thrusts are carried out indefinitely one may very likely
want to cancel thrusts at some point:
cancelThrustMoves() cancelThrustRots() cancelThrustOrbits() cancelThrustScales() Relevant examples: thrust.py , thrust_all.py , thrust_sine.py , solarsystem.py , ALL In Contextspriteobject.moveBy(Thrust(0.1, 0.0, 0.0)) spriteobject.rotBy(Thrust(0.0, 360.0, 0.0)) Both of the above thrust transformations utilize the standard Thrust class which leads to a linear transformation. No acceleration or deceleration will occur. By using a different thrust class this behavior can change. spriteobject.moveBy(SineThrust(0.1, 0.0, 0.0)) spriteobject.rotBy(SineThrust(0.0, 360.0, 0.0)) Now the same two thrusts will accelerate, decelerate, accelerate backwards, decelerate, accelerate forward and keep going back and forth according to a sine wave.
Since transformation and thrust are separated, one can easily define new thrusts that are applicable to all transformations. Creating a custom thrust is a matter of defining a class that inherits from slut.element.Thrust and overwrites the thrustfunc() method. class RedundantLinearThrust(Thrust): def thrustfunc(self, change): return change/glo.fps Cancel methods are called on the element (sprite or tag) which exhibits the thrust. To cancel all thrust movements of spriteobject, for example, one would write the following line: spriteobject.cancelThrustMoves() |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |