Snake Micro:bit

by Kyano in Circuits > Computers

518 Views, 1 Favorites, 0 Comments

Snake Micro:bit

Aantekening 2021-10-15 1142002.png

I will show you how my Micro:bit snake works. step by step.

Moving the Snake

Aantekening 2021-10-15 10748104.png

This code makes the snake move forward every 800ms.

Making the Food Blink.

Aantekening 2021-10-15 1048104.png

This code will make the food blink every second. This makes it easier to see what is the food and what is the snake.

Turning Left and Right.

Aantekening 2021-10-15 103952.png

This is the code that makes the snake turn left and right by pressing A and B.

it makes them turn 90 degrees to the left or right.

When Starting Micro:bit.

Aantekening 2021-10-15 104104.png

When starting the Micro:bit, your score will be set to 0, it will spawn the snake in the middle and spawn 1 random food somewhere on the map.

Spawning New Food.

3.png

this code checks if the snake and the food is on the same light, and if they are he will ad 1 to your score and spawn a new food.