Legacy GM [SOLVED] Drawing Depth.

D

DyingSilence

Guest
I make my roguelite game right now, it has a FOV algorhitm that draws black triangles in the places which player doesn't see. It works perfectly well.

But i want to draw some wall sprites on walls wchich cast those "vision shadows", so i made that "z" is the lower, the closer the object is to the player, so the near ones will cloak the further ones.
In theory.
Practically they behave like they kept the same depth, which is a mess.

Question:

How do I change actual draw depth?
 
S

Sudo_Radish

Guest
I make my roguelite game right now, it has a FOV algorhitm that draws black triangles in the places which player doesn't see. It works perfectly well.

But i want to draw some wall sprites on walls wchich cast those "vision shadows", so i made that "z" is the lower, the closer the object is to the player, so the near ones will cloak the further ones.
In theory.
Practically they behave like they kept the same depth, which is a mess.

Question:

How do I change actual draw depth?
In your object properties there is a depth field.

Or in code it is depth = -y

http://docs.yoyogames.com/source/da...nces/instances/instance properties/depth.html
 
D

DyingSilence

Guest
Shadow triangles are parts of the wall objects, so they have the same depth i guess.
They are drawn on Draw loop of the object.
 

TesloStep

Member
did you change "depth" variable, depending on the distance to player?
draw on every wall its depth in numbers to proof that
 

Yal

šŸ§ *penguin noises*
GMC Elder
How about this?
Code:
depth = point_distance(x,y,obj_player.x,obj_player.y)
 
D

DyingSilence

Guest
Here's my Step code for depth:

Code:
z = -900+distance_to_point(Damned.x,Damned.y);
I need it to be somewhere near 700 - 900, so it is as it is.

My draw code:


Code:
//drawing the black fill of the wall
draw_sprite_ext(Wall, 0, x, y, 1,1,0, c_white, 1);

//drawing the shadow
draw_set_colour(c_black);
draw_triangle(x,y,x+lengthdir_x(1000,point_lt),y+lengthdir_y(1000,point_lt),x+32+lengthdir_x(1000,point_rt),y+lengthdir_y(1000,point_rt),0)
draw_triangle(x,y,x+32+lengthdir_x(1000,point_rt),y+lengthdir_y(1000,point_rt),x+32,y,0)
draw_triangle(x,y+32,x+lengthdir_x(1000,point_ld),y+32+lengthdir_y(1000,point_ld),x+32+lengthdir_x(1000,point_rd),y+32+lengthdir_y(1000,point_rd),0)
draw_triangle(x,y+32,x+32,y+32,x+32+lengthdir_x(1000,point_rd),y+32+lengthdir_y(1000,point_rd),0)
draw_triangle(x,y+32,x,y,x+lengthdir_x(1000,point_lt),y+lengthdir_y(1000,point_lt),0)
draw_triangle(x,y+32,x+lengthdir_x(1000,point_ld),y+32+lengthdir_y(1000,point_ld),x+lengthdir_x(1000,point_lt),y+lengthdir_y(1000,point_lt),0)
draw_triangle(x+32,y+32,x+32,y,x+32+lengthdir_x(1000,point_rd),y+32+lengthdir_y(1000,point_rd),0)
draw_triangle(x+32,y,x+32+lengthdir_x(1000,point_rt),y+lengthdir_y(1000,point_rt),x+32+lengthdir_x(1000,point_rd),y+32+lengthdir_y(1000,point_rd),0)

//drawing actual walls
draw_sprite_ext(Wall_Left, 0, x, y, 1,1,0, c_white, 1);
draw_sprite_ext(Wall_Right, 0, x, y, 1,1,0, c_white, 1);

//drawing the depth on the block
draw_set_colour(c_white);
draw_text(x+2, y+2, z);
 

TesloStep

Member
Code:
z = -900+distance_to_point(Damned.x,Damned.y);
you need assign that to variable named "depth", its system named stuff
some like that:
Code:
depth = -900+distance_to_point(Damned.x,Damned.y);
 
D

DyingSilence

Guest
Oh baby, it's working!

Weird, GM 8 taught me that depth and z are the same thing.
 
Top