I'm afraid you can't nest subroutines like that. The compiler just sees return as a "jump back to where gosub was called from" and ignores any labels it sees on the way. For example:
Sync On
Do
GoSub Subroutine
Sync
LOOP
Subroutine:
StageOne:
// Colour screen red
CLS RGB(128,0,0)
// At this point, code jumps back to the Do-Loop block
return
StageTwo:
// Colour screen grey
CLS RGB(128,128,128)
return
return
This code follows something similar to your own code layout - but the "return" after StageOne simply triggers the return to where Gosub Subroutine was called from.
You
can do what you want though. Structure your code like this:
gosub Stage1
gosub Stage2
gosub Stage3
// this stops you accidentally running into the Subroutine's code
// when you think you've finished
end
Stage1:
// Put some code here
GoSub StageOne_Subroutine0
GoSub StageOne_Subroutine1
// Now return to wherever called "GoSub StageOne"
return
StageOne_subroutine0:
`codes
// Return here will return you to the StageOne subroutine
return
StageOne_subroutine1:
`codes
return
Collision:
gosub Stage2 `I think the problem would start here?
// No problem whatsoever...
Return
Stage2:
`Stage2 codes same with Stage1
Return
Stage3
`Stage3 codes same with Stage1 and Stage2
Return
It's fine to call GoSub from a subroutine, and you can carve your program up into nice, easy to use chunks. Just be careful on the order of them within the file. As DBP reads through the code file from first line to last, I don't think it can jump to a Subroutine it hasn't yet read.
Hope this helps!
We spend our lives chasing dreams. Dark Basic lets us catch some of them.