Lompat ke konten Lompat ke sidebar Lompat ke footer

How To Make Snake Game In Scratch

If you are looking to learn how to make the Snake game in Scratch, you have come to the right place. Scratch is a visual programming language that is great for beginners and young people who want to learn programming. It is a block-based programming language that lets you drag and drop blocks to make programs.

In this tutorial, we will go step by step on how to make the Snake game in Scratch. We will start from scratch, but by the end of the tutorial, you will have a working Snake game that you can play and share with your friends.

Step 1: Getting Started with Scratch

If you have never used Scratch before, you will need to start by creating an account on the Scratch website. Once you have created an account, you can log in and start using Scratch.

To get started with Scratch, you will need to create a new project by clicking on the "Create" button on the Scratch homepage. This will open a new project, and you will see the Scratch editor on your screen.

Scratch Editor

Step 2: Creating the Background

The first thing we need to do when making the Snake game is to create the background. To do this, select the "Stage" from the top menu and then select the "Backgrounds" tab. From here, you can create a new background by clicking on the "New Background" button.

Scratch Background

Once you have created the new background, you can set the background color to anything you like. For the Snake game, we will use a green background. To do this, select the "Paint" button and then select the green color. Now, you can draw a rectangle on the stage to create the background.

Scratch Paint

Step 3: Creating the Snake

Now that we have the background, we can start creating the Snake. To do this, we will need to create a sprite for the Snake. To create a new sprite, select the "Choose Sprite from Library" button and then select the "Animals" category from the left-hand side menu. From here, you can select the "Snake" sprite and add it to your project.

Scratch Sprite

Once you have added the Snake sprite to your project, you can start programming it. To move the Snake, we will use the "move" block. To do this, drag the "move" block from the left-hand side menu to the right-hand side menu and select the direction you want the Snake to move. We will start by moving the Snake to the right.

Scratch Move Block

Step 4: Creating the Food

Now that we have the Snake, we need to create the food that the Snake will eat. To do this, we will use a second sprite. To create a new sprite, click on the "Choose a Sprite" button and select the "Food" sprite from the "Food" category. We will add this sprite to our project.

Scratch Food

Once we have the food sprite, we need to program it to appear randomly on the stage. To do this, we will use the "go to x: (random 240) y: (random 180)" block. This block will make the food sprite appear at a random location on the stage.

Scratch Random Block

Step 5: Making the Snake Grow

Now that we have the Snake and the food, we want to make the Snake grow when it eats the food. To do this, we will use a "list" block. A list is a collection of items that can be manipulated in Scratch. In our case, we will use a list to keep track of the length of the Snake.

Scratch List

When the Snake eats the food, we will add an item to the list. To do this, we will use the "add (1) to [list]" block. This block will add 1 to the list, which will increase the length of the Snake.

Scratch Add Block

Step 6: Making the Game Over

Finally, we need to make the game over when the Snake hits the edge of the stage or when it hits its own body. To do this, we will use the "touching color?" block. We will use this block to check if the Snake is touching the green color of the background.

Scratch Color

If the Snake is touching the green color, we will end the game. To do this, we will use the "stop all" block, which will stop the game and display the "Game Over" message.

Scratch Stop-All

Conclusion

By following these simple steps, you now know how to make the Snake game in Scratch. Scratch is a great way to learn programming, and it is a lot of fun to create your own games and projects. Try changing the colors, adding obstacles, or making the game more challenging. The possibilities are endless!

Related video of How To Make Snake Game In Scratch