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