Scratch Arts
Normal
45 mins
115 points
What you need:
  • Computer/laptop

Pattern Snake

Create stunning visual snake patterns by moving your mouse.

1 - Create a new Scratch project

Go to the Scratch website, create a new project and delete the cat sprite.

scratch.mit.edu

2 - Draw a sprite

In this project we will draw a sprite and then code it to follow our mouse around the screen and create a trail behind it with some added effects.

Create a new sprite and draw a shape. It can be any shape and any colour you like. Keep it small and drag it into the center of the box.


3 - Follow you mouse pointer

To make the snake pattern we will code the sprite to follow your mouse around the stage area.

Add the following code to the sprite to make it start at a random position and then follow your mouse pointer.

when green flag clicked go to (random position v) forever move (10) steps if on edge, bounce point towards (mouse-pointer v) end

Click on the green flag and your sprite should follow your mouse around.


4 - Create clones

To make the trailing snake effect we will create clones of our sprite, leave them where they were created and then delete them after 5 seconds.

Add the following new code blocks to your sprite.

when green flag clicked go to (random position v) forever move (10) steps if on edge, bounce point towards (mouse-pointer v) create clone of (myself v) // add this block end when I start as a clone // add these blocks wait (5) seconds delete this clone

Click on the green flag and the clones should make a snake effect before deleting after 5 seconds.


5 - Change the colour

To make it look even better add a change [color] effect by 5  block underneath the create clone of [myself] block. This will change the color of the original sprite after each time a clone is created.

when green flag clicked go to (random position v) forever move (10) steps if on edge, bounce point towards (mouse-pointer v) create clone of (myself v) change [color v] effect by (5) // add this block end

Click on the green flag and snake should me multicoloured now.


Join our club 😃

To view the remaining 1 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more