Hi guys, over the past couple days I decided to try making a program that plays snake on my calculator because I was bored, wanted to learn BASIC better, and wanted some experience with a larger project than just small scripts. This was programmed on a TI-84+ and I was wondering about any optimizations to make my program smaller/faster or overall advice for current or future reference. Also welcome would be advice about usability or advice on making the UI nicer. The code is linked below, but if you want a brief explanation as to how it works, the next paragraph will be dedicated to that.
Start off with some setup stuff for the window and initializing a few variables. The main loop of the program goes like this: calculate the snake's next square (storing x coordinates to L1 and y coordinates to L2), check if it collided with itself or stepped out of bounds, check if it collected a cherry. If so, increment score, generate new cherry, and move on. If no cherry, then delete the oldest piece of the snake, and move on. Then display the next piece of the snake, and check for input. Then there's a game over screen (Pic 1 is simply a black box with white text saying "game over" in the same style as the title of a Menu(, and I couldn't find a better way to create that without going into an actual menu.). Finally a little bit of cleanup.
I read somewhere on the wiki that using getkey at the end of the loop is more efficient. I'd like to know why that is in particular. I got the impression it's because Ans is faster than calling a variable, but I don't see why that would be any different than calling it on the first line and then using Ans. Anyways, if someone could clarify that for me, as well as any other optimizations, that would be greatly appreciated.
Output(1,1,"PRESS ENTER TO BEGIN."
If K=15:Goto L
If L1(N+1)>31 or L1(N+1)<1:Goto L
If L2(N+1)>21 or L2(N+1)<4:Goto L
If pxl-Test(66-3L2(N+1),3L1(N+1)):Goto L