Skip to content

Number Memory Game – MIT App Inventor Tutorial

In this app, numbers will appear in a 4×4 grid for a certain amount of time. User needs to remember all the numbers and tap on the buttons according to number sequence from 1 to 16.

UI Components:
Label, Horizontal Arrangement, Button (lots of button 😱), Horizontal Arrangement, Clock, Notifier

Clock – Enabled (false), TimeInterval (5000)


Generate Random Number Sequence

First, generate a list with incremental numbers from 1 to 16. Then, apply Fisher-Yates algorithm to shuffle the list to have random permutation.

Show Numbers when Game Start

When the start game button is clicked, generate the random number list and show the numbers on all 16 buttons from left to right.

Enable the clock when game start to start the timer. In this example, the time interval was set to 5000ms and once the Clock.Timer event called, disable the timer and hide all the text on buttons.

Finally, we need a variable to keep track of the button clicks and the number will be displayed using the top label.

Game Play

For each button click, increase the clickCount variable by one and check if the number on the button matches the number in our generated array based on its sequence. In below example, checkClick function will take in an argument which will be used as index to get the value in the generated list.

Complete Program

Other Resources