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.

velocity angle

Problem it solves

You want to rotate a sprite's image to face the direction it's actually moving, but you only have its velocity.

What this block does

Returns the angle of a sprite's current movement, in radians.

The block

Block ID: spriteutilheading

$sprite velocity angle block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite to check

Returns

numberThe angle of movement in radians.

Example

let mySprite = sprites.create(img`.`, SpriteKind.Player)
let myEnemy = sprites.create(img`.`, SpriteKind.Enemy)
let direction = spriteutils.heading(mySprite)
console.log(direction)

Add the extension

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