Use MakeCode Arcade to teach coding and computer science concepts

Completed

MakeCode Arcade provides students the opportunity to learn how to code in blocks, JavaScript, and Python. Through its scaffolded and guided progression, students can follow the skillmaps to develop their coding skills over time.

The Beginner’s Guide to Arcade Games introduces the most common types of code blocks used in MakeCode Arcade.

In this set of activities, students create their first set of digital games with MakeCode Arcade. This guide is intended for students who are new to MakeCode with little or no previous coding experience. Through step-by-step instructions, students focus on projects from three different categories: Storytelling, Clicker Games, and Collector Games.

Designed for students ages 11-15, this experience contains a total of 11 tutorials (approximating 145 minutes of instruction) spread over five sessions.

After completing the Beginner’s Guide to Arcade Games, students will have gained exposure to all the elements needed to successfully create arcade games using MakeCode Arcade.

Specifically, students experience these computer science concepts:

  • Events

  • User input

  • Loops

  • Variables

  • Program control flow

Events

Event blocks are used to sense events, which trigger your code to run. The event block is what will run the program. There are two common event blocks in MakeCode Arcade.

First, there's the On Start block. On start is a special event that runs when the program starts, before any other event.

Screenshot of On Start coding block.

Next, is the On Event block. On event will run some code when a button is pressed or released. In this example, the on \[A\] button \[pressed\] will cause the event to happen.

Screenshot of On Event coding block with the code: "on A button pressed".

User input

Accepting user input in games is a great way to make interactive games, such as players naming their virtual characters or responding to questions posed by the game! Players are presented with a virtual keyboard to respond to questions or prompts.

The ask for string with text block adds this interactive element to your games.

Screenshot of the "ask for" string with text coding block.

If you're interested in learning more about user input and finding student activities around user input, this resource will help.

Loops

Loops are a programming element that repeats a portion of code a set number of times until the desired process is complete. Repetitive tasks are common in programming. Loops serve as a powerful tool, both to reduce redundancy in the code and to implement behaviors that must repeat multiple times or indefinitely.

In MakeCode Arcade, there are four types of loop blocks:

  • For
  • While
  • Repeat
  • For of

With this resource, you can learn more about loops and find student activities to reinforce this coding concept.

Screenshot of loop blocks in MakeCode.

Variables

A variable represents the place in memory for the data that’s kept there. It’s called a variable because the data it represents may change (vary) when the program stores something new there. When you create a new variable in your program, you’re reserving a place in memory for some data that your program might want to create, copy, or check on later.

Variables have a name, a type, and a value:

  • Name - how you’ll refer to the variable
  • Type - the kind of data a variable will store
  • Value - what’s stored (the data) in the variable

Step 1: Select the Variables toolbox drawer in MakeCode Arcade. Select the Make a Variable... button.

Screenshot of MakeCode variables toolbox drawer.

Step 2: Name the variable. In this example, we're calling the data "example."

Screenshot of new variable name window in MakeCode Arcade naming the variable "example."

Now, you're able to use the different variable blocks available.

Screenshot of program control flow in code.

Program control flow

The term control flow refers to the order in which the instructions in your program are executed. Let's use this program as an example to better understand the concept.

Screenshot of sample MakeCode code: on start; set background image to; splash "press (A) to play"; start countdown 10 s.

If you run this program, what is going to happen? Will the program run:

  • Alphabetically?
  • Based on color?
  • Completely randomly?

The answer is none of the above! If you run the program, you'll see the instructions executed in a top-down structure. The program starts running from the top and works its way down through the instructions until it reaches the bottom. You could say that its control flow is sequential or linear, because it runs through the instructions in a methodical way.

However, not all programs are this simple. Most programs, in fact, have instructions in the code that are repeated (loops), or branching paths (conditionals, which are decision-making statements).

All of these components make up program control flow.