< html >

< body >

< script type = "text/javascript" >

var timer : var = 0 ;

var timeLimit : var = 60 ; // This is the time limit

function Update ( ) {

timer += Time. deltaTime ;

if ( timer >= timeLimit ) {

}

}

< var Tile = function ( x , y ) {

this . x = x ;

this . y = y ;

this . width = 50 ;

} ;

Tile. prototype . drawFaceDown = function ( ) {

fill ( #A2B5CD ) ;

strokeWeight ( 3 ) ;

rect ( this . x this . y , this . width , this . width , 10 ) ;

image ( getImage ( "avatars/carbon-fiber" ) ) , this . x , this . y , this . width , this . width ) ;

} ;

Tile. prototype . drawFaceUp = function ( ) {

fill ( #f9f9f9 )

strokeWeight ( 3 ) ;

rect ( this . x , this . y , this . width , this . width ) ;

} ;

// Declare an array of all the faces

var faces = [

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

getImage ( "avatars/" )

] ;

// Make an array with 2 of each, and randomize it

var selected = [ ] ;

for ( var i = 0 ; i < 10 ; i ++ ) {

// Randomly pick 1 card from the array of the cards left

var randomInd = floor ( random ( faces. length ) ) ;

var face = faces [ randomInd ] ;

// Put 2 copies on the array

selected. push ( face ) ;

selected. push ( face ) ;

// Remove a card from the array

faces. splice ( randomInd , 1 ) ;

}

// Randomize the Array

selected. sort ( function ( ) {

return 0.5 - random ( ) ;

} ) ;

// Create array of tiles at appropriate positions

var tiles = [ ] ;

var NUM_COlS = 4 ;

var NUM_ROWS = 4 ;

for ( var i = 0 ; i < NUM_COLS ; i ++ ) {

for ( var j = 0 ; j < NUM_ROWS ; j ++ ) {

tiles. push ( new Tile ( i * 50 + 10 , j * 50 + 40 , selected. pop ( ) ) ) ;

}

}

background ( #FFFF ) ;

// Now put the cards face up

for ( var i = 0 ; i < tiles. length ; i ++ ) {

tiles [ i ] . drawFaceUp ( ) ;

}

// Start by putting all the cards face down

for ( var i = 0 ; i < tiles. length ; i ++ ) {

tiles [ i ] . drawFaceDown ( ) ;

}

</ script >

</ body >