The Secret Of The Snake Part 2

2023-06-12に共有

(v00 07-15-22)
TO LOAD THIS PICO-8 CART, in immediate mode, type: load #secret_snake2

A couple of years back I wrote a post called, "The Secret Of The Snake" and it was me investigating the complex code involved in making a "Snake" type game. In the link below, the only way I knew was to update the entire screen, in the case I wrote was 16x16 and keep track of the snake segments this way.

https://www.lexaloffle.com/bbs/?tid=35685

Thanks to @SquidLight and the marvelous "array rotation" code I am now able to create a true "snake" type program where only two pixels are drawn at a time.

One for the head of the snake and one for the back, and no need to redraw the screen or each snake segment each time; only those two points, the first and last.

In the demo above, use the arrow keys to navigate.

Press and hold 🅾️ to increase the length of the snake.

Press and hold ❎ to decrease the length of the snake, but not smaller than 8-pixels.

Release the 🅾️ or ❎ keys to continue the snake's movement.

Be aware no checks for collision are being made at this time. The code is to demonstrate how to make a SNAKE type game plotting only 2-points.

See source-code for documentation and information.