how I (try) to do it is by converting a sprite's position to a BG's position.
Using that data on an array,
you can check if the position under you is a blank or another block by using
IF ARRAYNAME[PLYRY+1,PLYRX]==0 THEN Y=Y+GRAVITY
note:(not plyry;variables can be changed)
My SAMPLE project is Key: Q34443GD. Inside of the project is a file called PLATFORM.
Starting on line 362 is a function called LOAD_MAP that will load map files saved from SmileBasic's map editor. No separate layer files required.
Between lines 291 and 360 are a set of functions used to check if you can bump into a background tile or not (one layer is reserved for non-passable blocks).
Lines 74 to 258 is the function that moves the hero around.
It is a lot of code, but what you are trying to do is actually fairly involved. Please give it a read and let me know if you have questions.