Thursday, July 4, 2019

java - Match-3 algorithm to fill empty space left from removing matches


I am currently creating a match 3 game.


I am at the point where I have objects dropping down in the column when only one item is removed. So if an item is removed, the above item moves into its old position etc.


The problem I am having now is that when more than one item is removed from a column, the items in that column only drop down to the first item that was removed. Instead of filling in both items that were removed it just drops down to fill in the first one.


So basically, if two(or more) items are removed from a column the second, third, fourth, etc positions are left blank.



The way I am designing my game is I am using units of 1. So each item takes up 1 unit by x and 1 unit by y. This means that I can position the items like in a grid, at 0x1, 0x2, etc.


What kind of algorithm could I use to move multiple items down to fill the empty space?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...