TulioHenry
Member
So i was trying to make a top down platformer where the platforms have a z position which the player can jump on the platform or go under the platform,
but the problem is the depth sorting, i'm using FriendlyCosmonaut's depth sorter instead of the "depth = -y", but my player sprite is always in front of everything.
OBS: i'm using the z axis project from Backspace Cadet.
--Depth sorter draw event
--Player Z Step event
Here the example:
I'm behind the block and yet being draw first.
So if anyone know the problem, please tell me.
but the problem is the depth sorting, i'm using FriendlyCosmonaut's depth sorter instead of the "depth = -y", but my player sprite is always in front of everything.
OBS: i'm using the z axis project from Backspace Cadet.
--Depth sorter draw event
GML:
var dgrid = ds_depth
var inst_num = instance_number(o_nonstatic_par);
ds_grid_resize(dgrid,2,inst_num);
var yy = 0
with(o_nonstatic_par){
dgrid[# 0,yy] = id;
dgrid[# 1,yy] = y+z;
yy++;
}
ds_grid_sort(dgrid,1,true);
var i = 0;
var inst;
repeat(inst_num){
inst = dgrid[# 0,i];
with(inst){
event_perform(ev_draw,0);
}
i++
}
Code:
//z jump (when space pressed)
if (zjump == true){
z += zspeed /*z pos goes up*/
}
//if not ontop of block
if (!instance_place(x,y,o_block_par))
{
zfloor = 0; /*zfloor is ground level*/
}
//if not on ground
if (!z <= zfloor)
{
z -= zgrav; /*apply downforce on z pos*/
zgrav += 0.2; /*grav gets stronger each step*/
}
//stop falling when you hit zfloor
if (z <= zfloor+1/*+1 for sticking glitch on ground*/)
{
z = zfloor; /*snap z pos to on ground*/
zgrav = 0; /*stop applying downforce*/
zjump = false; /*no longer in the air*/
}
I'm behind the block and yet being draw first.
So if anyone know the problem, please tell me.