Minimalist approach for playing in the style of the Snake

I got my TI-82 STATS programmable calculator (which is actually bigger than the TI-83) about two days ago - and wanted to program the Snake game with the built-in TI-BASIC language.

Although I had to find out: TI-BASIC is slower . My first implementation was so slow that it was not a problem for the player! The main bottleneck for me is the management of a list (array) containing the coordinates of the body of the snake.

I tried two things:

  • When the snake moves, update the position of the head, then iterate over the array from the position of the tail and set myList[ N ]to myList[ N - 1 ]to make the snake seem moving.

This, however, becomes invulnerable after the list receives about 4 parts. (too slow)

  • Then I tried to implement some kind of / deque queue using the TI-BASIC list management functions, for example, jump from the end and add something to the front of the array.

This worked a little better, but it gets too slow over time.

TL DR / current issue:

  • Do you know the trick to prevent the game from slowing down with the increase of the snake? I saw that this is possible in other games made in TI-BASIC
+5
source share
3 answers

Use a circular buffer . To clarify:

Get an array large enough to hold the maximum snake. Set two pointers, one for the head, one for the tail.

№1, №3. , . , , . , .

+3

, , , , [N - 1] [N - 2] , , , (

+1

All Articles