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

GameMaker Simulated depth in 2.5D

J

John Smillie

Guest
Making one of those 3d-looking games like Spineworld or other MMO's you've probably seen. Anyone know how to simulate depth in something like this? Such as, the player sprite is drawn over an object when it is supposed to be in front of it, and is drawn behind it when it should be behind. I tried looking at some tutorials but I can't seem to make it work quite right.
Here is the code for the depth object that's supposed to be placed in the room. I also have an image attached for clarity. The player can go in front of the toilet/stall sprite and the door frame, but he should also be able to do behind them.

create:
Code:
ds_depthgrid = ds_grid_create(2,1);
draw:
Code:
if(ds_exists(ds_depthgrid,ds_type_grid))
{
    var depthGrid = ds_depthgrid;
    var instNum = instance_number(obj_par_depth);
    
    ds_grid_resize(depthGrid,2,instNum);
    
    var yy=0;
    with(obj_par_depth)
    {
        depthGrid[# 0,yy]=id;
        depthGrid[# 1,yy]=y;
        yy++;
    }
    
    ds_grid_sort(ds_depthgrid,1,true);
    yy=0; repeat(instNum)
    {
        var instID=ds_depthgrid[# 0,yy];
        with(instID)
        {
            draw_self();
        }
        yy++;
    }
    ds_grid_clear(ds_depthgrid,0);
}
If you need to know anything else, don't hesitate to ask.
 
Top