MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Retro FX

Add juicy 8-bit sound synthesizers, screen shakes, particle explosions, camera effects, and retro text displays to your games.

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

velocity variation from $velocity min $min max $max block

Parameters

NameTypeDefaultMeaning
velocitynumber50The velocity value to evaluate.
minnumber0The minimum allowed output value.
maxnumber100The 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.