I already know how to fill in the grid for the game and i know how to remove the objects when the user selects a pair.

The problem is, i am not sure how to fill in spaces when objects are removed.

For example, if 2 items are removed from row 1 and 1 item is removed from row 2. what would be the algorithm to drop the items in row 2 down to slots, and the items in row 1 down 1 position above where the item was removed.

I hope i exlained my question well. For this game i will be using Libgdx(which is java) so any java pseudocode will be GREAT. I will also be using sprites of libgdx and tween engine to move objects.

So this was off the top of my head, sorry if it won't compile . Anyway, the moveBy is a scene2D function. You may have your own implementation here of course (like setting a boolean doFall or something) and have the occupants update each frame or something like that.

Judging from that statement I would say you need to take a step back fromd games and try to learn Java first. That is of a multi deminsional array type, which pretty much means it holds a bunch of references to blocks of memory (your objects). This is basic coding though, and I highly stress you stop trying to make a game and spend the time to learn programming first. You're only hurting yourself right now.

Judging from that statement I would say you need to take a step back fromd games and try to learn Java first. That is of a multi deminsional array type, which pretty much means it holds a bunch of references to blocks of memory (your objects). This is basic coding though, and I highly stress you stop trying to make a game and spend the time to learn programming first. You're only hurting yourself right now.

LOL. Actually i know java very well. I was asking what data type is it. Sprite, int, etc. ;-) I am fully aware of what an array is. This is like my 5th game. Just not sure how the match-3 thing works.

Well if you do it with scene2D you don't need to update them manually, you just add the action. But if you do the other method, where you set a boolean (like needsToFall or something), then you iterate through each of your Cell-occupants (extensions of Sprite), check if they need to fall (have the boolean set to true) and update their y-position accordingly.

Edit: Also, once they've fallen CELL_SIZE update the cell below to hold a reference to the sprite, set the needToFall boolean to false, so they don't fall forever

It first checks if a cell is empty or needs to fall. Then, if it is empty, we go up one row and move that item down to the empty position, and this will continue to happen for all the empty positions until the loop finishes? Correct?

But what if, more than 1 item is removed from a column? Or if more than 1 item is empty in column?

I ask because in my game, the user can connect as many matching sprites as possible. This means they can remove more than 1 item from a column, vs jus 3.

publicvoidscanForDrops(intmaxX, intmaxY){intspaces = 0; //counts spacesintoccupantsAbove = 0; //occupants above the point the loop is atbooleanfirstOccupantFound = false; //becomes true when the first cell in the column with a Piece is foundfor(intx = 0; x < maxX; x++) {spaces = 0; occupantsAbove = 0; firstOccupantFound = false;for(inty = 0; y < maxY; y++) {if(cell[x][y].hasOccupant() ) {if(!firstOccupantFound) {firstOccupantFound = true; }occupantsAbove++; }elseif(!cell[x][y].hasOccupant() && firstOccupantFound) //spaces above the first occupant dont matter {spaces = checkSpaces(x, y, maxY); //gets spaces under this starting at this pointdropAbove(x, y--, occupantsAbove, spaces); //drops all the pieces spaces amount of times starting at the piece above this spacey+= spaces + 1; //puts y down past the spaces and one extra because we did a y-- on the last linespaces = 0; //now there are no spaces in between and itll keep checking down the line }

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org