dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Dont understand this, its due in a hr?

  1. #1
    Join Date
    Mar 2012
    Posts
    8

    resolved [RESOLVED] Dont understand this, its due in a hr?

    Im supposed to make a matching game, I dont know where to start



    DONE /*
    For you to do:

    find 12 images, resize them to be about 150px X 115px and substitue their names in here

    */

    var images=new Array("1.jpg", "1.jpg","2.jpg","2.jpg",
    "3.jpg","3.jpg", "4.jpg", "4.jpg",
    "5.jpg", "5.jpg", "6.jpg", "6.jpg",
    "7.jpg", "7.jpg","8.jpg","8.jpg",
    "9.jpg","9.jpg", "10.jpg", "10.jpg",
    "11.jpg", "11.jpg", "12.jpg", "12.jpg");

    DONE /*
    For you to do:

    find an image to use as the back of the card and substitute it here
    */
    var back="back.jpg";

    function uncover(card)
    {
    /*
    For you to do:

    extract the value of the id attribute from card and set the src attribute to be the image
    that corresponds to the same index in the array
    */
    }

    function prepareGameboard()
    {
    var randomNum;
    var temp;
    var input=0;
    var i;
    var j;
    var numCards=24;
    var board;


    if (!document.getElementsByTagName) return false;
    if (!document.getElementById) return false;
    if (!document.getElementById("gameboard")) return false;

    for(var i=0;i<numCards;i++)
    {
    randomNum=Math.floor((Math.random() * numCards));
    temp=images[randomNum];
    images[randomNum]=images[i];
    images[i]=temp;
    }

    board=document.getElementById('gameboard');

    /*
    For you to do:

    Loop 0 to numCards-1, creating new image elements, setting each attribute to the card back image, setting each
    id to be i, and each alt attribute to be 'card' + i. Also, set each onclick attribute to return uncover(this).
    Finally, append the new element as a child to the element with the id 'gameboard'
    */

    }

    function addLoadEvent(func)
    {
    var oldonload = window.onload;

    if (typeof window.onload != 'function')
    {
    window.onload = func;
    }
    else
    {
    window.onload = function()
    {
    oldonload();
    func();
    }
    }
    }

    addLoadEvent(prepareGameboard);

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    gambling is not good

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles