Please check the following points.
Don't you escape from a subroutine without "RETURN" after you have jumped to the subroutine with "GOSUB"?
Isn't the nest of recursive function call too deep?
I assume you're using GOSUB in your code, right? Make sure you have a RETURN to return to your main loop. Basically, the game seems to be running out of memory because it keeps getting a GOSUB without a RETURN, like this:
@T1
GOSUB @T2
@T2
GOTO @T1
SmileBASIC tries to keep track of where the last GOSUB was so it can return there once it hits the RETURN command; However, it can also...
stack these, so you can use multiple GOSUBS and still remember all the previous ones. For example, you can make code that GOSUBS out of the main loop into an input section of code, and then GOSUB it again to, say, the code that activates when you press UP, and you could GOSUB it *again* to the code that moves the player up if there are no obstacles in the way, and this can go on and on. Once it...
reaches a RETURN, it will return where it left off in the moving code, and then the next RETURN would return it to where it left off in the input code, and one more RETURN would return it to where it left off in the main loop. The catch is that there's a limit to just how much you can GOSUB before RETURNing, and often times there may be an error in your code that causes this to happen...
You might have a GOTO @LOOP where you should have a RETURN, or maybe you just used to many GOSUBS! Check the line the error occurred on, and try to figure out exactly where the code is going. You probably just need to change a GOTO to a RETURN or remove an unecessary GOSUB. Hope this helps! (And that it wasn't too long. :P)
Well I have returns, so thats not the problem. I don't have gotos instead returns, so thats not the problem. I may have too many gosubs. This game has over 2000 lines of code and I may overuse gosubs. So if I did have too many gosubs, what would I do to fix the stack overflows.
Hmm, I'm not sure... Does the error occur quickly after starting or only after certain actions? I really can't give you a solid answer, I'm just trying to give you the best advice I've got, sorry.
Hmm, that's strange. The best thing to do is to look at your code around where the error occurs, and try to figure out if it is linked to any specific actions. (Like, does it always happen while you're moving down, for example?) Just try to figure out what the code is doing and why it's missing a RETURN. Hopefully I've sent you in the right direction and haven't just confused you. :P
I recommend you not to use deep nest subroutine call. A subroutine should be called after another subroutine has returned over. SmileBASIC's stack must not be so deep.
Actually, I'm looking forward to the completion of this game. I'd like to support you as much as I could in order to fix the problem.
Is it possible to show us line 349 of your code?
Hold up. What happens @DEAD? Does it reset the game or return to the main menu? If it does anything like that then it should probably be GOTO instead. Try that and see what happens!
I changed a ton of stuff to GOTO since I found out that GOTOS are different than GOSUBS and it worked for now. I GOT TO 40000 WHITHOUT A STACK OVER FLOW!! :)