Final project lesson 27

I have a student that is trying to duplicate the snake game. If the snake touches one thing, then the snake gets longer (or the part attaches to it). How can this be done? I’m totally drawing a blank to figure this out.
Thanks in advance.


Sometimes, the most simple looking projects are actually pretty complex. The problem isn’t just getting the snake to grow by one body length, but how to get its length to continue to grow each time it eats something.

This involves keeping track of its size and then visually changing its appearance to match that.

That gets pretty complex pretty quickly (even though it is doable).

If you Google “ snake game” you will find a number of different projects that others have made using Game Lab, and looking at the code will show you how the game was created, however, that doesn’t mean it is easy to understand and code yourself (for a beginner).

For a beginning student, I might suggest something a little more simple to solve this problem. Rather than making it like the real snake game where the snake can grow to an indefinitely long length, they might consider creating “animations” of length 1, 2, 3 and 4 (or maybe a few more … depending). Then, when the snake comes into contact with the “food”, they could switch “animations” (costumes) to a larger version of themself.

Then, the length could be tracked using a simple variable and if snake1 eats the food, it becomes snake 2, snake 2 could be come snake3, etc.

If your student is more advanced, maybe suggest they google “ snake game” and they can look at the code and see how it was done to help create their own version.

That’s probably how I would address it with one of my students…



Thank you very much. That helps a lot. I will definitely suggest both to her and see what she wants to try to do. I like the setting a new animation idea.

1 Like