Memory game

Is there a (semi) simple way to produce a memory game like this one?:

http://www.zefrank.com/memory/

I can draw all possible frames but there’s bound to be a better way…