Flash

Páginas: 3 (623 palabras) Publicado: 18 de enero de 2012
/*
* Function createDeck -
* creates an array to serve as a sorted card model
*/
function createDeck() {
   // create cards
   startDeck = new Array();
   // each card = it's array position +1
   for (x=0;x<picCount;x++) {
      startDeck
* = x + 1;

   }
   return startDeck;
}

/*
* Function shuffle - when given a deck of N cards (array) the
* shuffle will return adeck of N cards with the same elements
* of the given deck in random order
*/
function shuffle(deckOld) {
   // creating the deck we will return
   deck = new Array();
   // fill array of cardswith unique pics
   do {
   //*** NOT INDENTED FOR WEB PAGE PURPOSES ***
   newRandom = Math.floor(deckOld.length*Math.random());
   deck.push(deckOld[newRandom]);
      
   // copy array   scanData = new Array();
   scanData = scanData.concat(deck);
      
   // if last added was duplicate, than remove.
   if (scanData.sort(Array.UNIQUESORT) == 0) {
      deck.pop();
   }
      
   }while (deck.length<deckOld.length);
   
   // return the finished array
   return deck;
}

/*
* Function deal - takes the cards and deals them out onto
* the screen.  Supply unique picturenumber and uPic*2 cards
* are delt upon the screen.
*
* Parameters:
* uPic = number of unique pictures to deal
* deck of cards to deal it from (all pictures)
*/
function deal(uPic, cardDeck) {   moveY = 1;
   moveX = 1;
   // go to next row after rowBreak cards are delt.
   rowBreak = 8;
   
   //initialize decks
   deck1 = new Array();
   deck2 = new Array();
   // shuffle fulldeck
   deck1 = shuffle(cardDeck);
   // take only the number of cards needed.
   deck1 = deck1.slice(0,uPic);
   // deck 2 is shuffled cards of deck1
   deck2 = shuffle(deck1);
   
   // lay outtwice the uniques for duplication.
   for (icount=0; icount<(2*uPic); icount++) {
//*** NOT INDENTED FOR WEB PAGE PURPOSES ***
   curName = "pc"+icount;
   moveX = (icount%rowBreak)+1;...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • flash
  • Flash
  • Flash
  • el flash
  • Flash
  • Flash
  • Flash
  • Con flash

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS