Hello friends, and welcome to Obsidian Soft!
What if I told you that four Halloween symbols could turn into a game that gets harder with every single round? 🎃👻
In this tutorial, we are going to build a spooky App Inventor Halloween Game! Let’s have a look at the demo of the Halloween memory game in MIT App Inventor. The game is showing you a sequence of Halloween symbols, and your job is to remember the sequence and repeat it correctly.
Sounds easy? Well, wait until the sequence gets longer and longer! How far do you think you can go before your memory lets you down? 😈
Let us build it together, step by step!
First of all, download the media. I will use 4 Halloween symbol images, a skull image for the game-over situation, 1 correct sound, 1 wrong sound, and 1 round-completed sound.
Download the files from the following links:
Correct sound:
https://pixabay.com/sound-effects/technology-correct-472358
Wrong sound:
https://pixabay.com/sound-effects/film-special-effects-fail-trumpet-144746
Round completion sound:
https://pixabay.com/sound-effects/film-special-effects-great-success-384935
Halloween symbols:
https://drive.google.com/drive/folders/1FmQUAgDvYzcKX8hlgZXVfrvHkpfwj3nB?usp=sharing
Start a new project in MIT App Inventor. Let’s call it “SpookyMemoryGame”. Upload all media by dragging and dropping all of the files onto the media section.
For Screen1 properties, set Align Horizontal to Center and Align Vertical to Center. And choose the background color: #23103A
Add a label component from the user interface palette. Make the font bold, set the font size to 24, and change the text to “Press Start to play!”
Add an image component from the user interface palette and rename it to seqSymbol. Make the height 10%. This will display one symbol at a time in the sequence that the user then has to copy.
Add a label below the image. Rename it to scoreLbl. Make the font bold, font size 24, and change the text to Score: 0 and the text color to white.
Add a button from the user interface palette. Rename it to startBtn. Make the background color orange, the font bold, the font size 20, the width 50%, and the shape rounded. Change the text to “Start Game”.
Below the button, add a horizontal arrangement and set both align horizontal and align vertical to center. Make the width fill parent. Make the background color: none. Add a button inside this arrangement. Rename it to catBtn. Choose the cat image file as its image. And make the shape rounded. Remove all text from it. Select the button and duplicate it by pressing Ctrl+C & Ctrl+V on the keyboard for Window or Command+C & Command+V for macOS. Rename this to ghostBtn. And change the image to the uploaded ghost image.
Add an empty space label with a width 4% between the two buttons. Select the horizontal arrangement and duplicate it. Change the name and image of the buttons accordingly to pumpkin and hat. Put some space labels between the top components and the horizontal arrangements too.
Add a clock from the Sensors palette. Make timer interval 700 ms and uncheck Timer Enabled and Timer Always Fires.
Add a sound component from the media palette. Rename it to correctSound and choose the correct sound file as its source. Duplicate, rename to wrongSound, and choose the wrong sound file as its source. Duplicate, rename to successSound, and choose the success sound file as its source. Our screen design is done, so let’s go to the blocks section. We need a few global variables. We need a sequence list for storing the complete sequence of random symbols.

We also need a sequence index for storing the index of the sequence being played by the computer.

We need an input index for storing the index of the sequence being played by the user.

We need a score variable initialized to 0.

We also need 3 status variables to know the game state:



isPlaying indicates whether the computer is playing or displaying the sequence symbols. showingSymbol is for tracking how the symbols in a sequence are displayed with a gap i.e. we show a symbol, we hide it, and then we show the next symbol and so on. acceptingInput prevents players from tapping the symbol buttons during playback or after game is over.
We will use numbers to represent the symbols, and this is why my image files are also saved as numbers.
1=cat, 2 =ghost, 3=pumpkin, 4=hat
First, we make the addNewRound procedure. We update the statusLbl. We add a random number between 1 and 4 to the sequence for each new round.
We reset the sequence index to 1 and set isPlaying to true and clock to true so that the computer can start displaying the sequence. And we turn off acceptingInput so that if the user clicks the buttons while the sequence is playing, nothing happens. We also empty the picture of the sequence and update showingSymbol to false.

Now, since we have enabled the timer in addNewRound, what happens when the timer event fires? We first check that we are still in the isPlaying phase. And we check using an if/else block that showingSymbol is not false (which will be true the first time, as we made it false in addNewRound).
Then, we show the symbol according to the sequence index from the sequence list. Since the images are named as 1.png, 2.png…so on, we can join the number with .png. And we set showingSymbol to true so that next time we come, we enter the else condition where we empty the symbol image…so that there is a short delay between showing the next symbol in a sequence. We increment the sequence index, and we set showingSymbol to false so that next time if we come to the timer event, we enter the condition for showing the symbol. And we also check if we have displayed all the symbols in the sequence. If we have, we tell the user that it is his turn now. And we disable clock and isPlaying. We enable acceptingInput and set inputIndex to 1, as the user will now start entering his input by pressing the buttons.

Then, we make a procedure for gameOver where we set isPlaying and acceptingInput to false. We disable the timer. And we update the screen to show that the game is over.

Next, we make a procedure for checking the answer with userChoice as input. We first of all check that acceptingInput is true. Then we check using an if/else block that the user clicked the correct button according to the position of inputIndex in the sequence. We give it the user’s choice as input. If yes, we increase inputIndex. Then we further check if the user has completed the sequence. In that case, we play the success sound, update the score, and show it on screen. Otherwise, we just play the correct sound. If the user entered the wrong choice, then we play the wrong sound and call the game over procedure.

And now we code our 4 buttons’ click events to call the checkAnswer procedure.

And last is our startBtn click event, where we reset everything back to the original state and call the addNewRound procedure to start the game.

And that is it! We have built our very own Halloween memory game in MIT App Inventor. 🎃
Now it is your turn to play! How many rounds can you complete before making a mistake? Try it out and challenge your friends and family to beat your score.
I hope you like this fun App Inventor Halloween game made completely in MIT App Inventor, perfect for school and college projects or just to impress your friends.
Download AIA file for the Halloween Memory Game in MIT App Inventor
You can also check out the video tutorial for this project on my channel.
Please like my tutorials and share it with your friends and family. Also, subscribe to my channel and press the bell icon so you don’t miss any of the great projects I have planned for you.
https://www.youtube.com/c/obsidiansofteducation
Please like my Facebook page and Instagram page for more educational resources and tips.
Facebook: https://www.facebook.com/ObsidianSoft/
Instagram: https://www.instagram.com/obsidiansoftapps/
Pinterest: https://www.pinterest.com/obsidiansoft/
For links to free educational apps, have a look at the educational apps page
