[ 14 posts ]  Reply to topicPost new topic 
Author Message
 [us]
 Post subject: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 6:58 am 
User avatar
Just that RANDOM GUY!
Member
[*]
[*]
[*]
[*]
So me, and a friend are working on something small for an indie game.
It's basically a Puyo Puyo game. We're not trying much here. :P

But I've been messing around with GameMaker Studio for days, and countless hours, and I couldn't figure anything out.
Anyone know what I can do to check if there is a combo of a specific color in a pattern of 4?
Here's an example of what I'm trying to replicate in Studio:




I already figured out how to make them stack, as well as combine with other puyos of the same color...
But I have no clue how I can check for a combo.
Some info to help: Each color is a separate object but they're all under the same parent object.

This is what I have so far: (Pay no mind to the bad sprites, we started development 3 days ago, and we're not focused on graphics rn.

Image

_________________
Rest in peace Satoru Iwata. (1959-2015) You will always live on in our hearts.

I'm just a random guy named Nick! I like to make games, program, design sprites/art, and play Nintendo games.
Check out my cool fangame: SUPER MARIO Power Star Frenzy! A twist to the collectathon style Mario games. [PRIORITY]
Check out my other fangame: SUPER MARIO Dimension Dilemma! A SSBB Subspace Emissary styled Mario fangame.


Image Image Image Image

Power Star Frenzy Progress Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [br]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 9:23 am 
User avatar
Not a bird
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
Use a global variable that increases every time one combo is done.

_________________
Please contact me for any broken links below.
Spoiler:

Spoiler:
 
Top
Offline 
 
 
 [us]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 10:24 am 
User avatar
Just that RANDOM GUY!
Member
[*]
[*]
[*]
[*]
What...? I'm trying to check FOR a combo. NOT when one is done.

_________________
Rest in peace Satoru Iwata. (1959-2015) You will always live on in our hearts.

I'm just a random guy named Nick! I like to make games, program, design sprites/art, and play Nintendo games.
Check out my cool fangame: SUPER MARIO Power Star Frenzy! A twist to the collectathon style Mario games. [PRIORITY]
Check out my other fangame: SUPER MARIO Dimension Dilemma! A SSBB Subspace Emissary styled Mario fangame.


Image Image Image Image

Power Star Frenzy Progress Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 2:36 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
I kinda thought you meant checking for adjacent structures of the same color, but your description was pretty ambiguous.
What I would do is check all adjacent structures, and if they are of the same color save them to a list and perform the same check for them (disregarding objects that are already in the list).

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 2:53 pm 
Real horses don't run into trees
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Assume you have no combo currently. This means that the start of your search is the new blobs that just came in, or in other words, you only need to look at all the blobs that just moved.

For these new blobs, do this:
- remember the color of the blob you're checking
- create an empty queue
- create an empty list
- add the first blob to the queue
- while the queue is not empty, do this with the first in the queue:
-- mark it as checked
-- add it to the list of blobs part of this combo
-- look at the four surrounding blobs, and add each to the queue if it is the same color, and not marked as checked

the queue is now empty, so
- unmark all blobs
- free the queue data structure

the list now has all the blobs that are part of the group, and you can destroy/score them in order. Using a queue like this has the side effect of sorting them "inside out", rather than a deep search, so if you'd destroy them in the order of the resulting list, you'll get a kind of burning fuse effect.

This is untested and can probably still be optimized and there's a slight chance it's completely wrong. Feel free to improve.

Also, the "marking it as checked" is optional. It's merely optimization. You can of course do what Coco said, and just treat all elements from the list as "checked", but it requires to go through the whole list instead of checking only a single variable. In a scenario where you are not expecting huge groups, there should not be a big performance difference, but the longer your lists get, the less performant coco's method will be.

_________________
Guinea 2013 Reference (1) | 11 (1) | 10 (1) | 08/09 (1, 2)
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 5:17 pm 
User avatar
C# Programmer
Member
[*]
[*]
[*]
[*]
Random.NICK wrote:
Anyone know what I can do to check if there is a combo of a specific color in a pattern of 4?


So do you mean, determining whether you have an "L", "J", "[]", "l", "_", etc? Is your problem to match 4 blobs to a previously specified 4 combo?

_________________
MFGG TKO (scrapped) - Animations
Image
"It feels that time is better spent on original creations" - Konjak
Focus on the performance, the idea, not the technical bits or details - Milt Kahl
 
Top
Offline 
 
 
 [br]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Wed Dec 21, 2016 7:10 pm 
User avatar
Not a bird
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
I bet that's not necessary. Instead, you just need a way to make the game see there is a group of blobs and count how many blobs are in it.

I can't provide a code for you right now, I'm sorry. :( So I say each blob needs to check for the other blobs around and send information (variables and values) to blobs of same color in order to make a group and count the blobs.

_________________
Please contact me for any broken links below.
Spoiler:

Spoiler:
 
Top
Offline 
 
 
 [us]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Thu Dec 22, 2016 3:47 pm 
User avatar
Just that RANDOM GUY!
Member
[*]
[*]
[*]
[*]
So do you mean, determining whether you have an "L", "J", "[]", "l", "_", etc? Is your problem to match 4 blobs to a previously specified 4 combo?[/quote]Yes exactly.

Honestly I've tried so many things to try and get this to work.
Collision checking, place meetings, and other methods including variables, but I just can't get it to work. :/

_________________
Rest in peace Satoru Iwata. (1959-2015) You will always live on in our hearts.

I'm just a random guy named Nick! I like to make games, program, design sprites/art, and play Nintendo games.
Check out my cool fangame: SUPER MARIO Power Star Frenzy! A twist to the collectathon style Mario games. [PRIORITY]
Check out my other fangame: SUPER MARIO Dimension Dilemma! A SSBB Subspace Emissary styled Mario fangame.


Image Image Image Image

Power Star Frenzy Progress Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Thu Dec 22, 2016 4:34 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Ah, yeah, Guinea's approach is much better than mine.
I just thought it through in my head and it should work flawlessly.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Fri Dec 23, 2016 1:02 pm 
Real horses don't run into trees
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
I love how everyone ignores coco's idea and my pseudo code.

_________________
Guinea 2013 Reference (1) | 11 (1) | 10 (1) | 08/09 (1, 2)
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Fri Dec 23, 2016 1:46 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Guinea wrote:
I love how everyone ignores coco's idea and my pseudo code.
Truth be told, I think you're mostly just getting attention when you post actual code. No offense to anyone here, but I believe people just don't really care enough to put actual effort into doing some research themselves once pushed in the right direction, and simply prefer waiting for a more convenient solution.

Been there myself. It's a mindset I can accept, but it's not one I encourage, so I refuse to post actual code.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Sun Dec 25, 2016 6:59 pm 
User avatar
C# Programmer
Member
[*]
[*]
[*]
[*]
I forgot about this thread. But I thought the problem was about determining a specified pattern of 4, not just that there are 4 connected blobs of the same color. For the latter, DJ's and Guinea's solution works. But if Nick wants to know specifically which combo occurs (for example, to give different scores for a specific combo), then your solutions don't work.

_________________
MFGG TKO (scrapped) - Animations
Image
"It feels that time is better spent on original creations" - Konjak
Focus on the performance, the idea, not the technical bits or details - Milt Kahl
 
Top
Offline 
 
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Sun Dec 25, 2016 7:57 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
I don't think he needs to know what shape the blobs are in - if so, then things are getting a bit more complex.
The basic algorithm of Guinea should still work, though - in addition to that you'd just also need to check their positions and calculate the shape from it (this can probably also be done another way but I'd do it by using the coordinates).

I don't have an algorithm for that at hand right now, but I'm also not sure that's what he's looking for here.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: [HELP] Checking for combos of the same object
PostPosted: Mon Dec 26, 2016 6:17 am 
Real horses don't run into trees
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
TheShyGuy wrote:
I forgot about this thread. But I thought the problem was about determining a specified pattern of 4, not just that there are 4 connected blobs of the same color.

The first post states "blobs of a *specific color* in a pattern of 4", not "blobs of a color in a specific pattern of 4, and also the video example only shows a game in which any group of 4 or more blobs disappears, and there is nothing in it about pattern matching.

Of course, getting specific patterns of four leaves the question of what you do when you have groups with more than four blobs in them, e.g.:

Code:
   x   
xxx xxx


If that one x falls down in the gap you have a group of 7.

Either way, the basic idea for matching specific patterns is to predefine all shapes you want to check, and then check them. However you do that is up to the implementation. You could make it with some fancy function that takes a grid and a position as an input and checks from there, or you could just make one super complex function with many if conditions.

Essentially you'd define all the shapes you find in Tetris. The square (once), the long ones (horizontal and vertical), the Ts (rotate 4 times) the Ls and the Ns (for each, rotate 4 times + mirrored versions).

Then when you have a group of 4, you can easily determine the top and the leftmost blob of that group and apply all grids there until one matches.

_________________
Guinea 2013 Reference (1) | 11 (1) | 10 (1) | 08/09 (1, 2)
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 14 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group