[FMX] LINES help

Hi there!

Does anybody know what methods should I use creating a game such as Lines. The biggest problem is that I don’t know what AS to write to check when the 5 or more bubbles are in line and when they must dissapear. How I can do this? Any help? Thanks!