Main content
Computer programming
Intro to "Memory"
"Memory" is a fun game that you may have played in "real life", with actual paper tiles. It's called that because the main skill in the game is your memory - how well you can remember the position of tiles. It's also a game that can be re-created on a computer, and is a good example of using computer memory to remember information, like with arrays.
Once we're done, this is what our "Memory" game will look like:
To make the game, we will need to re-create the physical parts of the game using our drawing commands and implement the rules of the game using variables and logic. We will make a single-player version of the game, which will simplify some of the logic. Here's an outline of what we'll implement:
- The game consists of an even number of tiles with images on one side and a generic back. Each image appears on precisely two tiles.
- When the game starts, all tiles are turned face down.
- The player then flips over two cards, selecting them by clicking on them. If the two tiles have the same image, they remain face up. Otherwise, the tiles flip back over after a small period of time.
- The goal of the game is to get all the tiles flipped face up (i.e., find all the matching image pairs) in the least number of tries. That means that lower number of tries are better scores.
Want to join the conversation?
- I have just started learning programming please can someone tell me where do i learn the basics from?(14 votes)
- i am not saying any of the coders on khan academy are bad but would it be possible you make a really big game like with graphics like ps4 games on khan academy(5 votes)
- The coding enviroment on KA is meant for learning the basics of code, not strictly
for making games(though there are some cool games on here). It is very limited
compared to other game makers and a modern ps4 game would be way too
complicated for it.(36 votes)
- I was doing tic-tac-toe and it said o was better in "dot notation" what is dot notation?(5 votes)
- When you have an object
you can access its properties in two ways.var obj = {
prop: 4
};
The square bracket notation:
or the dot notation:var n = obj["prop"];
var m = obj.prop;
(11 votes)
- Hello I am planning on using javascript to power a game on my website however I need some way to connect to an SQL database to javascript OR as a less prefered option collecting a cookie set previously.I would be happy with either option however.Thank You!(5 votes)
- Databases should never be directly accessible from the front-end. You would need to use a solution with a backend to do that such as AJAX or websockets with a backend service in PHP, ASP or other similar system.
Using cookies certainly doesn't give the same possibilities but is by far simpler to implement. See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie for details.
Another option you haven't mentioned is HTML 5's local storage: https://developer.mozilla.org/en/docs/Web/API/Window/localStorage . This would have the same kind of limitations as cookies but is more flexible.(11 votes)
- does khan academy do Python?
I mean, I have a book that teaches me but I only code on khan.(4 votes)- Khan Academy does have some python 2 videos on their youtube channel but it is not a full course. Keep in mind that python 2 is outdated.(5 votes)
- How much coding does this require to make the memory game?(2 votes)
- Well, that depends. A simple version may not take more than a hundred or two lines of code. A complex (and neatly coded) version might take more.(6 votes)
- How do you start playing the games?(1 vote)
- Suppose you tell us what games you are referring to.(7 votes)
- I've been running into more new code as I go along the Advanced JS: Games & Visuals. I'm learning more and more stuff but it's sometimes hard to understand the new code that you introduce. Did I miss a course on Java Script because all I've done is the intro to Java Script then I went to this course? If not then could you explain a little more about these lines of code? Splice, randomInd (I understand random but what's the difference with randomInd?), Selected (you used it in the memory game step two like so:
selected.push(face);
). I'm sorry I have asked so many questions I just want to understand them so I can use them myself without confusion.(2 votes)- Your confusion is understandable, and I believe that KA could do a bit better with explaining OOP. This is the next course, however, despite the apparent learning gap.
Splice and push are array modifiers. Splice removes an item from the array, and push adds one.
randomInd stands for randomIndex. If you want to learn more about it, look up "randomInd javascript"(3 votes)
- Um...Is there a way to operate JavaScript that is not on Khanacaedemy, and convert it here?(2 votes)
- When I try to do that, nothing happen.(2 votes)
- I don't program games a lot.Just data sets but I think that the cards are not flipping so I think that you might need to fix that.(1 vote)