Create stunning visual snake patterns by moving your mouse.
Go to the Scratch website, create a new project and delete the cat sprite.
Go to the Scratch website using the link below and click on the 'Create' link in the blue bar at the top.
By default, each new project starts with the cat sprite already added. To delete the cat click on the x in the blue circle beside the cat in the sprite list.
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.
You can create your own sprites using the sprite editor. To create a new sprite put your mouse over the Choose a Sprite button and then click on the paintbrush.
This create a blank sprite and will open the sprite editor where you can use the tools to create your sprite. You can even create extra costumes for your sprite!
Tip: give your sprite a name so that you can recognise it in the code blocks.
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.
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.
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.