Erayd
Member
I've been working on following this concept on binary lists as depth ordering: https://forum.yoyogames.com/index.p...rity-list-nested-list-grid-binary-list.13425/
I dived in to bitwise operators and read through several demo scripts by yoyo along with reading the guides on priority lists. At this point, I THINK I know what I'm doing, however the list sorting system just doesn't seem to work.
I have an object, obj_DrawController which I place in to a room on the "Instance" layer where all the other instances are. This object correctly grabs all the objects and stores them in this binary list to which I can then access and run code in. I've (in the draw event part) have tested putting output of the object index it finds and it does in fact store and then access each item.
The problem is they're all still just drawing in the same order I put them in the room. Nothing has changed, my player is still just on top of everything and anything I placed in the room renders based on where I placed it in the room, not it's y position. Could the draw event be running twice somehow? Could event_perform just not be working? Could the list idea be bugged and it doesn't work like this anymore? Maybe it just isn't sorting? I just don't know and any thoughts on this topic are greatly appreciated.
In case you're wondering, I do need event_perform because there is a lot going on in a single sprite that simply drawing its sprite at an x/y position isn't enough.
Create Event:
Room Start Event
Draw Event:
I dived in to bitwise operators and read through several demo scripts by yoyo along with reading the guides on priority lists. At this point, I THINK I know what I'm doing, however the list sorting system just doesn't seem to work.
I have an object, obj_DrawController which I place in to a room on the "Instance" layer where all the other instances are. This object correctly grabs all the objects and stores them in this binary list to which I can then access and run code in. I've (in the draw event part) have tested putting output of the object index it finds and it does in fact store and then access each item.
The problem is they're all still just drawing in the same order I put them in the room. Nothing has changed, my player is still just on top of everything and anything I placed in the room renders based on where I placed it in the room, not it's y position. Could the draw event be running twice somehow? Could event_perform just not be working? Could the list idea be bugged and it doesn't work like this anymore? Maybe it just isn't sorting? I just don't know and any thoughts on this topic are greatly appreciated.
In case you're wondering, I do need event_perform because there is a lot going on in a single sprite that simply drawing its sprite at an x/y position isn't enough.
Create Event:
Code:
depth_table = ds_list_create();
Code:
/// @description Fill Depth Table
//Clear the list
ds_list_clear(depth_table);
//Add all instances to depth table except this one
var _id = 0;
for(var i = 0; i < instance_count - 1; i++){
_id = instance_id_get(i);
if(_id != id) depth_table[| i] = (_id | _id.y << 32);
}
//Sorth the depth list
ds_list_sort(depth_table, false);
Code:
/// @description Draw all objects
var _id = 0;
for(var i = 0; i < ds_list_size(depth_table); i++){
_id = depth_table[| i] & $ffffffff;
with(_id) {
event_perform(ev_draw, 0);
}
}