new Array(); question, sorry!

Out of context: Reply #2

  • Started
  • Last post
  • 9 Responses
  • Hardcore0

    Try using an array of objects;

    calculatePos = function() {

    return 35*Math.round(Math.random
    ()*5);

    }

    MatriceArray = new Array()

    for (i=0; i<6; i++) {

    Matrice = new Object()

    Matrice.x = calculatePos()
    Matrice.y = calculatePos()

    MatriceArray[i] = Matrice

    }

    now you can access the array using :

    xValue = MatriceArray[0].x
    yValue = MatriceArray[0].y

    then test the xValue and yValues for each position in the array in a different loop - and recalculate the position as necessary...

    Not tested - just made up off the top of me head... hope this helps (a little) ... :)

View thread