Dev Diary 019: Match 3 Invaders with Arrays

Matt Barton's picture

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!

NO MORE MISSES! Woohoo! Woohoo!

I had to do some pretty extensive surgery on the code, so I might have introduced new errors. But after several playtests, I'm not seeing any missed matches or lingering orphans. Plus, it seems to be running more smoothly even in edit mode.

All right! Now I feel like I'm finally closing that gap. I plan to add two new enemy types today, perhaps a bonus rocket or something, and from there on it's just a matter of polish.

Unity Web Player | WebPlayer


TripHamer's picture
Joined: 07/31/2010
Array' your

Array' your talking!!!!! :D


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.