...

View Full Version : Matching Images JavaScript



Business7
12-16-2011, 07:14 PM
I'm writing a matching game. I have uploaded an example. I want to be able to read the current image rather than the default image as a variable to compare in an IF statement.

http://www.mediafire.com/file/8nq4s5182f7h0xa/matching.zip

cuzMazn
12-16-2011, 08:53 PM
I'm writing a matching game. I have uploaded an example. I want to be able to read the current image rather than the default image as a variable to compare in an IF statement.

http://www.mediafire.com/file/8nq4s5182f7h0xa/matching.zip

Greetings,

I think there would be a possible way to do it, using Ajax to transfer your image link to PHP, then use PHP to read the md5() hash of an image then return a result. That's the only way I can think of right now.

Tim_

Business7
12-16-2011, 09:07 PM
That sounds complicated for something as simple as this.

cuzMazn
12-16-2011, 10:06 PM
That sounds complicated for something as simple as this.

Hi there,

I just want to clarify your question before I could move further, do you mean:

To read the content of the image and see if they are exactly the same OR
You have many images and you would like to know if user selects 2 same images provided?


As I commented, I thought you meant to read the content of each image and see if they are the same.

Tim_

felgall
12-17-2011, 05:34 AM
Sounds like you are trying to build something like http://javascript.about.com/library/blmemoryi1.htm

Business7
12-19-2011, 03:18 PM
In my example I have 2 images that change between 2 images. In my project I have 5 images that change between 27 images. I would like to be able to document.write when a certain selection of the images I have provided is displayed. In my example if I could just have it document.write "Both squares are blue. / Both squares are red."

I will look at the logic of the matching game here and see if I can apply it for my use.

nuBee
12-19-2011, 07:36 PM
I hacked this tutorial up for my first card game using jquery.
http://www.elated.com/articles/drag-and-drop-with-jquery-your-essential-guide/

Halfway down the page is the card one...Here's the demo http://www.elated.com/res/File/articles/development/javascript/jquery/drag-and-drop-with-jquery-your-essential-guide/card-game.html

When you drag the right card onto the right slot it turns a color and you can have it update a variable for a score/match. Similarly when you drag it onto the wrong slot it takes points away and returns the card...This is what I was messing around with http://pugetsoundtraining.com/Portfolio/localStorage.html You can change the 2 arrays to be other names instead of numbers, like colors, shapes, whatever, to suit your needs. Then instead of saying "you dropped a 1 onto a 5 slot" it would say "you dropped a blue onto a red square" or something similar...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum