You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// DESIGN: A `resetAccelerationWhenChangingDirection` is probably not needed because the inertia and friction of the physics body should take care of that anyway, right?
@@ -30,77 +34,102 @@ public final class KeyboardControlledThrustComponent: OctopusComponent, OctopusU
30
34
/// Change this to a different code to customize the keys.
31
35
publicvararrowDown:UInt16=.arrowDown
32
36
33
-
publicvarbaseMagnitudePerSecond:CGFloat
34
-
publicvarmaximumMagnitudePerSecond:CGFloat
35
-
publicvaracceleratedMagnitude:CGFloat=0
36
-
37
-
/// The amount to increase `acceleratedMagnitude` by per second, while there is keyboard input. `acceleratedMagnitude` is reset to `baseMagnitudePerSecond` when there is no keyboard input.
38
-
publicvaraccelerationPerSecond:CGFloat
37
+
/// The amount of thrust to apply in a single update, with optional acceleration. Affected by `timestep`. Reset when there is no keyboard input.
/// Multiplies the force by the specified value. Default: `1`. To reverse the thrust, specify a negative value like `-1`. To disable thrust, specify `0`.
41
-
publicvarfactor:CGFloat=1
41
+
publicvarscalingFactor:CGFloat=1
42
+
43
+
/// Specifies a fixed or variable timestep for per-update changes.
44
+
publicvartimestep:TimeStep
42
45
43
46
/// - Parameters:
44
-
/// - baseMagnitudePerSecond: The minimum magnitude to apply to the physics body every second.
45
-
/// - maximumMagnitudePerSecond: The maximum magnitude to allow after acceleration has been applied.
46
-
/// - accelerationPerSecond: The amount to increase the magnitude by per second, while there is keyboard input. The magnitude is reset to the `baseMagnitudePerSecond` when there is no keyboard input.
47
-
/// - factor: Multiply the force by this factor. Default: `1`. To reverse the thrust, specify a negative value like `-1`. To disable thrust, specify `0`.
48
-
publicinit(baseMagnitudePerSecond:CGFloat=600, // ÷ 60 = 10 per frame
49
-
maximumMagnitudePerSecond:CGFloat=1200, // ÷ 60 = 20 per frame
50
-
accelerationPerSecond:CGFloat=600,
51
-
factor:CGFloat=1)
47
+
/// - magnitudePerUpdate: The amount of thrust to apply every update, with optional acceleration. Affected by `timestep`.
48
+
/// - scalingFactor: Multiplies the force by the specified factor. Default: `1`. To reverse the thrust, specify a negative value like `-1`. To disable thrust, specify `0`.
49
+
/// - timestep: Specifies a fixed or variable timestep for per-update changes. Default: `.perSecond`
/// - magnitudePerUpdate: The minimum magnitude to apply to the physics body every second. Affected by `timestep`.
62
+
/// - acceleration: The amount to increase the magnitude by per second, while there is keyboard input. The magnitude is reset to the `baseMagnitudePerSecond` when there is no keyboard input. Affected by `timestep`.
63
+
/// - maximum: The maximum magnitude to allow after acceleration has been applied.
64
+
/// - scalingFactor: Multiplies the force by the specified factor. Default: `1`. To reverse the thrust, specify a negative value like `-1`. To disable thrust, specify `0`.
65
+
/// - timestep: Specifies a fixed or variable timestep for per-update changes. Default: `.perSecond`
66
+
publicconvenienceinit(magnitudePerUpdate:CGFloat=600, // ÷ 60 = 10 per frame
0 commit comments