kadi Posted August 2, 2013 Share Posted August 2, 2013 hi, anyone can help me on how to match pictures using javascript bird-------------> seeds cat-------------> milk so if we consider above there are four images(bird, seeds, cat, milk, for sake of convenience i am just writing names as it wil b easy to understand what i am trying to say), As birds feed on seeds and cat on milk. we need to match those pictures in javascript like this if we click on bird and then on seeds it should say "correct match" and both images needs to vanish else "not correct match and try again" if we click on cat and then on milk it should say "correct match" and both images needs to vanish else "not correct match and try again" after all are matched correctly we need to redirect to homepage... any help regards Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2013 Share Posted August 2, 2013 What do you have so far? For a start, you'll need an array of image pairs that go together. You'll also need a variable to track the last one they clicked on. Whenever they click on an image you'll figure out which one they clicked on, and check to see if they clicked on one previously. If they haven't you just save what they just clicked on to check later. If they did click on something previously, then you look up both pictures in the array to see if they match and take action based on that. After a second image click, whatever the outcome, you would probably want to clear the variable that holds the last click so that it starts over with a new pair. Link to comment Share on other sites More sharing options...
davej Posted August 3, 2013 Share Posted August 3, 2013 (edited) As JSG says, this is a simple enough concept. Where the difficulty might lie is in defining the match ups. You could for example use the name of the images as the match indicator such as image007a.jpg and image007b.jpg. Other than that you are left to define some sort of table or array, where it could get more complicated, especially if you want to switch between different sets of images. You could do a lot of different things with a picture game. When an image is clicked on you could enlarge it or put a border around it or move it to a new location. You could also use drag and drop. The last picture game I was introduced to would display several images and then ask for a word that described the common theme or concept being displayed. Edited August 4, 2013 by davej Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now