arrays

Matt Barton's picture

Dev Diary 019: Match 3 Invaders with Arrays

When I woke up this morning I suddenly understood how to do all my matches with arrays instead of raycasts. There really is something to be said about "sleeping on it" and that your unconscious brain will figure out stuff that just isn't clear to you otherwise. The first breakthrough was realizing that I could create an array to hold all the enemy game objects, then populate each element as I build the fleet. Then I could assign an array column and row number to each enemy. An enemy to the left or right is -1 and +1, top and bottom -6 and +6. I could use the row numbers to eliminate the problem of the leftmost or rightmost columns getting mixed up. Instead of raycasting, I can simply check to see if the element exists and is in the proper row or column. Viola! No more misses!

Syndicate content