Sixteen cards, eight pairs — can you remember where they are?
← Back to Fun TimeThis game is split into small library files inside funtime/lib/, and every function has a comment saying exactly what goes in, what comes out, and the algorithm in plain English. Empty any function out, read its comment, and write it yourself.
| File | What it does | Good functions to try re-writing |
|---|---|---|
| lib/memory-rules.js | The rules: dealing, flipping, matching | cardIndex, createDeck, isMatch, flipCard |
| lib/memory-draw.js | Painting the cards and the eight symbols | drawSymbol, drawCard, cardAtPixel |
| lib/memory-main.js | The glue: clicks, keyboard, the loop | doAction, canvasPosition, gameLoop |
💡 The big idea: the sixteen cards are one flat list, and cardIndex(column, row) is the little sum that turns a grid into a list. Almost every board game you write needs it.
🛠️ Want to be walked through it? Build Memory Match Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.