I'm working on a boggle type game for android, using libgdx. The user is presented with a 4x4 grid of letters and must find words by dragging their finger over the letters.

Unlike boggle I want used letters to disappear. Remaining letters will fall down (to the bottom of the board, screen orientation is fixed) and the board is refilled from the top. Users can rotate the board to try and put hard to use letters in a better place by strategic word selection.

An example:

d g a o
u o r T
h v R I
d G n a

If i selected the word GRIT, those letters would disappear and the remaining fall down:

u g a
h o r o
d v n a

and then get replaced by new letters

d w x y
u g a z
h o r o
d v n a

I'm stuck figuring out how to represent the board and tiles.

I tried representing the board as a matrix to keep track of tiles selected and valid moves and the tiles stored in a matrix as well so that there was an easy mapping. This works, but I had to write some convoluted code to rotate the board.

How do other games handle this problem?

EDIT: So thinking about it, I should really just process my touch point according to the board rotation so cells stay constant. Attached an image of what I'm thinking.Process screen touch so board orientation never changes

  • 1
    \$\begingroup\$ You mean that direction, to which letters are falling, depends on device orientation? Could you also elaborate that do you mean by "screwed up when I want to rotate the tiles". \$\endgroup\$
    – pabdulin
    Commented Jul 31, 2014 at 4:48
  • \$\begingroup\$ I meant that my mapping from board location to tile location was a very convoluted once I made a rotation. However, I think I can solve this problem if I think of the board as rotating about the origin of a coordinate system instead of all the tiles changing places... \$\endgroup\$ Commented Jul 31, 2014 at 4:52
  • \$\begingroup\$ Thanks for the update. It's usually better to update the question itself, so other would not need to dig into comments for valuable info. It's still not clear to me how rotation is performed (now), what it the result, and how it actually makes tracking difficult. It's not clear if the full board is rotated or individial tiles only. Usually adding code fragments is of a great help to understanding the problem. \$\endgroup\$
    – pabdulin
    Commented Jul 31, 2014 at 5:07
  • \$\begingroup\$ I think I was going about the problem all wrong, processing the users touch point according to the rotation will allow me to think of the board as a static object. \$\endgroup\$ Commented Jul 31, 2014 at 5:13
  • \$\begingroup\$ Please put this in an answer and accept your answer if you have found the solution to your problem; otherwise you can keep this open if you're still not 100% sure. The term to describe your proposed solution is "space translation", i.e. you are translating your touch point between screen space and (rotated) board space. \$\endgroup\$
    – Engineer
    Commented Mar 24, 2016 at 18:57

2 Answers 2


I would not use arrays for this at all because managing it will get more and more complex. Make a custom Board data-structure with Nodes that have references to their neighbors. This is essentially a multi-dimensional LinkedList of Nodes. In that way, if a node's letter is removed, other nodes can view this in an encapsulated way. This avoids complicated array arithmetic. You will need one big function to get everything connected correctly, but once linked the logic should be much easier to work with.

Your edge nodes will have neighbors set to null, so make sure to handle that accordingly in your methods in the Node class that need to refer to neighbors.

I have used this approach for implementing Conway's Game Of Life and once you get it set up, it drastically decreases the complexity of adding logic that changes the state of a Node based on neighbors.

Depending on how you are manipulating the nodes in the board, you may need one board method to iterate through and determine the next state or action and save that within each node. Then follow that by iterating and committing each node to the new state. This avoids having nodes determining their next state by looking at nodes that have already changed.

enter image description here


Yes the solution is you get value from your matrix or array and set That value for temp array or matrix and Then set value from there this is show you your rotate value gird. I added code below i think its help you

    int MAX_GRID = 4;
    int[][] main_array = new int[MAX_GRID][MAX_GRID];
    int[][] temp_array = new int[MAX_GRID][MAX_GRID];

    /** This method for clockwise **/
    int mainRow = MAX_GRID - 1;
    for (int c = 0; c < MAX_GRID; c++) {
        for (int r = 0; r < MAX_GRID; r++) {
            temp_array [mainRow][c] = main_array [r][c];
            Log.i("TAG", "R C : [ " + mainRow + " " + c + " ]" + " => [ "
                    + r + " " + c + " ]");
    main_array = temp_array;

    /** This method for anti-clockwise **/
    int mainCol = 0;
    for (int c = MAX_GRID - 1; c >= 0; c--) {
        for (int r = MAX_GRID - 1; r >= 0; r--) {
            temp_array [r][mainCol] = main_array [c][r];
            Log.i("TAG", "R C : [ " + r + " " + mainCol + " ]" + " => [ "
                    + c + " " + r + " ]");
    main_array = temp_array;

    // Now you can set main_array value then its rotate

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .