yes the variables declaired in DB functions will all be local ones. also you can not call a goto or gosub tag from outside of that function. I asume you're having problems because you have some sort of ground that uses curves or is hilly... cant help you there, but here is some stuff that i've learned about 2d in Db that might be helpfull.
1: because sprites in Db move so slowly... at least on my crap pc, try using the set sprite comand and seting the backsave state to 0 on your sprites then seting the backdrop comand to on, this clears the screen and uses some of DB's 3d capabilites to help with the slowness of the 2d.
2: the sprite collision() comand sucks, because if you are still touching one sprite it will not pick up on the next sprite you touch unless you are no longer touching the previous sprite. so its much better to just create an aray for each sprite's position in your game.
dont know if that was any help. sory if not. if you want more help i've made a prety good 2d collision engine (easily walk up stairs, easily walk on stuff, works well with gravity settings etc..)
Come children and i shall bring you into unlevend
feilds of faraf fo sdlief dnevelnu otni uoy gnirb llahs i dna nerdlihc emoC