Tutorial 8: Make a simple drawing app with Pen
You will make: a drawing surface where the sprite follows the pointer while the mouse is down. This uses G-Warp's Pen extension; enable it from Extensions before building the scripts.
Step 1 — Enable Pen
- Save a copy of the project.
- Open Extensions and add Pen, if it is available in the current build.
- Select the sprite that will act as the pen tip. Put it at the Stage centre and choose a small costume.
Step 2 — Draw while dragging
Use a looping script to follow the mouse, drawing only while the pointer button is down.
when flag clicked
erase all
pen up
forever
go to x: (mouse x) y: (mouse y)
if <mouse down?> then
pen down
else
pen up
If your Pen palette calls its clearing block erase all or shows a slightly different label, use exactly what is in your build's Pen category. The pointer-tracking block is from Motion and the mouse-state reporter is from Sensing.
Step 3 — Add colors or thickness
- Use the available Pen color block before drawing to pick a new color.
- Use the Pen size block to set a comfortable thickness. Try two or three sizes and compare them.
- Add a key-press event for a chosen key to clear the screen with the Pen clear block if you want a reset shortcut.
Step 4 — Test and save
- Press Start and drag the mouse across the Stage. Lines should appear only while the mouse is held down.
- Release the mouse and move the pointer without drawing. The pen should lift.
- Try drawing again after clearing. Save, close/reopen a copy, and check whether your saved project behaves the way you expect.
Gotcha: Pen ink may be cleared when the project stops or restarted depending on the implementation. If you need a permanent drawing, you may need to stamp/export the result or use a paint editor. Do not assume pen strokes become costume art automatically.