Ajax CSS jQuery

Image match javascript memory game

Games !!! Its always fun to play games. i think 70% people likes to play games, out of remaining 30% percent 20% likes to play but dont find time, and remaining 10% ?? i dont want to talk about them :D. well, thats not a point we are going to discuss here.
This Image match javascript memory game idea was in my mind from long back but due to time i wasnt able to draw it in a browser. but no matter Image match javascript memory game is in browser now and i am feeling little little light, because there are still many ideas waiting for their turn.
For this Image match javascript memory game i am using one free jquery plugin named rotate3Di and i am really thankful of Zachary Johnson half of work was done my him and remaining half was done by jquery,i didnt do anything at all.Play ! Download

Image match javascript memory game Game Setup

1) Include javascript,jquery and css files

2) Put images in images folder
Make sure they are .PNG files. You can change this to any extension just dont forgot to mention it in game.js file.

3) Create HTML page
For this you just need to add few lines (If you want to show game only and dont want to show click and high scores etc)

4) Game Logic
And here is the logic, the game.js.

Note: If you want to increase number of blocks then just change “no_of_blocks” to any EVEN number and place extra images in images folder.


How to play Image match javascript memory game game

1) You will be shown blocks with faces down.
2) Click on each block and face will open.
3) Try to find the same image by clicking other blocks.
4) If you manage to find two blocks with same images then both the block will disappear.
5) Finish all the blocks game will over.
6) Try to finish the game in less clicks and you will be high scorer.



        • Say thanks to ur boss from me 🙂 I m sorry to say but i m not going to update this script because i m bz with office work and more than that bz with few advanced scripts like 1) gmail like “drag-drop” file upload (90% done) 2) Facebook like “like button” script (70% done) 3) Gmail like GTalk chat script (70% done). But if u really want to see the updates please start urself and i will help u implement the updates.

  • Thanks a lot. Really simple and useful in Firefox. But what about updates?

    “Image match game is only supported in Firefox 3.5+. You can expect support for all browsers in newer version.”

    • Dmitry : I wanted to update the script to make it support all the browsers, But i think instead of wasting time on this script i should move to the next script, first thing is this script isnt that much useful (i made this script just for fun/experiment), and second things is, it will take toooo much time to make it work in all browser (I am not css, javascript ninja so it will be headache for me), if i utilize same time for creating other 2-3 script it will be much appreciated. so sorry to say, i am not going to work on it anymore. I am working on 2-3 scripts like 1) gmail like “drag-drop” file upload (70% done) 2) Facebook like “like button” script (60% done) 3) Gmail like GTalk chat script (50% done). I think this scripts will me more useful for my visitors…isnt it ??

  • Hi Amit,
    Your blog is very useful and I have learnt a lot from your ideas. Thank you for keep posting great stuff 🙂 .

    Actually your javascript memory game is perfect. You just miss something in the code so it shows only on firefox. Just update it as below:

    File: game.js

    Original code

    Updated code

    Hope it works for you too. Have a great day!


    • Matt, I am really thankful for your help, you found the mistake. It was simple “single quote” that was making problem in browsers other than firefox. Many users was asking me for this but i thought its problem of rotating plugin and thought to look at it later but didnt found time for it. Anyways it working fine now because of you. Thanks

  • Please does anyone know how to display the name of the images that matched (right after or right before they disappear)?
    I also would like to have another separate image changing every time there’s a match. Does anyone know how do to that?
    Thank you. Great tutorial!

  • Hey Amit! Your code sample was awesome and i managed to implement it with very little changes 🙂 but even if the game runs great, i can’t save my scores or populate the list with them. I don’t know what i’m doing wrong, but i get a ‘Uncaught SyntaxError: Unexpected token <' error with the same code i downloaded from your site!

    any ideas what i might be doing wrong? any help would be appreciated <3

    • Check your database configuration. There is some database error which throwing error (with html contents), “Unexpected token <" says it clearly that script was expecting data in JSON format, but actually its receiving html contents.

      • Turns out i was missing the
        header(‘Content-Type: application/json’);
        part in the php file 🙂 now i can write scores in my database 🙂 thanks for pointing me in the right direction! <3

        Now i get a null error from the get_scores function :/ i have no idea why, since i can write scores OK, but since i can't get them back to display in the scoreboard, the function never completes and it's stuck on 'loading'.


        I'm sure i'll figure it out eventually though. Thanks so much for the 'you're getting html instead of json' heads-up 🙂
        if you're ever in Chile, come collect your free coffee and bagel!

  • Sorry, I’m newbie. I paste this in notepad with name game.js. But, it’s shows ; problem.
    So, mind to teach me stepby step? Thanks! 🙂

  • Hi, great script!

    Any idea why it is not working in IE? Just opens all the icons until you find a pair.

    thanks in advance 🙂

    • “unfortunately most of the good things are not supported by IE”, Use latest IE version. Day i become rich its my dream to buy IE copyrights and throw that crap in a dustbin.

      • Hi,

        thanks for your reply, i just updated the jquery_flip.js to the latest version and its working in all IE versions now.

        Nice script 🙂

    • Its too old code, may be latest browsers stopped supporting some function inside the code, need to recode it 😉

Leave a Comment


Notify me of followup comments via e-mail. You can also subscribe without commenting.


Let your friends know what are you reading

Share this post with your friends!