Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Matching Images JavaScript

    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/8nq4s5...a/matching.zip

  • #2
    New Coder
    Join Date
    Dec 2011
    Location
    Earth if you want to know
    Posts
    27
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Business7 View Post
    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/8nq4s5...a/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_

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That sounds complicated for something as simple as this.

  • #4
    New Coder
    Join Date
    Dec 2011
    Location
    Earth if you want to know
    Posts
    27
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Business7 View Post
    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_

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Sounds like you are trying to build something like http://javascript.about.com/library/blmemoryi1.htm
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    New Coder
    Join Date
    May 2011
    Posts
    43
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I hacked this tutorial up for my first card game using jquery.
    http://www.elated.com/articles/drag-...sential-guide/

    Halfway down the page is the card one...Here's the demo http://www.elated.com/res/File/artic...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/Portfo...alStorage.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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •