Unknown Entity
Member
So, I recently rewrote my game to use my own system instead of the built-in Room system so I could
A) more easily transition between them without weird workarounds for the fact Rooms don't load until after you finish executing all your code
B) use an external map editor to create them
C) add custom properties to rooms, like names and whatnot
So I wrote a script to load all the map tiles/maps into objects and store them in Game Maker, and then another script to clear out the room and fill it with objects (mostly trees at the moment) and tiles. The issue is, a room with a size of 75x75 loads incredibly slowly through this method (multiple seconds), and I have found that is because it's calling instance_create_layer about 5372 times, and instance_create_layer is absurdly slow.
For reference, each of those objects has to instantiate a ds_list each time it's created, which is the second-most-taxing part of loading the area, and that process takes only about 33ms, where the process of creating the instances themselves is taking 5757ms (almost two seconds!). Considering that I'm providing the function with an x-coordinate, a y-coordinate, the layer ID, and the object ID, it should NOT be taking this long.
room_layers[layer_id][y_coordinate][x_coordinate] = object_id. Done. That's all that should be happening there. Someone explain to me how YoYo Games justifies this function taking over a third of a millisecond to complete on average, and if there's any way at all for me to work around it.
A) more easily transition between them without weird workarounds for the fact Rooms don't load until after you finish executing all your code
B) use an external map editor to create them
C) add custom properties to rooms, like names and whatnot
So I wrote a script to load all the map tiles/maps into objects and store them in Game Maker, and then another script to clear out the room and fill it with objects (mostly trees at the moment) and tiles. The issue is, a room with a size of 75x75 loads incredibly slowly through this method (multiple seconds), and I have found that is because it's calling instance_create_layer about 5372 times, and instance_create_layer is absurdly slow.
For reference, each of those objects has to instantiate a ds_list each time it's created, which is the second-most-taxing part of loading the area, and that process takes only about 33ms, where the process of creating the instances themselves is taking 5757ms (almost two seconds!). Considering that I'm providing the function with an x-coordinate, a y-coordinate, the layer ID, and the object ID, it should NOT be taking this long.
room_layers[layer_id][y_coordinate][x_coordinate] = object_id. Done. That's all that should be happening there. Someone explain to me how YoYo Games justifies this function taking over a third of a millisecond to complete on average, and if there's any way at all for me to work around it.