velocity variation
Problem it solves
You want particle effects or sound pitches to scale with how fast your character is moving.
What this block does
Takes a sprite velocity value, converts it to an absolute speed, and clamps it within a minimum and maximum range.
The block
Block ID: retro_velocity_variation
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| velocity | number | 50 | The velocity value to evaluate. |
| min | number | 0 | The minimum allowed output value. |
| max | number | 100 | The maximum allowed output value. |
Returns
number — The absolute speed value clamped between min and max.
Example
let hero = sprites.create(img`.`, SpriteKind.Player) let speedFactor = Retro.velocityVariation(hero.vx, 10, 100) console.log(speedFactor)
Add the extension
Add github:CrzLe0723/RetroFx to your project, or open: Import RetroFx.