Learn How to Code a Classic Snake Game (Part 1)

Опубликовано: 11 Июль 2026
на канале: Learning With Greg
327
3

In this series of videos I will code a Classic Snake Game from start to finish, talking you through my entire thought process along the way because I really do believe this type of project is one of the best way for new programmers to learn.

I am going to be using the MIT Scratch platform, but most of the methods and coding principles I use to create this snake game will be applicable in just about any coding platform or language (e.g. Java, Python, etc.) although different languages/platforms will have their own quirks and their own methods for working with graphics. I chose the MIT Scratch platform because it is highly visual and easy to get started with making it a great choice for learning the basics of programming. It's also a free platform so anyone can take this project for a spin and start to learn.

Play a final version of this game: https://scratch.mit.edu/projects/6313...

Because of the length, I've divided this snake game tutorial into 4 parts:

Snake Game Part 1:    • Learn How to Code a Classic Snake Game (Pa...  
Snake Game Part 2:    • Learn How to Code a Classic Snake Game (Pa...  
Snake Game Part 3:    • Learn How to Program a Classic Snake Arcad...  
Snake Game Part 4:    • snake game part4of4  

Some key moments in this video:

1:39 - Advice for when starting a new project
2:16 - Breaking the stage up into a grid
4:50 - Using the Pen Extension
9:25 - Using Custom Blocks (Functions) for more Efficient Code and to speed up workflow
16:24 - Lightning fast blocks/functions with Run w/o Screen Refresh
17:13 - creating the head of the snake
23:02 - Using a game flow variable
24:30 - Commenting your Code
30:35 - Using Broadcast Messages
35:24 - Coding the Snake Movement
36:05 - Thinking Ahead and Making Your Game more Flexible
38:24 - Forever Loops and Frame Rate
41:06 - Controlling snake direction and movement with variables tied to events (key presses)
45:00 - A Happy Accident
46:08 - Embrace Your Mistakes
46:42 - Watch for Game/Code Flow Mistakes
47:52 - Adjusting Player Speed
50:34 Cleaning Up and Improving Your Code as you Go
51:00 Using Grid Cell Size for More Flexibility
1:00:06 The payoff, changing grid/board size

Thanks for watching!

cheers,
Greg