Bust-A-Move/Puzzle Bubble questions

B

Blakkid489

Guest
GMS2

For those of you unaware of the game itself....

So far this is my code to attempt this...
Code:
#region My Code
iAngle += 10;

if (gridSnap)
{
   if (!place_snapped(24,24)) && (place_meeting(x,y,oWall))
   {
       move_snap(24,24);
       speed = 0;
       iStable = true
       alarm[0] = 5;
   }
   if (!place_snapped(24,24)) && (place_meeting(x,y,oBubbleParent))
   {
       move_snap(24,24);
       speed = 0;
       iStable = true;
       with (oBubble)
       alarm[0] = 5;
   }
}

if (place_meeting(x,y,oWall))
{
   gridSnap = true;
 
}
if (place_meeting(x,y,oBubbleParent)) && (!dead)
{
   gridSnap = true;
   iStable = true
   isShooting = true;
}

if x < 24 || x > 192
{
   if (!gridSnap)
   hspeed = hspeed * -1;
}

if (canGrav)
{
   gravity = gravPower;
   gravity_direction = 270;
}
#endregion


if (gridSnap) && y > 192
instance_destroy();
Code:
if (gridSnap)
{
   if (x < 145) && (y > 47)
   if (!position_empty(x+24,y)) && (!position_empty(x+48,y))
   {
       var n1,n2
       n1 = instance_position(x+24,y,oBubble);
       n2 = instance_position(x+48,y,oBubble);
       if (n1.iStable) && (n2.iStable)
       {
           if (n1.iColor == iColor) && (n2.iColor == iColor)
           {
               match = 1;
           }
       }
   }
   if (y < 169) && (y > 47)
   if (!position_empty(x,y+24)) && (!position_empty(x,y+48))
   {
       var n3,n4
       n3 = instance_position(x,y+24,oBubble);
       n4 = instance_position(x,y+48,oBubble);
       if (n3.iStable) && (n4.iStable)
       {
           if (n3.iColor == iColor) && (n4.iColor == iColor)
           {
               match = 2;
           }
       }
   }


   switch (match)
   {
       case 1:
           with (n1)
           alarm[1] = 1;
           with (n2)
           alarm[1] = 1;
           alarm[1] = 1;
           match = 0;
       break;
 
       case 2:
           with (n3)
           alarm[1] = 1;
           with (n4)
           alarm[1] = 1;
           alarm[1] = 1;
           match = 0;
       break;
 
       case 3:
           with (n5)
           alarm[1] = 1;
           with (n6)
           alarm[1] = 1;
           alarm[1] = 1;
           match = 0;
       break;
   }
}
Code:
instance_destroy();

and here's the result

Quesion 1: Is there a way I can manipulate this code to work when there is a cluster of them instead of just a horizontal and/or vertical collision?

Question 2: How to make some fall when not connected to anything?

Question 3: How do I get the gems to align to the grid as they do in bust a move?
 

TheouAegis

Member
If you look closely at BustAMove, it is actually aligned to an isometric grid. So first off, study up on working with isometric grids. In other words each bubble has up to 6 collisions to check; There is no true vertical collision.

As for the falling off when there are no other bubbles holding it up, the way I would handle that is to at the beginning of each step have every bubble specify that it is not stable. Then starting with the top left bubble, working right and down like a typewriter, check if the bubble is at the very top row. If so, it is stable. Otherwise, check if there are any bubbles diagonally above it. If not, it is not stable. Otherwise, if at least one of the bubbles is stable, then it is also stable. I don't think stability worked horizontally in BustAMove...
 
B

Blakkid489

Guest
Isometric. I can study that no problem. Are you saying there is no other way to manipulate this concept to match this?
 

TheouAegis

Member
If you want to allow pure vertical collisions as attachments, then you'd just increase your search size.

Actually I was wrong. I said you'd need to check 6 directions. The CORRECT number is 3: left, upper-left and upper-right. It's half the number of connections. In games like Bust-A-Move, there are 6 directions of connectivity with no vertical connection, as the vertical component is actually the upper-left.

Code:
________________
0 1 2 3 4 5 6 7 
 8 9 A B C D E F
It was all handled in an array, which was defined as

[-1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F]

So for any bubble at position n in the grid, the bubble at n-8 is the upper-left bubble and the bubble at n-7 is the upper-right bubble. So in other words:

Code:
if cell[n-8] != 0 or cell[n-7] != 0
    stable[n] = 1;
So if either of the above cells is a bubble or wall, the current bubble is marked stable.

Putting it all together...

Code:
stable[n] = 0;
group[n] = 0;
if cell[n-8] != 0 {
    stable[n] = 1;
    if cell[n-8] == cell[n]
        group[n] = 1;
}
if cell[n-7] != 0 {
    stable[n] = 1;
    if cell[n-7] == cell[n]
        group[n] = 1;
}
if n mod 8 > 0 {
    stable[n] = 1;
    if cell[n-1] == cell[n]
        group[n] = 1;
}
So here it clears stability of the current cell, clears the group association, checks if the upper-left cell is stable, then checks if it's the same bubble and assigns it to the same group, then does the same for the upper-right cell and the left cell if the left cell is not an "undefined wall".

You can code it with objects just fine, but I'm just showing how it was a bit easier for them to handle it as a single array .
 

TheouAegis

Member
Can you recreate it for me? I've been trying to and failing at it. Preferably in the SNES or NeoGeo version. If it's in some of the premades, which levels?

Code:
O
 OO
Everytime I try, I just end up with

Code:
O
 O
  O
 
P

ParodyKnaveBob

Guest
Can you recreate it for me? I've been trying to and failing at it. Preferably in the SNES or NeoGeo version. If it's in some of the premades, which levels?

Code:
O
 OO
Everytime I try, I just end up with

Code:
O
 O
  O
Watch the video Blakkid489 posted (Japanese arcade footage). Jump straight to 2:22 to see a yellow bubble attach to the side of a yellow bubble.

Regards,
Bob $:^ J
 
B

Blakkid489

Guest
If you want to allow pure vertical collisions as attachments, then you'd just increase your search size.

Actually I was wrong. I said you'd need to check 6 directions. The CORRECT number is 3: left, upper-left and upper-right. It's half the number of connections. In games like Bust-A-Move, there are 6 directions of connectivity with no vertical connection, as the vertical component is actually the upper-left.

Code:
________________
0 1 2 3 4 5 6 7
 8 9 A B C D E F
It was all handled in an array, which was defined as

[-1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F]

So for any bubble at position n in the grid, the bubble at n-8 is the upper-left bubble and the bubble at n-7 is the upper-right bubble. So in other words:

Code:
if cell[n-8] != 0 or cell[n-7] != 0
    stable[n] = 1;
So if either of the above cells is a bubble or wall, the current bubble is marked stable.

Putting it all together...

Code:
stable[n] = 0;
group[n] = 0;
if cell[n-8] != 0 {
    stable[n] = 1;
    if cell[n-8] == cell[n]
        group[n] = 1;
}
if cell[n-7] != 0 {
    stable[n] = 1;
    if cell[n-7] == cell[n]
        group[n] = 1;
}
if n mod 8 > 0 {
    stable[n] = 1;
    if cell[n-1] == cell[n]
        group[n] = 1;
}
So here it clears stability of the current cell, clears the group association, checks if the upper-left cell is stable, then checks if it's the same bubble and assigns it to the same group, then does the same for the upper-right cell and the left cell if the left cell is not an "undefined wall".

You can code it with objects just fine, but I'm just showing how it was a bit easier for them to handle it as a single array .
Would this work with my collision check system in my aalarm 0 event, or would I have to alter that a bit?
Your example looks legit but it looks like there's barely any wiggle room to check for horizontal collision and/or attachment. . I think I'm looking at it wrong possibly
 

TheouAegis

Member
Damn it hold on. I tried simplifying the grouping thing and then it realized it wasn't going to work. I just really hate performing the same Loops over and over multiple times in a step. ... I ended up doing this with my Puyo Puyo project after some deliberation even though I wasn't satisfied with the decision.

So you have two types of scenarios when a bubble is destroyed and scored:

The first is when you shoot a bubble and it collides with a group of 2 or more matching the same color. At this point we don't even care about stability, we just care about the grouping. So here I would use a RECURSIVE loop checking each neighboring bubble if it is the same color; if a bubble matches, increase a bubble counter and flag it as destroyed, then move on to that neighbor. Your play field should not be too big for the recursion depth. After all conjoined bubbles have been found, check if the counter is 2 (or 3 if you started it at 1) and then if it is Loop through all of the bubbles and the store and the ones that have been flagged to be destroyed.

The second part is then thus finding all of the ones that are no longer stable. So in this scenario you would just do a normal loop like I had described before starting with the top left bubble. As soon as a neighboring bubble is found, you flag the bubble as stable. When you have finished checking all of the bubbles, then Loop through every bubble and if it has not been flagged as stable, you tell it to drop and increase the score accordingly.

So in other words, upon collision of the shot bubble with any other buble or the ceiling, you perform a recursive loop checking every neighboring bubble to see if you can destroy any bubbles that turn. If and only if a group of bubbles is able to be destroyed, then you check stability. There's no need to check stability otherwise.
 
Top