Fs1nTheChat
Member
Hi everyone
I usually try to figure things out on my own and with the help of already posted questions, but with this one I don't even know what to search for.
I am building a level editor for my game. The level consists of nodes that are either on or of, stored in a 2d array.
I wrote a recursive script to fill areas of the array kind of like the paint bucket tool in paint. The script checks for one node if it is on and if it isn't (and therefor is inside the barriers) it turns on and then executes the script for the four neigbouring nodes.
here is the script:
It seems to work fine with small areas, but when I make bigger areas it just crashes without an error message, just returns to the editor
I can't find a clear rule for when it crashes and when it doesn't
Any help in figuring out the problem is greatly appreciated
I usually try to figure things out on my own and with the help of already posted questions, but with this one I don't even know what to search for.
I am building a level editor for my game. The level consists of nodes that are either on or of, stored in a 2d array.
I wrote a recursive script to fill areas of the array kind of like the paint bucket tool in paint. The script checks for one node if it is on and if it isn't (and therefor is inside the barriers) it turns on and then executes the script for the four neigbouring nodes.
here is the script:
GML:
///fill(x, y, mode)
var fill_x = argument0
var fill_y = argument1
var mode = argument2
if(lvl_map[fill_x, fill_y] = mode)
{
if(mode = 0)lvl_map[fill_x, fill_y] = 1;
if(mode = 1)lvl_map[fill_x, fill_y] = 0;
if(fill_x>1)
{
fill(fill_x-1, fill_y, mode)
}
if(fill_x<(room_width/block_size)-1)
{
fill(fill_x+1, fill_y, mode)
}
if(fill_y>1)
{
fill(fill_x, fill_y-1, mode)
}
if(fill_y<(room_height/block_size)-1)
{
fill(fill_x, fill_y+1, mode)
}
}
I can't find a clear rule for when it crashes and when it doesn't
Any help in figuring out the problem is greatly appreciated
Attachments
-
134 KB Views: 8