MediumGetting Characters Moving in Microsoft MakeCode Arcade | by Kiki Prottsman | Kiki’s Corner | Medium
Sitemap
Kiki’s Corner

Whether you’re a student or a teacher, a beginner or expert, drop by weekly to find new tips, suggestions, and challenges!

Getting Characters Moving in Microsoft MakeCode Arcade

6 min readDec 2, 2024

--

If you’re new to Microsoft MakeCode Arcade, you may not have had a chance to investigate all of the different ways you can get sprites moving. This post will help you learn about some of the most common.

Move with Arrow Keys

Definitely one of our most popular methods, moving a character (aka sprite) around with the arrow keys is useful in many situations.

To make this happen, simply connect the move [mySprite] with buttons block BENEATH the block where you define your sprite.

Note: If you accidentally place the move block above the set block, the computer won’t know what you’re talking about yet, and you’ll get an error.

Nuther Note: Make sure that the name selected in the move block is the same as the name you gave your sprite in the set block or the computer won’t know what to move.

The d-pad on the game window, arrow keys on your keyboard, and the w,a,s,d keys on your keyboard should all now successfully move your sprite in the proper directions.

If you want to limit the directions that your sprite can move, click the + sign to the right of the block to extend the options.

Extended `move` block

Now you can choose how fast the sprite moves horizontally and/or vertically. Setting either of these to 0 will keep the sprite from moving in that direction altogether.

Moving in Multiplayer

Do you have multiple players that need to be moved around by different players’ arrow keys? You can either use this block from the Controller category…

…or one of these from the Multiplayer extension.

Follow Another Sprite

Sometimes, like with enemies or dummy players, you may want your sprite to follow another character that’s already on the screen. This block makes that very simple.

However, you’ll notice that the following sprite stays pretty close on top of the main player very quickly. I like to slow the following sprite down a little to give the characters some space.

To do that, click the + at the right of the block, and change the speed to a lower number.

Move Continuously

Maybe you want your sprite to be always moving forward. This can be accomplished one of two ways.

  1. Scroll your background to make it look like the sprite is moving
  2. Add horizontal acceleration to keep the sprite constantly moving

Scrolling Background

We use this trick in tutorials like Save the Baby Dino. By adding the arcade-background-scroll extension, you get access to this block

Which sets the background moving, making it look like your character is on a leisurely stroll.

Get Kiki Prottsman’s stories in your inbox

Join Medium for free to get updates from this writer.

Note: In order to use this block, you’ll need to add a background first or you won’t notice any change.

Horizontal Acceleration

When you want your character to actually move through the world you’ve created (particularly if you’ve set up a tilemap) then you may want to use acceleration. To set your character moving to the right, you’ll want to drag out one of these blocks

Then change the dropdown so that it’s showing ax (acceleration x) along with a positive number. A negative number will send the character off to the left.

Note: Don’t forget to instruct the camera to follow your sprite, or else your characters will dash off screen and you’ll never see them again!

Move with Gravity

Similarly, you may want your character to float or fall. This uses the same method as before, except you’re setting the ay (acceleration y).

Setting a positive number will pull down on your sprite, while a negative number will push it up.

Note: If you have the camera set to follow your sprite and you don’t have a tilemap showing, you might not notice that your sprite is falling. If you get in this situation, try removing the camera follow sprite block and see if the character drops off screen.

Move Against Gravity

Sometimes, you need to temporarily defy gravity — like when you’re jumping. To do this, use the same block as before, but change the dropdown to vy (velocity y).

Then set the number to something less than what your acceleration is set to. This will give your character a temporary boost and make it look like they’re jumping.

Teleport

Would you like your sprite to move very long distances in the blink of an eye? Then teleportation may be for you!

This trick is generally done by detecting an overlap between the character and a certain tile on the tilemap, but it could be done when the character overlaps with some other sprite, as well. We’ll move forward with the tile example.

In this case, we want the character to teleport when they get to the bubble, so we’ll start with this container:

Once that happens, we want the character to be placed on top of the treasure box tile, like so.

Ta da! Teleportation.

Note: Since there is no place [mySprite] on top of specific [] block, you’ll need to note that one of two things might be true:

  1. There should be only ONE tile of the type you want your character to land on
  2. Your character could show up on one of a few spots after teleportation

Both options have their place, you just need to decide which is right for you.

Destroy

Finally, vanishing is a type of movement, isn’t it?

If you get to the place where you want your character to cease to exist, use the destroy mySprite block. This will take the character out of the game entirely.

And that is my magnum opus about moving sprites. Hopefully you learned something.

Do you have something you want to teach *me* about moving sprites? Leave me a comment!

--

Kiki Prottsman
Kiki Prottsman

Written by Kiki Prottsman

Kiki is an author, educator, and the Director of Education for Microsoft MakeCode

Kiki’s Corner
Kiki’s Corner

Published in Kiki’s Corner

Whether you’re a student or a teacher, a beginner or expert, drop by weekly to find new tips, suggestions, and challenges!