ScratchData LogoScratchData
Back to excelguru's profile

Snake

EXexcelguru•Created January 12, 2019
Snake
0
0
6 views
View on Scratch

Instructions

A recreation of the classic game "snake." Arrow keys to change direction. Get the food, but avoid running into yourself.

Description

Update Feb. 18 2019: tweaked script to make fast turns easy both horizontally and vertically (previously they only worked horizontally). As a side effect, you can now move diagonally more easily. How this project works: The graphics are handled completely separately from what makes the game work. The position of each part of the snake is stored in three lists: snake x (x positions), snake y (y positions), and snakepositionreference, which stores the x position and the y position joined together and is used for checking if a block is part of the snake. Every time the snake moves, the lists are updated, and the snake is updated to match the updates to the list: the new head location is stamped in and the block at the end is stamped white so it can't be seen. If the new head location is at the food's location (which is stored in two variables), the first part is not removed, so the snake gets longer. The food is relocated to somewhere else, using a loop to not end up in the snake's location. The food displays at its location.

Project Details

Project ID279156090
CreatedJanuary 12, 2019
Last ModifiedFebruary 18, 2019
SharedJanuary 14, 2019
Visibilityvisible
CommentsAllowed