
removes a sprite from the end of the snake.īecause steps 1 and 2 are the same for each of the four directions, the function below embodies the two steps.

places a body sprite where the head was and.moves the snake head in the direction indicated by the button,.Move Snake with Up, Down, Left and Right Buttons Each apple is placed at a random position on the screen. The function create_random_apples generates one or two apples keeping the total number less than or equal to 3. Because the initial snake is to be positioned vertically, the x position is always the same as the snake head, while the y position varies. The function make_body_sprite takes two arguments that are the x and y positions of the sprite to be created. Of course, the first body sprite is positioned just below the snake head. A function is called within a loop to build a snake of 4 sprites, each positioned below the preceding. The links in the snake are stored in a list that is an array of sprites of type snake_body_sprite. If the head goes off the screen, the game will end.Ĭreating the snake’s body is a little more complicated because a snake has only one head but may have many links (sprites) in its body. The last block requires the snake head to stay on the screen. The function creating the snake’s head creates a square green image to be used in creating the sprite.
#Download screen snake for windows code#
The code below initializes the game by setting the background color, setting sprites of which the snake is composed to 8 pixels, calling functions to create the snake head and body, creating the apples and setting the score to 0.
#Download screen snake for windows how to#
The last section of the post will explain how to download a MakeCode Arcade game to a Meowbit. In the photo below, the Meowbit is running the Apple-Eating Snake game. In addition to the Arcade simulator, which runs in a browser, an Arcade game can also be run on several devices. If done by accident, the snake head may hit the wall or the snake’s body unexpectedly and end the game.

The snake head can be alongside the body, but cannot intersect it.
