• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Loop feedback not shown when running

R

RoyTheDragon

Guest
Good timezone to y'all, new to the forum but not new to Game Maker: Studio 1.4.9999 (the version I'm using at the moment) please forgive me if the formatting and tag of this is incorrect in any way possible.
I've had some time to try and develop my own game but want to be able to develop match 3 style games,
I seem to have an issue where the results of the loop will not give me any sign that it's running and just to show you what I've got for the loop, this is more to make the pieces clear from the board, before I was actually making it so that the game would automatically detect if there's 2 of the same colour on each side but that deemed a little problematic from the fact that it only cleared 3 instead of the entire cluster.

I'm going to show 3 blocks of relevant code in this post to possibly open up some possibilities as to what might not be running properly. One for the destroy loop, one for clearing the pieces that are affected and also the one before which checks if there's a specific amount of pieces.
Here's a few things to note before anything else
all the variables here are defined in a creator instance where they're only touched once when the game is run.
so things like spacer, spacermin, curx, cury, etc. are all defined in such a manner that if i were to change something, it would work regardless of what kind of change I did.
and after further testing and attempt of fixing and why I still couldn't see any results I put a couple variables in as a global to put into my creator's draw block to see what's going on, they're not really used for much else anyway and it seems to be that the loop is getting stuck somewhere when looping, more specifically at object ID 100165.

I'm aware that things like a loop ending prematurely could cause issues like this, there maybe other factors of which I'm not looking into too much. I've practically nowhere to turn.

GML:
for (i = 0; i < 10; i++) // the script I'm using for the matching function. (named destroyer)
{
    for (v = 0; v<10; v++)
    {
        curx = sx + (i * spacer) ;
        cury = sy + (v * spacer) ;
        curxm = msx + (i * spacermin) ;
        curym = msy + (v * spacermin) ;
        curpiece = instance_position(curxm , curym , obj_mini) ; // current minimap piece
        curbpiece = instance_position( curx ,cury , obj_pieces) ; // current main board piece
        if instance_exists(curbpiece)
        {
            if (instance_exists(instance_position(x + 32 , y , curbpiece)) and instance_exists(instance_position(x - 32 , y , curbpiece))) and (instance_position(x + 32 , y , curbpiece).image_index == curbpiece.image_index and instance_position(x - 32 , y , curbpiece).image_index == curbpiece.image_index) // horizontal
            {
                curbpiece.infected = true ; // this causes other pieces that are the same colour to be infected horizontally
            }
            if (instance_exists(instance_position(x , y + 32 , curbpiece)) and instance_exists(instance_position(x , y - 32 , curbpiece))) and (instance_position(x , y + 32 , curbpiece).image_index == curbpiece.image_index and instance_position(x , y - 32 , curbpiece).image_index == curbpiece.image_index) // vertical
            {
                curbpiece.infected= true ; // this causes other pieces that are the same colour to be infected vertically
            }
        }
    }
}
if not moving //this checks if there's nothing moving on the board before executing
{
    clear();
}
GML:
with(obj_pieces) //the code I'm using for when the loop above is done. (named clear)
{
    if infected
    {
        instance_destroy(); // should clear those that are in the cluster (infected=true)
    }
}
cycling=false;

GML:
//part of step block in an object named Cycler.
if instance_number(obj_pieces) <81 // checks if the board has exactly 81 pieces
{
    moving = true;
}
else
{
    moving = false;
}
if not cycling
{
    cycle();
}
 

Nidoking

Member
That's a gigantic mess of logic that would be much simpler with a couple of local variables. And you're not using the curpiece variable for anything.

I also can't make much sense of your description of the problem. Could you boil it down to maybe one or two relevant sentences?
 
R

RoyTheDragon

Guest
That's a gigantic mess of logic that would be much simpler with a couple of local variables. And you're not using the curpiece variable for anything.

I also can't make much sense of your description of the problem. Could you boil it down to maybe one or two relevant sentences?
Thanks for the catch on the unused variable.
I'm trying to get all pieces that are connected to a cluster to disappear, nothing at the moment is disappearing.
 

demonipo

Member
have you tried referencing the image you're checking on a variable? besides that, it seems like it is checking if the current piece is in the other sides, instead of checking for the other pieces. maybe referencing the piece object directly might fix the issue
 

Nidoking

Member
I've found this much easier to implement using a ds_grid and having the tiles store their position in the grid. It's easy to tell which tiles are neighbors that way.
 
R

RoyTheDragon

Guest
I've found this much easier to implement using a ds_grid and having the tiles store their position in the grid. It's easy to tell which tiles are neighbors that way.
I've always had trouble finding out how to interpret datastructure grids.
 
Top