S
ShuDiZo
Guest
First of all, thank you for visiting and reading this request. The issue i'm currently trying to fix is the silhouette system as it only draws the effect while it is behind another instance that is not part of the list; instances not using the depth system.
- All instances using the depth system has obj_parent_depth as an ancestor
- If using the tradition depth =-y system, the silhouette will still draw as if the player is underneath the instance.
----- DEPTH SYSTEM -----
//Check if grid exists
if(ds_exists(ds_depthgrid, ds_type_grid)){
//make ds_depthgrid local and accessable to our instances (all children of depth parent)
var depthgrid = ds_depthgrid;
//get the number of instances (number of children)
var instNum = instance_number(obj_parent_depth);
//resize the grid to the number of instances/children
ds_grid_resize(depthgrid, 2, instNum);
//declare a local variable we will increment with each loop when adding children to grid
var yy = 0;
//add all the instances/children to the grid, and their corresponding y value
with(obj_parent_depth){
depthgrid[# 0,yy] = id;
depthgrid[# 1,yy] = y;
yy += 1;
}
//sort the grid in ascending order (lowest Y will be at the top)
ds_grid_sort(ds_depthgrid, 1, true);
//use repeat to loop through the grid, starting at height = 0, drawing the instance,
//and then incrementing yy for the next loop, to draw the next instance in the grid
yy = 0; repeat(instNum){
var instanceID = ds_depthgrid[# 0, yy];
with(instanceID){ draw_self(); }
yy+=1;
}
//clear all cells of the grid to 0
ds_grid_clear(ds_depthgrid, 0);
}
----- SILHOUETTE DRAW STEP -----
gpu_set_blendenable(false);
gpu_set_colorwriteenable(false, false, false, true);
var cam = view_camera[0];
var cx = camera_get_view_x(cam);
var cy = camera_get_view_y(cam);
var w = camera_get_view_width(cam);
var h = camera_get_view_height(cam);
draw_set_alpha(0);
draw_rectangle(cx, cy, cx+w, cy+h, false);
draw_set_alpha(1);
gpu_set_colorwriteenable(true, true, true, true);
gpu_set_blendenable(true);
----- SILHOUETTE DRAW END STEP -----
gpu_set_blendmode_ext(bm_dest_alpha, bm_inv_dest_alpha);
gpu_set_alphatestenable(true);
with (obj_cb01){
gpu_set_fog(true, c_fuchsia,0, 1);
draw_self();
}
gpu_set_fog(false,c_white,0,0);
gpu_set_alphatestenable(false);
gpu_set_blendmode(bm_normal);
- All instances using the depth system has obj_parent_depth as an ancestor
- If using the tradition depth =-y system, the silhouette will still draw as if the player is underneath the instance.
----- DEPTH SYSTEM -----
//Check if grid exists
if(ds_exists(ds_depthgrid, ds_type_grid)){
//make ds_depthgrid local and accessable to our instances (all children of depth parent)
var depthgrid = ds_depthgrid;
//get the number of instances (number of children)
var instNum = instance_number(obj_parent_depth);
//resize the grid to the number of instances/children
ds_grid_resize(depthgrid, 2, instNum);
//declare a local variable we will increment with each loop when adding children to grid
var yy = 0;
//add all the instances/children to the grid, and their corresponding y value
with(obj_parent_depth){
depthgrid[# 0,yy] = id;
depthgrid[# 1,yy] = y;
yy += 1;
}
//sort the grid in ascending order (lowest Y will be at the top)
ds_grid_sort(ds_depthgrid, 1, true);
//use repeat to loop through the grid, starting at height = 0, drawing the instance,
//and then incrementing yy for the next loop, to draw the next instance in the grid
yy = 0; repeat(instNum){
var instanceID = ds_depthgrid[# 0, yy];
with(instanceID){ draw_self(); }
yy+=1;
}
//clear all cells of the grid to 0
ds_grid_clear(ds_depthgrid, 0);
}
----- SILHOUETTE DRAW STEP -----
gpu_set_blendenable(false);
gpu_set_colorwriteenable(false, false, false, true);
var cam = view_camera[0];
var cx = camera_get_view_x(cam);
var cy = camera_get_view_y(cam);
var w = camera_get_view_width(cam);
var h = camera_get_view_height(cam);
draw_set_alpha(0);
draw_rectangle(cx, cy, cx+w, cy+h, false);
draw_set_alpha(1);
gpu_set_colorwriteenable(true, true, true, true);
gpu_set_blendenable(true);
----- SILHOUETTE DRAW END STEP -----
gpu_set_blendmode_ext(bm_dest_alpha, bm_inv_dest_alpha);
gpu_set_alphatestenable(true);
with (obj_cb01){
gpu_set_fog(true, c_fuchsia,0, 1);
draw_self();
}
gpu_set_fog(false,c_white,0,0);
gpu_set_alphatestenable(false);
gpu_set_blendmode(bm_normal);
Last edited by a moderator: