KunoNoOni

checkPuzzle and Array

Jul 23rd, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private function checkPuzzle():void
  2.         {
  3.             var countTrue:int = 0;
  4.             var totalCount:int = 0;
  5.            
  6.             //Get the total number of non blank spot in puzzle
  7.             for(var y:int=0;y<10;y++)
  8.             {
  9.                 for(var x:int=0;x<10;x++)
  10.                 {
  11.                     if(Registry.puzzleSolutions[x+puzzleSolutionIndex][y+puzzleSolutionIndex] == 1)
  12.                     {
  13.                         totalCount++;
  14.                     }
  15.                 }
  16.             }
  17.            
  18.             //Check to see if the player has recreated the picture correctly
  19.             for(var j:int=0;j<10;j++)
  20.             {
  21.                 for(var i:int=0;i<10;i++)
  22.                 {
  23.                     if(grid[i][j] == 1 && Registry.puzzleSolutions[i+puzzleSolutionIndex][j+puzzleSolutionIndex] == 1)
  24.                     {
  25.  
  26.                         countTrue++;
  27.                     }
  28.                 }
  29.             }
  30.             trace("Total Count True = "+countTrue+" Total Count = "+totalCount);
  31.             if(countTrue == totalCount)
  32.             {
  33.                 puzzleComplete = true;
  34.                 trace("Puzzle Complete!!");
  35.             }
  36.         }
  37.  
  38.  
  39. *notes - puzzleSolutionIndex is 0.
  40. Inside the Registry.as I have
  41.  
  42. puzzleSolutions = [[0,0,0,0,0,0,0,0,0,0],
  43.            [0,0,0,1,1,1,1,0,0,0],
  44.            [0,0,1,1,1,1,1,1,0,0],
  45.            [0,1,1,0,1,1,0,1,1,0],
  46.            [0,1,1,0,1,1,0,1,1,0],
  47.            [0,1,1,1,1,1,1,1,1,0],
  48.            [0,1,0,1,1,1,1,0,1,0],
  49.            [0,0,1,0,0,0,0,1,0,0],
  50.            [0,0,0,1,1,1,1,0,0,0],
  51.            [0,0,0,0,0,0,0,0,0,0],
  52.            [0,0,0,0,0,1,1,0,0,0],
  53.            [0,0,0,1,1,1,1,0,0,0],
  54.            [0,0,0,0,0,1,1,0,0,1],
  55.            [0,0,1,1,1,0,1,1,1,0],
  56.            [0,1,1,0,1,1,1,0,0,0],
  57.            [0,1,1,0,1,1,0,0,0,0],
  58.            [0,0,0,1,1,1,0,0,0,0],
  59.            [0,0,1,1,0,1,1,0,0,0],
  60.            [0,0,1,0,0,0,1,1,1,0],
  61.            [0,1,1,0,0,0,0,0,1,0],
  62.            [0,0,0,1,0,0,0,0,0,0],
  63.            [0,1,1,1,0,0,0,0,1,1],
  64.            [0,1,0,1,0,0,0,0,1,0],
  65.            [1,1,1,1,1,1,1,1,1,0],
  66.            [1,1,1,1,1,1,1,1,1,0],
  67.            [0,0,0,1,1,1,1,1,1,0],
  68.            [0,0,0,1,1,1,1,1,0,0],
  69.            [0,0,0,1,0,0,0,1,0,0],
  70.            [0,0,0,1,0,0,0,1,0,0],
  71.            [0,0,1,1,0,0,1,1,0,0],
  72.            [0,0,0,0,0,0,0,0,0,0],
  73.            [1,0,1,0,0,0,0,0,0,0],
  74.            [1,1,1,0,0,0,0,0,0,1],
  75.            [1,1,1,0,0,0,0,0,1,1],
  76.            [1,1,1,1,1,1,1,1,1,0],
  77.            [1,1,1,1,1,1,1,1,0,0],
  78.            [1,1,1,1,1,1,1,1,1,0],
  79.            [1,0,1,0,0,0,1,0,1,1],
  80.            [1,0,1,0,0,1,1,0,0,1],
  81.            [0,0,0,0,0,0,0,0,0,0],
  82.            [0,0,0,0,0,1,0,0,0,0],
  83.            [0,0,0,0,1,0,1,0,0,0],
  84.            [0,0,0,1,0,0,0,1,0,0],
  85.            [0,0,1,0,0,0,1,1,1,0],
  86.            [0,1,1,1,0,1,1,0,1,1],
  87.            [1,1,0,1,1,1,0,1,1,1],
  88.            [1,0,1,1,1,1,1,1,1,1],
  89.            [1,1,1,1,1,1,1,1,1,1],
  90.            [1,1,1,1,1,0,1,1,1,0],
  91.            [0,1,1,1,0,0,0,0,0,0],
  92.            [0,0,0,0,1,1,0,0,0,0],
  93.            [0,0,1,1,1,1,1,1,0,0],
  94.            [0,0,0,1,1,1,1,0,0,0],
  95.            [0,0,0,1,0,0,1,0,0,0],
  96.            [0,0,1,0,0,0,0,1,0,0],
  97.            [0,0,1,0,0,0,0,1,0,0],
  98.            [0,1,1,1,1,1,1,1,1,0],
  99.            [0,1,1,1,1,1,1,1,1,0],
  100.            [1,1,1,1,1,1,1,1,1,1],
  101.            [1,1,1,1,1,1,1,1,1,1],
  102.            [0,0,1,0,0,0,0,1,0,0],
  103.            [0,1,1,1,0,0,1,1,1,0],
  104.            [1,1,1,1,1,1,1,1,1,1],
  105.            [1,1,1,1,1,1,1,1,1,1],
  106.            [1,1,1,1,1,1,1,1,1,1],
  107.            [1,1,1,1,1,1,1,1,1,1],
  108.            [0,1,1,1,1,1,1,1,1,0],
  109.            [0,0,1,1,1,1,1,1,0,0],
  110.            [0,0,0,1,1,1,1,0,0,0],
  111.            [0,0,0,0,1,1,0,0,0,0],
  112.            [0,0,0,0,1,1,0,0,0,0],
  113.            [0,0,0,1,1,1,1,0,0,0],
  114.            [0,0,1,1,1,1,1,1,0,0],
  115.            [0,1,1,1,1,1,1,1,1,0],
  116.            [1,1,1,1,1,1,1,1,1,1],
  117.            [1,1,1,1,1,1,1,1,1,1],
  118.            [0,1,1,1,1,1,1,1,1,0],
  119.            [0,0,1,1,1,1,1,1,0,0],
  120.            [0,0,0,1,1,1,1,0,0,0],
  121.            [0,0,0,0,1,1,0,0,0,0],
  122.            [0,0,0,0,1,1,0,0,0,0],
  123.            [0,0,0,1,1,1,1,0,0,0],
  124.            [0,0,1,1,1,1,1,1,0,0],
  125.            [0,1,1,1,1,1,1,1,1,0],
  126.            [1,1,1,1,1,1,1,1,1,1],
  127.            [1,1,1,1,1,1,1,1,1,1],
  128.            [1,1,1,1,1,1,1,1,1,1],
  129.            [1,1,0,0,1,1,0,0,1,1],
  130.            [0,0,0,0,1,1,0,0,0,0],
  131.            [0,0,0,1,1,1,1,0,0,0],
  132.            [0,0,0,0,1,1,0,0,0,0],
  133.            [0,0,0,1,1,1,1,0,0,0],
  134.            [0,0,0,1,1,1,1,0,0,0],
  135.            [0,1,1,0,1,1,0,1,1,0],
  136.            [1,1,1,1,1,1,1,1,1,1],
  137.            [1,1,1,1,1,1,1,1,1,1],
  138.            [0,1,1,0,1,1,0,1,1,0],
  139.            [0,0,0,0,1,1,0,0,0,0],
  140.            [0,0,0,0,1,1,0,0,0,0],
  141.            [0,0,0,1,1,1,1,0,0,0]];
Advertisement
Add Comment
Please, Sign In to add comment