Project 25 of 35  ·  Scratch Programming  ·  Module 2
Module 2

Memory

Build a card memory matching game where players flip cards and find all the pairs.

🍓  Open on Raspberry Pi Projects  ↗ Opens the official Raspberry Pi Foundation project — includes starter files and full step-by-step guide

What You Will Build

Build a card memory matching game where players flip cards and find all the pairs. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.

🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.

What You Will Learn

  • Create 8 pairs of cards with matching costumes
  • Flip cards by switching between front and back costumes
  • Track which two cards are currently face up using variables
  • Compare cards and leave matches face up or flip both back down
  • Shuffle card positions at the start of each game

Step-by-Step Guide

  • 1Create a card sprite with 9 costumes: 1 back design and 8 different front designs.
  • 2In on start: create 16 clones, position them in a 4×4 grid, shuffle using a random sort.
  • 3Each clone stores its pair number using a variable.
  • 4When clicked: switch from back costume to the matching front costume.
  • 5Track card1 and card2 variables. First click sets card1. Second sets card2.
  • 6Compare: if card1 costume = card2 costume: leave both face up, add 2 to matched.
  • 7If no match: wait 1 second then flip both back to back costume.
  • 8When matched = 16: show You win! and display the number of attempts.
  • 9Track attempts — increment by 1 each time a second card is flipped.
  • 10Add a timer to create a time-attack mode.

Extension Challenges

Finished the main project? Push further:

  • Add themed card sets using different costume groups (animals, flags, shapes).
  • Add a multiplayer mode with two players taking alternating turns.
  • Add a flip animation using size changes as the card turns.