I simplified the library "ILI9225_TFT" provided by Arman Safikhani to better suit my needs in implementing a simple sliding puzzle game.

Committer:
blac3777
Date:
Fri Apr 27 07:33:56 2018 +0000
Revision:
3:251e4d020501
I simplified the library "ILI9225_TFT" provided by Arman Safikhani to suit my needs in implementing a simple sliding puzzle game.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
blac3777 3:251e4d020501 1 #include "ILI9225.h"
blac3777 3:251e4d020501 2 #include <time.h>
blac3777 3:251e4d020501 3
blac3777 3:251e4d020501 4 //Initialize pins for MBED LPC1768: RST, RS, CS, SDI(MOSI), CLK(SCK), LED.
blac3777 3:251e4d020501 5 ILI9225 tft(P2_4, P2_3, P2_5, P0_9, P0_7, P0_6);
blac3777 3:251e4d020501 6 DigitalOut led1(LED1);
blac3777 3:251e4d020501 7 DigitalOut led2(LED2);
blac3777 3:251e4d020501 8 DigitalOut led3(LED3);
blac3777 3:251e4d020501 9 DigitalOut led4(LED4);
blac3777 3:251e4d020501 10
blac3777 3:251e4d020501 11 //Initialize pins for LPCXPRESSO LPC1769: RST, RS, CS, SDI(MOSI), CLK(SCK), LED.
blac3777 3:251e4d020501 12 //ILI9225 tft(P0_5, P0_10, P0_4, P0_18, P0_15, P0_16);
blac3777 3:251e4d020501 13
blac3777 3:251e4d020501 14 //???b used out of 256kb available.
blac3777 3:251e4d020501 15 //uint16_t picture[13986] = {0};
blac3777 3:251e4d020501 16
blac3777 3:251e4d020501 17 uint16_t *picture = (uint16_t *)(0x2007C000);
blac3777 3:251e4d020501 18
blac3777 3:251e4d020501 19 uint8_t puzzState[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
blac3777 3:251e4d020501 20 15};
blac3777 3:251e4d020501 21
blac3777 3:251e4d020501 22 uint8_t cursorIndex = 0; //Refers to current index (-1 < cursorIndex < 16).
blac3777 3:251e4d020501 23
blac3777 3:251e4d020501 24 Timer timer; //Timer used to implement wireless input
blac3777 3:251e4d020501 25 InterruptIn wirelessInput(p18); //Interrupt used to implement wireless input
blac3777 3:251e4d020501 26 float wirelessInput_Freq = 0; //Global variable used to implement wireless input
blac3777 3:251e4d020501 27
blac3777 3:251e4d020501 28 void flip() {
blac3777 3:251e4d020501 29 //Convert period (in us) to frequency (Hz)
blac3777 3:251e4d020501 30 wirelessInput_Freq = (1/(float)timer.read_us())*1000000;
blac3777 3:251e4d020501 31 //Reset timer and wait for next interrupt
blac3777 3:251e4d020501 32 timer.reset();
blac3777 3:251e4d020501 33 }
blac3777 3:251e4d020501 34
blac3777 3:251e4d020501 35 int getPlayerInput(float freq) {
blac3777 3:251e4d020501 36 int specifier = (((int)freq) - (((int)freq)%1000))/1000;
blac3777 3:251e4d020501 37 wait_ms(1);
blac3777 3:251e4d020501 38 if(specifier == 1) {
blac3777 3:251e4d020501 39 //Turn on LED indicator(s): controller is in range.
blac3777 3:251e4d020501 40 led1 = led2 = led3 = led4 = 1;
blac3777 3:251e4d020501 41 return 0;
blac3777 3:251e4d020501 42 }
blac3777 3:251e4d020501 43 else if(specifier > 0 && specifier < 8) {
blac3777 3:251e4d020501 44 //Turn on LED indicator(s): controller is in range.
blac3777 3:251e4d020501 45 led1 = led2 = led3 = led4 = 1;
blac3777 3:251e4d020501 46 return specifier;
blac3777 3:251e4d020501 47 }
blac3777 3:251e4d020501 48 else {
blac3777 3:251e4d020501 49 //Turn off LED indicator(s): controller is NOT in range.
blac3777 3:251e4d020501 50 led1 = led2 = led3 = led4 = 0;
blac3777 3:251e4d020501 51 return 0;
blac3777 3:251e4d020501 52 }
blac3777 3:251e4d020501 53 }
blac3777 3:251e4d020501 54
blac3777 3:251e4d020501 55 void printNumber(int x, int y, uint8_t number) {
blac3777 3:251e4d020501 56 //tft.fillRectangle(0, 0, 175, 91, COLOR_BLACK);
blac3777 3:251e4d020501 57 tft.setFont(Terminal12x16);
blac3777 3:251e4d020501 58
blac3777 3:251e4d020501 59 if(number == 0)
blac3777 3:251e4d020501 60 tft.drawText(x, y, "0", COLOR_WHITE);
blac3777 3:251e4d020501 61 else if(number == 1)
blac3777 3:251e4d020501 62 tft.drawText(x, y, "1", COLOR_WHITE);
blac3777 3:251e4d020501 63 else if(number == 2)
blac3777 3:251e4d020501 64 tft.drawText(x, y, "2", COLOR_WHITE);
blac3777 3:251e4d020501 65 else if(number == 3)
blac3777 3:251e4d020501 66 tft.drawText(x, y, "3", COLOR_WHITE);
blac3777 3:251e4d020501 67 else if(number == 4)
blac3777 3:251e4d020501 68 tft.drawText(x, y, "4", COLOR_WHITE);
blac3777 3:251e4d020501 69 else if(number == 5)
blac3777 3:251e4d020501 70 tft.drawText(x, y, "5", COLOR_WHITE);
blac3777 3:251e4d020501 71 else if(number == 6)
blac3777 3:251e4d020501 72 tft.drawText(x, y, "6", COLOR_WHITE);
blac3777 3:251e4d020501 73 else if(number == 7)
blac3777 3:251e4d020501 74 tft.drawText(x, y, "7", COLOR_WHITE);
blac3777 3:251e4d020501 75 else if(number == 8)
blac3777 3:251e4d020501 76 tft.drawText(x, y, "8", COLOR_WHITE);
blac3777 3:251e4d020501 77 else if(number == 9)
blac3777 3:251e4d020501 78 tft.drawText(x, y, "9", COLOR_WHITE);
blac3777 3:251e4d020501 79 else if(number == 10)
blac3777 3:251e4d020501 80 tft.drawText(x, y, "10", COLOR_WHITE);
blac3777 3:251e4d020501 81 else if(number == 11)
blac3777 3:251e4d020501 82 tft.drawText(x, y, "11", COLOR_WHITE);
blac3777 3:251e4d020501 83 else if(number == 12)
blac3777 3:251e4d020501 84 tft.drawText(x, y, "12", COLOR_WHITE);
blac3777 3:251e4d020501 85 else if(number == 13)
blac3777 3:251e4d020501 86 tft.drawText(x, y, "13", COLOR_WHITE);
blac3777 3:251e4d020501 87 else if(number == 14)
blac3777 3:251e4d020501 88 tft.drawText(x, y, "14", COLOR_WHITE);
blac3777 3:251e4d020501 89 else if(number == 15)
blac3777 3:251e4d020501 90 tft.drawText(x, y, "15", COLOR_WHITE);
blac3777 3:251e4d020501 91 else
blac3777 3:251e4d020501 92 tft.drawText(x, y, "?", COLOR_WHITE);
blac3777 3:251e4d020501 93 }
blac3777 3:251e4d020501 94
blac3777 3:251e4d020501 95 void printElementsInPicture() {
blac3777 3:251e4d020501 96 tft.fillRectangle(0, 0, 175, 91, COLOR_BLACK);
blac3777 3:251e4d020501 97 for(int i = 0; i < 16; i++)
blac3777 3:251e4d020501 98 printNumber((40*(i%4)) + 8, (20*((i - (i%4))/4)) + 8, puzzState[i]);
blac3777 3:251e4d020501 99 }
blac3777 3:251e4d020501 100
blac3777 3:251e4d020501 101 //Put contents of pictureN at target index on GLCD specified by 'index'.
blac3777 3:251e4d020501 102 void printPictureN(int index, int N) {
blac3777 3:251e4d020501 103 int c = index%4;
blac3777 3:251e4d020501 104 int r = (index - c)/4;
blac3777 3:251e4d020501 105
blac3777 3:251e4d020501 106 if(N > 13) {
blac3777 3:251e4d020501 107 tft.fillRectangle((39*c) + 11, (29*r) + 95,
blac3777 3:251e4d020501 108 (39*c) + 47, (29*r) + 121, COLOR_BLACK);
blac3777 3:251e4d020501 109 return;
blac3777 3:251e4d020501 110 }
blac3777 3:251e4d020501 111 for(int x = (39*c) + 11; x <= (39*c) + 47; x++) {
blac3777 3:251e4d020501 112 for(int y = (29*r) + 95; y <= (29*r) + 121; y++)
blac3777 3:251e4d020501 113 tft.drawPixel(x, y, picture[(999*N) + (4*y) + x]);
blac3777 3:251e4d020501 114 }
blac3777 3:251e4d020501 115 }
blac3777 3:251e4d020501 116
blac3777 3:251e4d020501 117 void updatePuzzle() {
blac3777 3:251e4d020501 118 for(int N = 0; N < 16; N++)
blac3777 3:251e4d020501 119 printPictureN(N, puzzState[N]);
blac3777 3:251e4d020501 120 }
blac3777 3:251e4d020501 121
blac3777 3:251e4d020501 122 int getNextPixel_index = 0;
blac3777 3:251e4d020501 123
blac3777 3:251e4d020501 124 //**TODO** replace the contents of the following method with the code necessary
blac3777 3:251e4d020501 125 //to get the next pixel from the OV7670. The method, in its current state, is
blac3777 3:251e4d020501 126 //good for testing purposes. You should also be able to remove the
blac3777 3:251e4d020501 127 //'getNextPixel_index' variable if you correctly implement this new method.
blac3777 3:251e4d020501 128 uint16_t getNextPixel() {
blac3777 3:251e4d020501 129 uint16_t value = 0;
blac3777 3:251e4d020501 130
blac3777 3:251e4d020501 131 int x, y;
blac3777 3:251e4d020501 132
blac3777 3:251e4d020501 133 if(getNextPixel_index > 19199) {
blac3777 3:251e4d020501 134 getNextPixel_index = 0;
blac3777 3:251e4d020501 135 x = 0;
blac3777 3:251e4d020501 136 }
blac3777 3:251e4d020501 137 else
blac3777 3:251e4d020501 138 x = getNextPixel_index%160;
blac3777 3:251e4d020501 139 y = (getNextPixel_index - x)/160;
blac3777 3:251e4d020501 140
blac3777 3:251e4d020501 141 //Is pixel in one of 4 outer pieces (corners)?
blac3777 3:251e4d020501 142 if((x >= 0 && x <= 40) && (y >= 0 && y <= 30)) //Upper left corner.
blac3777 3:251e4d020501 143 value = 65535;
blac3777 3:251e4d020501 144 if((x >= 119 && x <= 159) && (y >= 0 && y <= 30)) //Upper right corner.
blac3777 3:251e4d020501 145 value = 52428;
blac3777 3:251e4d020501 146 if((x >= 0 && x <= 40) && (y >= 89 && y <= 119)) //Lower left corner.
blac3777 3:251e4d020501 147 value = 13107;
blac3777 3:251e4d020501 148 if((x >= 119 && x <= 159) && (y >= 89 && y <= 119)) //Lower right corner.
blac3777 3:251e4d020501 149 value = 0;
blac3777 3:251e4d020501 150
blac3777 3:251e4d020501 151 //Is pixel in one of 4 outer pieces (left and right)?
blac3777 3:251e4d020501 152 if((x >= 0 && x <= 40) && (y >= 31 && y <= 59)) //Upper left side.
blac3777 3:251e4d020501 153 value = 48059;
blac3777 3:251e4d020501 154 if((x >= 0 && x <= 40) && (y >= 60 && y <= 88)) //Lower left side.
blac3777 3:251e4d020501 155 value = 30583;
blac3777 3:251e4d020501 156 if((x >= 119 && x <= 159) && (y >= 31 && y <= 59)) //Upper right side.
blac3777 3:251e4d020501 157 value = 34952;
blac3777 3:251e4d020501 158 if((x >= 119 && x <= 159) && (y >= 60 && y <= 88)) //Lower right side.
blac3777 3:251e4d020501 159 value = 17476;
blac3777 3:251e4d020501 160
blac3777 3:251e4d020501 161 //Is pixel in one of 4 outer pieces (top and bottom)?
blac3777 3:251e4d020501 162 if((x >= 41 && x <= 79) && (y >= 0 && y <= 30)) //Left top side.
blac3777 3:251e4d020501 163 value = 61166;
blac3777 3:251e4d020501 164 if((x >= 80 && x <= 118) && (y >= 0 && y <= 30)) //Right top side.
blac3777 3:251e4d020501 165 value = 56797;
blac3777 3:251e4d020501 166 if((x >= 41 && x <= 79) && (y >= 89 && y <= 119)) //Left bottom side.
blac3777 3:251e4d020501 167 value = 8738;
blac3777 3:251e4d020501 168 if((x >= 80 && x <= 118) && (y >= 89 && y <= 119)) //Right bottom side.
blac3777 3:251e4d020501 169 value = 0;
blac3777 3:251e4d020501 170
blac3777 3:251e4d020501 171 //Is pixel in one of 4 inner pieces?
blac3777 3:251e4d020501 172 if((x >= 41 && x <= 79) && (y >= 31 && y <= 59)) //Upper left inner piece.
blac3777 3:251e4d020501 173 value = 43690;
blac3777 3:251e4d020501 174 if((x >= 80 && x <= 118) && (y >= 31 && y <= 59)) //Upper right inner piece.
blac3777 3:251e4d020501 175 value = 39321;
blac3777 3:251e4d020501 176 if((x >= 41 && x <= 79) && (y >= 60 && y <= 88)) //Lower left inner piece.
blac3777 3:251e4d020501 177 value = 26214;
blac3777 3:251e4d020501 178 if((x >= 80 && x <= 118) && (y >= 60 && y <= 88)) //Lower right inner piece.
blac3777 3:251e4d020501 179 value = 21845;
blac3777 3:251e4d020501 180
blac3777 3:251e4d020501 181 getNextPixel_index++;
blac3777 3:251e4d020501 182
blac3777 3:251e4d020501 183 return value;
blac3777 3:251e4d020501 184 }
blac3777 3:251e4d020501 185
blac3777 3:251e4d020501 186 void handlePixel(int index, uint16_t pixel) {
blac3777 3:251e4d020501 187 int x = index%160;
blac3777 3:251e4d020501 188 int y = (index - x)/160;
blac3777 3:251e4d020501 189 if((x >= 3 && x <= 39) && (y >= 3 && y <= 29))
blac3777 3:251e4d020501 190 picture[37*y + x - 114] = pixel;
blac3777 3:251e4d020501 191 else if((x >= 42 && x <= 78) && (y >= 3 && y <= 29))
blac3777 3:251e4d020501 192 picture[37*y + x - 153 + 999] = pixel;
blac3777 3:251e4d020501 193 else if((x >= 81 && x <= 117) && (y >= 3 && y <= 29))
blac3777 3:251e4d020501 194 picture[37*y + x - 192 + 1998] = pixel;
blac3777 3:251e4d020501 195 else if((x >= 120 && x <= 156) && (y >= 3 && y <= 29))
blac3777 3:251e4d020501 196 picture[37*y + x - 231 + 2997] = pixel;
blac3777 3:251e4d020501 197 else if((x >= 3 && x <= 39) && (y >= 32 && y <= 58))
blac3777 3:251e4d020501 198 picture[37*y + x - 1187 + 3996] = pixel;
blac3777 3:251e4d020501 199 else if((x >= 42 && x <= 78) && (y >= 32 && y <= 58))
blac3777 3:251e4d020501 200 picture[37*y + x - 1226 + 4995] = pixel;
blac3777 3:251e4d020501 201 else if((x >= 81 && x <= 117) && (y >= 32 && y <= 58))
blac3777 3:251e4d020501 202 picture[37*y + x - 1265 + 5994] = pixel;
blac3777 3:251e4d020501 203 else if((x >= 120 && x <= 156) && (y >= 32 && y <= 58))
blac3777 3:251e4d020501 204 picture[37*y + x - 1304 + 6993] = pixel;
blac3777 3:251e4d020501 205 else if((x >= 3 && x <= 39) && (y >= 61 && y <= 87))
blac3777 3:251e4d020501 206 picture[37*y + x - 2260 + 7992] = pixel;
blac3777 3:251e4d020501 207 else if((x >= 42 && x <= 78) && (y >= 61 && y <= 87))
blac3777 3:251e4d020501 208 picture[37*y + x - 2299 + 8991] = pixel;
blac3777 3:251e4d020501 209 else if((x >= 81 && x <= 117) && (y >= 61 && y <= 87))
blac3777 3:251e4d020501 210 picture[37*y + x - 2338 + 9990] = pixel;
blac3777 3:251e4d020501 211 else if((x >= 120 && x <= 156) && (y >= 61 && y <= 87))
blac3777 3:251e4d020501 212 picture[37*y + x - 2377 + 10989] = pixel;
blac3777 3:251e4d020501 213 else if((x >= 3 && x <= 39) && (y >= 90 && y <= 116))
blac3777 3:251e4d020501 214 picture[37*y + x - 3333 + 11988] = pixel;
blac3777 3:251e4d020501 215 else if((x >= 42 && x <= 78) && (y >= 90 && y <= 116))
blac3777 3:251e4d020501 216 picture[37*y + x - 3372 + 12987] = pixel;
blac3777 3:251e4d020501 217 }
blac3777 3:251e4d020501 218
blac3777 3:251e4d020501 219 //A utility function to swap 2 numbers
blac3777 3:251e4d020501 220 void swap(uint8_t *a, uint8_t *b) {
blac3777 3:251e4d020501 221 uint8_t temp = *a;
blac3777 3:251e4d020501 222 *a = *b;
blac3777 3:251e4d020501 223 *b = temp;
blac3777 3:251e4d020501 224 }
blac3777 3:251e4d020501 225
blac3777 3:251e4d020501 226 void shuffleGridIndices() {
blac3777 3:251e4d020501 227 int n = sizeof(puzzState)/sizeof(puzzState[0]);
blac3777 3:251e4d020501 228
blac3777 3:251e4d020501 229 //Use a different seed value so that we don't get same result each time we
blac3777 3:251e4d020501 230 //run this program.
blac3777 3:251e4d020501 231 srand(time(NULL));
blac3777 3:251e4d020501 232
blac3777 3:251e4d020501 233 //Start from the last element and swap one by one. We don't need to run for
blac3777 3:251e4d020501 234 //the first element, which is why i > 0.
blac3777 3:251e4d020501 235 for (int i = n-1; i > 0; i--) {
blac3777 3:251e4d020501 236 int j = rand()%(i+1); //Pick a random index b.w. 0 & i.
blac3777 3:251e4d020501 237 swap(&puzzState[i], &puzzState[j]); //Swap w| element @ random index.
blac3777 3:251e4d020501 238 }
blac3777 3:251e4d020501 239 }
blac3777 3:251e4d020501 240
blac3777 3:251e4d020501 241 //This method puts a picture on the screen that is/was helpful during testing.
blac3777 3:251e4d020501 242 void putTestPicture() {
blac3777 3:251e4d020501 243 //Add 4 outer pieces (corners).
blac3777 3:251e4d020501 244 tft.fillRectangle(8, 92, 48, 122, 65535); //Upper left corner.
blac3777 3:251e4d020501 245 tft.fillRectangle(127, 92, 167, 122, 52428); //Upper right corner.
blac3777 3:251e4d020501 246 tft.fillRectangle(8, 181, 48, 211, 13107); //Lower left corner.
blac3777 3:251e4d020501 247 tft.fillRectangle(127, 181, 167, 211, 0); //Lower right corner.
blac3777 3:251e4d020501 248
blac3777 3:251e4d020501 249 //Add 4 outer pieces (left and right).
blac3777 3:251e4d020501 250 tft.fillRectangle(8, 123, 48, 151, 48059); //Upper left side.
blac3777 3:251e4d020501 251 tft.fillRectangle(8, 152, 48, 180, 30583); //Lower left side.
blac3777 3:251e4d020501 252 tft.fillRectangle(127, 123, 167, 151, 34952); //Upper right side.
blac3777 3:251e4d020501 253 tft.fillRectangle(127, 152, 167, 180, 17476); //Lower right side.
blac3777 3:251e4d020501 254
blac3777 3:251e4d020501 255 //Add 4 outer pieces (top and bottom).
blac3777 3:251e4d020501 256 tft.fillRectangle(49, 92, 87, 122, 61166); //Left top side.
blac3777 3:251e4d020501 257 tft.fillRectangle(88, 92, 126, 122, 56797); //Right top side.
blac3777 3:251e4d020501 258 tft.fillRectangle(49, 181, 87, 211, 8738); //Left bottom side.
blac3777 3:251e4d020501 259 tft.fillRectangle(88, 181, 126, 211, 0); //Right bottom side.
blac3777 3:251e4d020501 260
blac3777 3:251e4d020501 261 //Add 4 inner pieces.
blac3777 3:251e4d020501 262 tft.fillRectangle(49, 123, 87, 151, 43690); //Upper left inner piece.
blac3777 3:251e4d020501 263 tft.fillRectangle(88, 123, 126, 151, 39321); //Upper right inner piece.
blac3777 3:251e4d020501 264 tft.fillRectangle(49, 152, 87, 180, 26214); //Lower left inner piece.
blac3777 3:251e4d020501 265 tft.fillRectangle(88, 152, 126, 180, 21845); //Lower right inner piece.
blac3777 3:251e4d020501 266 }
blac3777 3:251e4d020501 267
blac3777 3:251e4d020501 268 void putGrid() {
blac3777 3:251e4d020501 269 tft.drawRectangle(8, 92, 167, 211, COLOR_WHITE);
blac3777 3:251e4d020501 270 tft.drawRectangle(9, 93, 166, 210, COLOR_WHITE);
blac3777 3:251e4d020501 271
blac3777 3:251e4d020501 272 for(int r = 0; r < 4; r++) {
blac3777 3:251e4d020501 273 for(int c = 0; c < 4; c++)
blac3777 3:251e4d020501 274 tft.drawRectangle(39*c + 10, 29*r + 94, 39*c + 48, 29*r + 122,
blac3777 3:251e4d020501 275 COLOR_WHITE);
blac3777 3:251e4d020501 276 }
blac3777 3:251e4d020501 277 }
blac3777 3:251e4d020501 278
blac3777 3:251e4d020501 279 void highlightGridIndex(uint8_t index, bool hasSelected) {
blac3777 3:251e4d020501 280 int c = index%4;
blac3777 3:251e4d020501 281 int r = (index - c)/4;
blac3777 3:251e4d020501 282 putGrid();
blac3777 3:251e4d020501 283 if(hasSelected) //Red highlight means player has selected an index.
blac3777 3:251e4d020501 284 tft.drawRectangle(39*c + 10, 29*r + 94, 39*c + 48, 29*r + 122,
blac3777 3:251e4d020501 285 COLOR_RED);
blac3777 3:251e4d020501 286 if(!hasSelected) //Green highlight means player has not selected an index.
blac3777 3:251e4d020501 287 tft.drawRectangle(39*c + 10, 29*r + 94, 39*c + 48, 29*r + 122,
blac3777 3:251e4d020501 288 COLOR_GREEN);
blac3777 3:251e4d020501 289 cursorIndex = index;
blac3777 3:251e4d020501 290 }
blac3777 3:251e4d020501 291
blac3777 3:251e4d020501 292 bool selectionMode_indexVerified(uint8_t index) {
blac3777 3:251e4d020501 293 //index must satisfy 2 characteristics for method to return true.
blac3777 3:251e4d020501 294
blac3777 3:251e4d020501 295 //1) Target puzzle piece is NOT one of the 2 missing puzzle pieces.
blac3777 3:251e4d020501 296 if(puzzState[index] > 13)
blac3777 3:251e4d020501 297 return false;
blac3777 3:251e4d020501 298
blac3777 3:251e4d020501 299 //2) Target puzzle piece is NOT locked on all 4 sides.
blac3777 3:251e4d020501 300 if(index - 4 > -1) { //NOT out of bounds above.
blac3777 3:251e4d020501 301 if(puzzState[index - 4] > 13) //Empty space above?
blac3777 3:251e4d020501 302 return true;
blac3777 3:251e4d020501 303 }
blac3777 3:251e4d020501 304 if(index + 4 < 16) { //NOT out of bounds below.
blac3777 3:251e4d020501 305 if(puzzState[index + 4] > 13) //Empty space below?
blac3777 3:251e4d020501 306 return true;
blac3777 3:251e4d020501 307 }
blac3777 3:251e4d020501 308 if((index%4) - 1 > -1) { //NOT out of bounds to the left.
blac3777 3:251e4d020501 309 if(puzzState[index - 1] > 13) //Empty space to the left?
blac3777 3:251e4d020501 310 return true;
blac3777 3:251e4d020501 311 }
blac3777 3:251e4d020501 312 if((index%4) + 1 < 4) { //NOT out of bounds to the right.
blac3777 3:251e4d020501 313 if(puzzState[index + 1] > 13) //Empty space to the right?
blac3777 3:251e4d020501 314 return true;
blac3777 3:251e4d020501 315 }
blac3777 3:251e4d020501 316
blac3777 3:251e4d020501 317 return false;
blac3777 3:251e4d020501 318 }