carlfoxmarten: (Default)
[personal profile] carlfoxmarten
I had quite a productive day yesterday.

I'd been having problems figuring out the best way to recognize the matching blocks, as it's something I've never come across before.

Something that helped me was realizing that I may need some of that information while drawing, so caching the information was a good idea.
This means that I have two functions that work together to remove matching sets of blocks.

The first one checks for all matches and stores its results in temporary arrays while we wait for the logic to decide if it wants to start removing them.
It assigns each grid cell a "set number" that all adjacent cells that match will have, as well as storing the number of cells each set has in another array.

That data is then scanned to see if any set has at least three cells in it.
If so, we have matches that should get removed as soon as possible.

The removal function is fairly trivial as well, though it took a while to get right.
It scans through the whole grid, checking to see if each cell is supposed to get removed.
Each cell that needs to be removed gets blanked out with null values as markers so we don't accidentally miss any removals.
We then drop each existing cell that is above an empty space down as far as it can go, and fill the remaining in with new cells.

It's working rather well, too.

However, I think there's a bug in there somewhere that causes it to remove more cells than necessary.
Sometimes when I'm sliding a line around, I know for certain that I'll only create a certain number of matches, but it removes far more than that.

If I have you on Facebook or Google+, I've already posted screen shots so you can see them.
I probably won't be posting much of this on DA or FA, as I'll be releasing this under my real name, but I might post a couple of screen shots when the game is finally released for advertising purposes.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

carlfoxmarten: (Default)
Carl Foxmarten

August 2023

S M T W T F S
  12 345
6789101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 27th, 2025 03:12 pm
Powered by Dreamwidth Studios