Please update your browser
Your browser version is not supported by this site. CS First may not work properly. Learn more.
In the last video, you should have
opened the starter project, remixed it, and signed in.
If you haven't done this yet, please stop this video
and return to the previous one.
In this video, you'll program the pencil
to follow the mouse-pointer and draw on the canvas.
To start, make the pencil follow the mouse-pointer.
Select the pencil sprite and click the motion menu.
Find the go to mouse-pointer block and click to run it.
The pencil moves where the mouse-pointer is.
Drag out this block and click it to run it again.
The pencil sprite again moves as close to
the mouse-pointer as possible.
Now that the pencil goes to the mouse-pointer
when the go to mouse-pointer block is run once,
program this block to run forever.
To do this, use a loop.
Select the control menu.
Loops tell the computer to repeat an action
as many times as you specify which in this case,
should be forever.
Select a forever loop and put it
around the go to mouse-pointer block.
Click the block stack to try this out.
When you move the mouse-pointer around the stage,
the pencil sprite follows it.
This is because the sprite is programed
to go to the mouse-pointer forever.
Now that the pencil sprite follows the mouse-pointer,
it should draw as it moves.
Select the pen menu.
Drag a pen down block into the forever loop.
Click to run it again.
Test it out by moving the mouse-pointer around the stage.
To erase all the drawings and marks,
click the erase all block.
This game should always start with a blank canvas,
so add the erase all block to the start of this block stack.
Finally, add a when flagged click event
to the top of the block stack.
Click the flag to add it all together.
When the flag is clicked, the drawing clears,
the pen starts drawing and the
sprite follows the mouse-pointer forever.
Now it's your turn.
Program the pencil sprite to go to
the mouse-pointer forever.
Use the pen down block to make the pencil sprite draw.
Add a when flag clicked event
and a clear block to the start of the program.
Sign in to track your progress and earn badges