cairnswm
15-08-2007, 10:49 PM
How do you do recursion in Game Maker?
Script : FocusCell(argument0 = CellX; argument1 = CellY)
if not global.BlockSel[argument[0],argument[1]] == true then
{
global.BlockSel[argument[0],argument[1]] = true;
px = argument[0];
py = argument[1];
if px > 0 then
{ if global.BlockId[px-1,py] == global.BlockId[px,py] then
{ FocusCell(nx,py); } }
if px < 9 then
{ if global.BlockId[px+1,py] == global.BlockId[px,py] then
{ FocusCell(nx,py); } }
if py > 0 then
{ if global.BlockId[px,py-1] == global.BlockId[px,py] then
{ FocusCell(px,ny); } }
if py < 9 then
{ if global.BlockId[px,py+1] == global.BlockId[px,py] then
{ FocusCell(px,ny); } }
}
What happens is it seems to only execute in one direction - ie it doesn;t seem to do the second FocusCell when called. (So it it needs to focus a cell to left and top, it only does the left one).
Script : FocusCell(argument0 = CellX; argument1 = CellY)
if not global.BlockSel[argument[0],argument[1]] == true then
{
global.BlockSel[argument[0],argument[1]] = true;
px = argument[0];
py = argument[1];
if px > 0 then
{ if global.BlockId[px-1,py] == global.BlockId[px,py] then
{ FocusCell(nx,py); } }
if px < 9 then
{ if global.BlockId[px+1,py] == global.BlockId[px,py] then
{ FocusCell(nx,py); } }
if py > 0 then
{ if global.BlockId[px,py-1] == global.BlockId[px,py] then
{ FocusCell(px,ny); } }
if py < 9 then
{ if global.BlockId[px,py+1] == global.BlockId[px,py] then
{ FocusCell(px,ny); } }
}
What happens is it seems to only execute in one direction - ie it doesn;t seem to do the second FocusCell when called. (So it it needs to focus a cell to left and top, it only does the left one).