Is this what your looking for?
// Project: Block Drop
// Created: 2021-06-14
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Block Drop" )
SetWindowSize( 500, 900, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 500, 900 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 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
Function CreateBlock()
sprID=CreateSprite(0)
SetSpriteColor(sprID, random(0, 255), random(0, 255), random(0, 255), 255)
SetSpriteSize(sprID, 32, 32)
SetSpritePosition(sprID, GetRawMouseX(), 20)
EndFunction sprID
Function CheckBlock(sprNext, sprLast)
bResult = 0
if GetSpriteExists(sprNext) and GetSpriteExists(sprLast)
nextX = GetSpriteX(sprNext)
nextY = GetSpriteY(sprNext)
nextHeight = GetSpriteHeight(sprNext)
lastX = GetSpriteX(sprLast)
lastY = GetSpriteY(sprLast)
lastWidth = GetSpriteWidth(sprLast)
if (nextX >= lastX-lastWidth) and (nextX<= lastX+lastWidth) and (nextY + nextHeight >= lastY)
// count is above and NOT besides count-1
SetSpritePosition(sprNext, nextX, lastY-nextHeight)
bResult=1
elseif (nextY+nextHeight >= 900)
SetSpritePosition(sprNext, nextX, 900-nextHeight)
bResult=1
endif
endif
EndFunction bResult
Function UpdateBlock(sprNext, sprLast)
if GetSpriteExists(sprNext)
if CheckBlock(sprNext, sprLast)
SetSpriteColor(sprNext, 97, 97, 97, 255)
else
SetSpritePosition(sprNext, GetSpriteX(sprNext), GetSpriteY(sprNext)+20)
endif
endif
EndFunction
Global gNext
Global gLast
do
if GetRawMouseLeftPressed()
gLast=gNext
gNext=CreateBlock()
endif
UpdateBlock(gNext, gLast)
Print( "Click mouse to drop next block" )
Sync()
loop