Monday, July 27, 2015

Doodle Pencil - Using the Pen & Mouse Pointer Coordinates in Scratch

Here's a fun little Doodler made with Scratch:  The Doodle Pencil
















This was rather a spur-of-the-moment project... inspired by Etch-a-Sketch...  and kind of a follow-up on the Pac-Man game...

The code is minimal, and I feel not much of an explanation is required. The instructions are mainly from the Pen area of the Scratch Instruction Set, along with the instruction to follow the mouse-pointer. The "green flag click" handler does the initialization - clearing the screen, setting the sprite size and setting up the pen size & color.

The code is interactive, and it's designed to enable the user to lift and lower the pen as required while doodling: Move the mouse pointer to the desired location on screen and then click on the up arrow key; the pen will start drawing now by following the movements of your mouse pointer. Click on the down arrow key to stop drawing at any point.

This could be a fun little exercise for the kids to see how different combinations of the "Pen" and "Motion" instructions interact with each other.

Enjoy doodling!

No comments:

Post a Comment