So today morning when i launched my computer i have decided to add shadows to my game i’m currently working on. Now i would like to share this simple script i wrote to add shadows:
In script section add script scr_shadows:
draw_sprite_ext(sprite_index,image_index,x+shadow_x,y+shadow_y,shadow_xsize,shadow_ysize,direction,c_black,shadow_alpha);
Now we need to add this to draw event of object we want to add shadow:
shadow_x=a;
shadow_y=b;
shadow_xsize=c;
shadow_ysize=d;
shadow_alpha=e;
script_execute(scr_shadows);
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,direction,image_blend,1)
where:
- a is how far is shadow from the object on x axis
- b is how far is shadow from the object on y axis
- c is how big is the x size of shadow
- d is how big is the y size of shadow
- e is the shadow alpha (transparency) (can be only 0-1, so for example it can be 0.5, 0.1, etc.; 0 is invisible, 1 is fully visible)
- the 6th line executes the scr_shadows script
- the 7th line draws the sprite itself
I hope this was useful
PS: about my game i will write soon!