Situation: I started work on a pet project recently. It's a bit like Puzzlecraft, or Bejewled, but slightly different. You click one gem, as we'll call it, and if it's the first in the link, then it's added to the link.
That works well enough. However, the problem comes in that after that, in order to link, it must be adjacent to the last link... and somehow, something goes wonky. The first time you click something not adjacent, it doesn't get put on the link...or it at least doesn't highlight. It also doesn't run across any of my show_message
popups - aside from "second else".
Yet, somehow, it seems to act as though that one you clicked on was the Last_Link
, after that point...permanently...which shouldn't even be possible...
So, if you click adjacent to the one that got to "second else", it will still consider that "adjacent", even if it's across the entire board from the last one that actually highlighted.
And this permanent allocation of Last_Link
can happen for every gem on the board. At the same time. (Note: It does deallocate once you restart the program.)
This DOESN'T make sense!
I have no step events (yet). This is also the only left click event in the game at the moment. Every other event is a create or game start event, mostly for initialization purposes. So I have no idea what is doing this. Can someone tell me?
Left Click Event for the Gems
if (obj_Handle_Links.Match_Length = 0) //if this would be the first in the link
{
show_message("first to link");
obj_Handle_Links.Match_Length +=1; //because we're increasing the length
image_index = 1; //this should highlight
//add to link, later
show_message( Matrix_Location_y );
obj_Handle_Links.Last_Link = id; //makes it so this is what's seen as last link
show_message(obj_Handle_Links.Last_Link.Matrix_Location_y);
}
else
{
// show_message("first else");
//check if the target is the same type as the last Link's type
if(obj_Handle_Links.Last_Link.Type = Type &&
//check if the last link in the chain is adjacent to the target link
//includes diagonals
(obj_Handle_Links.Last_Link.Matrix_Location_y = (Matrix_Location_y-1)
|| obj_Handle_Links.Last_Link.Matrix_Location_y = (Matrix_Location_y+1)
|| obj_Handle_Links.Last_Link.Matrix_Location_x = (Matrix_Location_x-1)
|| obj_Handle_Links.Last_Link.Matrix_Location_x = (Matrix_Location_x+1)) )
{
show_message( Matrix_Location_y );
//show_message("third if");
obj_Handle_Links.Match_Length +=1; //because we're increasing the length
image_index = 1; //this should highlight
//add to link, later
obj_Handle_Links.Last_Link = id; //makes it so this is what's seen as last link
show_message(obj_Handle_Links.Last_Link.Matrix_Location_y);
}
else{
show_message("second else");
//play sound that link failed
}
}
show_message
stuff because I intentionally put them out of indent for ease of finding them in the code later. Thanks. I have indented them for the question. \$\endgroup\$ – SangoProductions Jun 15 '16 at 2:27