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

Need help with shadows that grow and shrink with jump

Status
Not open for further replies.

Pkirkby

Member
Hey everyone, I have this code implement from a tutorial I did. I have a z-axis in my game, and a jump command. When I jump, my shadow stays the same obviously.

I am trying to work out an equation or simple solution to have it somehow multiply,divide, etc. by my zsp (my jump height on the z-axis) and increment by 0.1 depending on my height. I've almost successfully done it with some old code, but I can't figure it out. Hope this made sense to everyone.

Here's my current code for my shadows:

with(oParent)
{
//variables for shadows
var sx = 25;
var sy = 15;


//Draw Shadow

gpu_set_fog(true,c_black,0,1);
draw_sprite_pos(sprite_index,image_index,
x-(sprite_width/2)-sx,
y-sy,
x+(sprite_width/2)-sx,
y-sy,
x+(sprite_width/2),
y,
x-(sprite_width/2),
y,
0.5);


//draw_sprite_ext(sprite_index,image_index,x-5,y-5,image_xscale,image_yscale,0,c_black,0.5);

//This sets fog to disable,white is default.
gpu_set_fog(false,c_white,0,0);

}

Here's the old way I did it, that almost worked:

draw_sprite_ext(sprite_index,image_index,x,y,image_xscale/(2 - (zsp -1) * 0.1),image_yscale/(2 - (zsp -1) * 0.1),
image_angle,c_black,0.5);

Thanks in advance everyone!
 

obscene

Member
Using your old version:

If the max of zsp was 10, and you wanted the shadow at that point to be 0.5 size...

shadow_scale = 1-(zsp*.05);

.05 is the minimum shadow size divided by the maximum zsp value.
 
Status
Not open for further replies.
Top