• 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!

(solved)NEED HELP! Out of MEMORY! error

I

Isaiah Reyes

Guest
Hello, I was wondering if anyone could help me understand why i keep getting an "Out of memory!" error

This is the relative code








globalvar map;

mapWidth = room_width/GRID_SIZE;
mapHeight = room_height/GRID_SIZE;

// create nodes!
for(xx = 0; xx < mapWidth; xx += 1){
for(yy = 0; yy < mapHeight; yy +=1){
map[xx, yy] = instance_create (xx * GRID_SIZE, yy * GRID_SIZE, obj_node);
}
}

//populate neighbor lists!!
for(xx = 0; xx < mapWidth; xx += 1){
for(yy = 0; yy < mapHeight; yy =+ 1){

node = map[xx, yy];

//add left neighbor
if(xx > 0){
ds_list_add(node.neighbors, map[xx - 1, yy]);
}

//add right neighbor
if(xx < mapWidth - 1){
ds_list_add(node.neighbors, map[xx + 1, yy]);
}

//add top neighbor
if(yy > 0){
ds_list_add(node.neighbors, map[xx, yy - 1]);
}

//add bottom neighbor
if(yy < mapHeight - 1){
ds_list_add(node.neighbors, map[xx, yy + 1]);
}

//top left neighbor
if(xx > 0 && yy > 0){
ds_list_add(node.neighbors, map[xx - 1, yy - 1]);
}

//top right neighbor
if(xx < mapWidth - 1 && yy > 0){
ds_list_add(node.neighbors, map[xx + 1, yy - 1]);
}

//bottom left neighbor
if(xx > 0 && yy < mapHeight - 1){
ds_list_add(node.neighbors, map[xx - 1, yy + 1]);
}

//bottom right neighbor
if(xx < mapWidth - 1 && yy < mapHeight - 1){
ds_list_add(node.neighbors, map[xx + 1, yy + 1]);
}

}

}


instance_create(x, y, obj_cursor);
 
I

Isaiah Reyes

Guest
This might be the problem line. I guess you are actually wanting it to be += and not =+. It may be that GMS is actually reading it as you wanting to set yy to be +1 (which is actually just 1) and not increase it by 1, so it would never increase at all.


thank you so much! i didn't even see that and i was staring at it for a couple of hours
 
Top