Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Match-3 Engine: Has it already been done?

Author
Message
Mr909
11
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 13th Dec 2012 22:01
I'm looking to create an advanced match-3 game (a la Bejeweled and it's countless ripoffs) and I was wondering if someone had already coded a base for it (because frankly, the code is giving me hell. The grid has to be both an array (for checking it) and a list of objects (to properly account for the tiles falling in a visually appealing way, and only checking once they're in place)

I plan to essentially evolve it along the lines of a monster training game, stats and all, where the game board serves to charge energy that fuels the attacks. It would be MUCH easier if someone's already laid the groundwork.

If it hasn't been done, I understand, but anything that could help ease the burden would be great.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th Dec 2012 11:30 Edited at: 15th Dec 2012 11:36
You could make an array, like "dim gem_array(11,10)" for a 10x10 gem board. Then you could have every gem above line 1 check if the spot underneath have become empty or is about to become empty.

gem_array(11,10) = 5 (then the spot is becoming empty)
gem_array(11,10) = 1-4 (spot is occupied)


The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th Dec 2012 15:21
How do you want to match 3? Vertical, horizontal and diagonal?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Mr909
11
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 15th Dec 2012 23:25
I want to use all of Bejeweled 3's matches, that is to say:

L/T Junctions
3, 4, and 5 vertical/horizontal
No diagonals.

And have each create special gems, like in Bejeweled.
Here's the source code. Currently, it is making the mistake of checking gems that have not yet fallen into place, and there's ALWAYS something weird with the array indices.

I'm giving up for now. Check it out if you'd like.

Attachments

Login to view attachments
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 17th Dec 2012 20:36
What do you mean by L/T junctions? (I don't play Bejeweled)

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 26th Dec 2012 13:23
Ah, match-x engine. I wish I had the time (and was at my pc) to put this in code or better elaborate. I'll just throw this nugget in:
Use a single-dimensional array to store the "gems".
Maths does the rest eg:
sizeX = 5, sizeY = 10, sizeTotal = sizeX * sizeY
DIM myGems(sizeTotal)
Now match verticals using ((currentGem + sizeX) * numMatches ) where nuMatches specifies the match you're seeking, eg 3.
Now match diagonals the same way but inc/dec 1 each round for right/left.
Horizontals are straight-forward.
The accessing and shifting is simple-math. Much like pixek-buffer manipulation.

Mr909
11
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 26th Dec 2012 18:47 Edited at: 26th Dec 2012 18:50
@nonZero: Well, the reason I didn't track the grid in a single array is that it won't account for gem falling, since I want to do it all pretty-like. If I do the falling with the single array and the storage with a two-dimensional array, it becomes simpler.

@Cybermind: L/T junctions are as such:


X X
X X


X X
X X

Both of which create the same "Star" gem, which clears the whole row. and column at the point where it is cleared (via explosion or matching)

Login to post a reply

Server time is: 2024-04-23 10:46:48
Your offset time is: 2024-04-23 10:46:48