Click here and the assortment of tiles you saw last week should show up once again. However, there is an important difference this time. Try dragging the tiles up, down, left and right. Notice anything?
That's right! The tiles move now!
How I did this was by using a two-dimensional array. What that means is that you have one array (we'll call it "tileGrid"), and each slot in that array is another array. Each slot in the first array represents a row of tiles, and each slot in each of the other arrays represents a single tile. However, it's not as easy as that, because when you move the tiles, the arrays get messed up. TileGrid[0][0] might now be at position (0, 4). So you can't just write a for loop shifting every tile up or down by 1 for each scroll and expect it to work after you've moved the tiles more than once. The underlying array has to line up with what's displayed on the screen.
I fixed this by having the array shift along with the tiles. Another exceedingly obvious problem that caused me to pull my hair out because I couldn't figure it out at first. All part of the learning process, I guess.
After this I just have to work on the actual game aspect--in other words, selecting and checking words from the tile grid.
No comments:
Post a Comment