Creative Coding (Day 4)

Pen

To use the “Pen”, you need to first add the “Pen” extension. Click on the “Add Extension” button on the bottom left, then select the “Pen” extension.

The “Pen” extension will allow your sprite to draw on the screen. You can use it to draw interesting shapes and patterns.

It’s recommended to use a small sprite when drawing with a pen, as a large sprite can block your drawing. You can make any sprite small by changing its size.

The “Pen” extension works just like a real pen. If you lift the pen up, it will not draw. If you put the pen down, it will draw a line when you move it. Use “pen down” and “pen up” to start and stop drawing.

You can change the way the lines look by changing the pen color and size.

The “erase all” block will clear all drawings from the screen. Useful when you want to restart your drawing.

The “stamp” block will stamp the picture of your sprite on to the screen. This is just a picture, so it can’t move around or detect touches.

Basic Shapes and Repeat

Regular shapes such as squares, triangles, hexagons, etc, are drawn using repeated move and turn. You can save a lot of code and make your program neater by using the “repeat” blocks. In the above program, both scripts does the same thing, but the one on the right is a lot shorter!

My Blocks

“My Blocks” allows you to reuse code, allowing the program to be shorter and neater.

In the above example, when the script on the left reaches the “hexagon 50” block, it will jump over to the “define hexagon” script and set size to be equal to 50. After the “define hexagon” script is completed, it will return to the left and continue with the next block. By the end of the program, it would have drawn 3 hexagons of different sizes.

In this example, “size” is a parameter to the “hexagon” my block. A “My Block” can have one parameter, many parameters, or no parameters at all.

Quiz