Lesson Code: http://www.developphp.com/video/JavaScript/Memory-Game-Programming-Tutorial
In this programming exercise you can learn to create a JavaScript powered memory game that you can easily enhance and extend as your skills improve as a JavaScript programmer. We will use HTML and CSS for the looks and user interface.
Original source
Memory Game Programming JavaScript Tutorial
(Programming, computer, css, CSS3, design, Development, free, game, html, html5, javascript, javascript tutorial, learn, lesson, Memory, ONLINE, science, tutorial, video game, Web
50 responses to “Memory Game Programming JavaScript Tutorial”
what if i want to use image instead of int?
None of my card images are coming up, even though my image is in the database and the urls match up. I don't understand why this is happening; I'm not missing any semicolons either.
can anyone please edit the program and put score in this game!! I need it asap! And also if a match is made then can anyone make the cards disappear!! Your help is highly appreciated.
would it be possible when you find the image pair the boxes as well the images containing in it diasppears and also please tell me how do i set the score…
hey Adam, im new to programming, but i do understand enough of whats going on. although i have an uncaught bug after your tutorial and i dont understand whats causing it. the ifs in memoryFlipTile are only calling flip 2 back the first time i flip 2 cards, afterwards it just lets me flip all the cards over, any ideas of what to look for while im debugging?
This was a super good guide…but I hate niggas who do inline
How do I change the letters into images?
You're a legend.
Hello
I'm a novice programmer.
I would like to ask, Can I add sound to each letter?
If you can say yes?
pre Spisibo
Hi Adam,
I would repeat one of the questions below, as I did not find an reply to it, if I may : How to add images to cards instead of letters?
In fact, I was trying to get one side image and the other side the name of the image. Many thanks
Hi Adam, How to add images to cards instead of alphabets
Great job Adam, keep up the good work 🙂
can we set limitation of click it..like after the user has clicked 10 cards the alert vil show u can't play any more …pzl help
Suppose i want to give pictures instead of the alphabets then what changes should i do??
AWESOME
Adam, you sound like a good ol New Yorker, like me??
Sir I want to put a limits for tiles flip because after several flips we know all cards vales ..so how to set max flip turns Sir..plz help
nice
Thanks a lot man, helped me a lot 😀
Keep it up!
subbed.
Great tutorial. This tutorial is now featured on PencilTree, in the javascript subject.
hi, i'd like to implement your game but i have a problem. all my tiles form one big image so i can't use div#memory-board >div background… (i'm using different images as tiles). is it also possible to make a memory card game on this way?
This is great. I enjoy the teaching method.
How can I add images to the back side of the cards when it first put it down. I did to the css DIV , the radical gradient works , the image does not. /* works background: radial-gradient(circle, black, white);*/
/* no worky background: url(images/imagebg.jpg);*/
border:#000 1px solid;
width:71px;
height:71px;
float:left;
margin:10px;
padding:20px;
font-size:18px;
cursor:pointer;
text-align:center;
Anyone know a way to match like 3+1 and 4 in this? Like match something that isnt identical but has the same value?
Where do we get the tile URLs? They never show up in my page. Do I have to save a file or something?
Hey Adam. I know someone already asked this but it never got a reply. If you click on two tiles that you already correctly matched it continues to count as another match. So in my case with 8 possible matches all you have to do is make one match and then just repeatedly click the two to make 7 more matches without flipping over anymore cards. Also if you click one card you matched and a new card it flips the one card you already matched back over. Obviously the problem is your allowed to continue to click on cards you already matched when you shouldnt be able too. Im sure your aware and probably left it out on purpose to get people to figure out how to fix it but anyone know of solution?
hi great video; do you have the flowchart of this game?;thanks
can someone please explain how to make onclick css flip animation with these automatically generated cards?
What if I want a card to match another card but with a different content? For instance there are cards like "tiger", "rose", "tuna", so I want the card "tiger" match the card "animal". How to manage to do that?
Thank you! awesome video btw
Adam, this is a great video. I have one question. I am trying to include this on my web site. I have three files: HTML, CSS, and jQuery files. I copied the HTML into the HTML file, the CSS into the CSS file and the jQuery into the jQuery file. When I run this it only show a gray box and no cards. Clicking anywhere in the box does not work either. Any suggestions on how I might link the three files? I have other options that use these three files and everything else works fine. Thank you Kydolphin2013.
thanks, I'll need to create this game in my job 😉
Excellent video, really well explained, I recommend this highly for anyone learning JS.
One comment: I had to take out the 'on repeat' on two of the lines setting the background style back to the image, within the flip2back function; with 'on repeat', my image did not display consistently with the CSS settings.
Thanks for that script and video!
Hey, I am using this game, but there is a bug where if you accidentally click on a card thats already turned over, it will turn it back around. Is there a way to make it impossible to click on cards that are already turned over?
Which Editor or IDE are you using?
hi.. can u plz tell me how can i insert a timer into the above code..so that when the game starts the timer starts..and when the user finishes the game it should display how much time the user took to finish the game..thanks
Adam your a brilliant programming teacher.. 🙂
Hi 🙂 Nice Tutorial, thank you a lot!
After reading a few comments, I still don't get how to use colors instead of letters for the memory cards! Actually I don't want to use images/jpg's, just chance the array, but when I do, the cards dissapear.. can anybody help me :/? It's quite important! Thanks in anticipation (>.<)/
i'm not quite sure why, but i've written the code into my html document pretty much exactly as is and it's not working :/ any suggestions?
so loving this
im gay
why does the background image for my memory game does not show up?plss help meeee…
who the fuck dislike this tutorial?
am I the only one seeing dots between the blue memory blocks?
This is an awesome tutorial, thank you.
can you please give the url for the tile
I was trying to simplify the code, why can't I put
"// Clear both arrays
memory_values = [];
memory_tile_ids = [];"
right after the if-else statement? rather than writing it out twice. It gives some strange behaviour though…
@Adam Khoury; i don't see the cards. why?
Only one complaint, but first, I am very happy to have stumbled onto this corner of the Internet. Okay, to the complaint. The white spaces at the corner of the memory cards creates a powerful optical illusion that scatters dark dots across the board. This is probably one of the strongest examples I've seen of this phenomena, but probably not what you were going for.
hi.. do you know how an image can be used for the puzzle images instead of letters???
Hey Adam how about when i flip the card and it the same it disappear ? how do you code that ? and what if by level ? can you answer my questions please for my thesis requirements