P#37938 2017-02-28 15:39 ( Edited 2017-02-28 20:39)
Hi,
I get an out of memory when calling this function (recursive)
when i click a button, i will call select_ball(4,4,3) -> now all objects with the same index (neighbours) wil get index 7
This works perfectly fine, but no matter how many objects will be selected, in the end there is an out of memory exception
balls is a 16x10 multidimensional array.
arrow keys to move the cursor and 'z' to click on a ball
function select_ball(x,y,index) if balls[x][y].index==index then balls[x][y]={index=7} if x>1 and balls[x-1][y].index==index then select_ball(x-1,y,index) end if x<width and balls[x+1][y].index==index then select_ball(x+1,y,index) end if y>1 and balls[x][y-1].index==index then select_ball(x,y-1,index) end if y<height and balls[x][y+1].index==index then select_ball(x,y+1,index) end end end |
P#37901 2017-02-27 18:20 ( Edited 2017-02-28 11:53)