MakeCode Games!

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

← Back to extensions

Sprite Utils

A grab-bag of sprite math and rendering helpers for MakeCode Arcade: distances, angles, movement, timers, and simple drawing.

round with precision

Problem it solves

You want to show a score or measurement with a fixed number of decimal places (like "3.14") instead of a long, messy decimal.

What this block does

Rounds a number to a given number of digits after the decimal point and returns it as text.

The block

Block ID: spriteutilextroundwithprecision

round $x to $digitsAfterDecimal decimal places block

Parameters

NameTypeDefaultMeaning
xnumber3.14159The number to round
digitsAfterDecimalnumber2How many decimal digits to keep

Returns

stringThe rounded value, formatted with the requested number of digits.

Example

let rounded = spriteutils.roundWithPrecision(3.14159, 2)
console.log(rounded)

Add the extension

Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.