this is a similar to your example image:
// Project: sprite shadow
// Created: 2019-08-16
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "sprite shadow" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
box = CreateSprite(0)
SetSpriteSize(box,128,64)
SetSpritePosition(box,1080,720)
Shadow = MakeShadow(box,10)
SetClearColor(128,255,128)
MaximizeWindow()
do
mx = GetPointerX() : my = GetPointerY()
SetSpritePosition(box,mx,my) : SetSpritePositionByOffset(shadow,mx,my)
Print( ScreenFPS() )
Sync()
loop
Function MakeShadow(sprite, distance)
W = GetSpriteWidth(sprite) : H = GetSpriteHeight(sprite)
alpha = 30/distance
ShadowSpr as integer[]
for x = 1 to distance
this = CloneSprite(Sprite)
ShadowSpr.insert(this)
SetSpriteColor(this,0,0,0,alpha)
SetSpritePosition(this,x,distance-x)
SetSpriteDepth(this,GetSpriteDepth(sprite)+x)
SetSpriteTransparency( this, 2 )
render()
next x
for x = 0 to distance-1
DeleteSprite(ShadowSpr[x])
next x
SetSpriteVisible(sprite,0)
Shadow = GetImage(0,0,W+Distance,H+Distance)
SetSpriteVisible(sprite,1)
this = CreateSprite(Shadow)
SetSpriteOffset(this,0,distance)
SetSpriteDepth(this,GetSpriteDepth(sprite)+1)
Endfunction this
play with the
distance and
alpha (can even add
direction easy enough).