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.

jump impulse

Problem it solves

You want a platformer jump that reaches roughly the same height no matter how strong gravity is set to, instead of guessing a velocity by trial and error.

What this block does

Gives a sprite an instant upward velocity, calculated from its current gravity (acceleration y), so it jumps to approximately the given height in pixels.

The block

Block ID: spriteutiljumpimpulse

make $sprite jump $pixels pixels block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite to make jump
pixelsnumber34The approximate jump height

Example

let mySprite = sprites.create(img`.`, SpriteKind.Player)
let myEnemy = sprites.create(img`.`, SpriteKind.Enemy)
mySprite.ay = 200
spriteutils.jumpImpulse(mySprite, 34)

Add the extension

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