Using Projectiles in MakeCode Arcade

Kiki Prottsman
Kiki’s Corner
Published in
3 min readJul 18, 2022
This game uses projectiles in a couple of different ways

What are Projectiles?

In MakeCode Arcade, projectiles are specific types of sprites that are given additional properties based on the assumption that they are generated in mass quantities and won’t need to be shown on the screen for long periods of time.

How do I use Projectiles in a game?

In most cases, you will use one or more of these specific blocks for creating projectiles in your game.

Projectiles from Side

This block sends a projectile in from whichever side is opposite the given velocity (vx, vy)

The projectile creation block shown above is used heavily in our tutorials and skillmaps. It’s fantastic for items that should be coming in from off-screen, as each projectile will spawn at the opposite edge from the direction it is heading.

Projectiles from Sprite

This block sends a projectile out from the center of a sprite with velocity (vx, vy)

This second projectile creation block is great for “shooting” or “throwing” items from a player or an enemy. This block will spawn the projectile at the center of the sprite that you define with movement directed by the vx and vy that you specify.

Keep in mind that either block will only spawn a single projectile. To create several, you’ll want to have your block inside of a loop or repeating event.

The velocity you set in either case will determine the direction that the projectile flies:

Projectile Collisions

Projectiles really become useful once you pair them with overlap events. These allow you to accrue points or lose lives when your character and a projectile collide. You can also use overlap events to break or change tiles when projectiles collide with tilemap elements.

One important thing to remember is that you must immediately destroy the exact projectile that overlapped the item, or else your overlap event will trigger several times in quick succession.

To make sure you’re destroying the exact projectile that overlapped your item (especially difficult since all of your projectiles have the same name) you’ll need to use the variable values provided in the title of the overlap event…like so:

And that’s all you need to know to begin implementing projectiles in MakeCode Arcade!

Is there anything else you’d like to know when it comes to projectiles? Drop me a note in the comments and I’ll see what I can do.

--

--

Kiki Prottsman
Kiki’s Corner

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