|
|
Line 48: |
Line 48: |
| File:Collapsestack.jpg|Collapse a 'stack' of blocks to save space | | File:Collapsestack.jpg|Collapse a 'stack' of blocks to save space |
| File:Pushpop.jpg|Store data in the first in last out heap using 'push' and 'pop' | | File:Pushpop.jpg|Store data in the first in last out heap using 'push' and 'pop' |
− | File:Turtlearray.jpg|Box names (and stack names) can be boxes, in this case 10 boxes are created. This is a powerful programming feature. A one dimensional array of variables has effectively been created. | + | File:Turtlearray.jpg|Box names (and stack names) can be boxes, in this case(taken from the math-dice project), a one-dimensional array of 11 variables has been created. |
| </gallery> | | </gallery> |
| | | |
Revision as of 09:11, 10 July 2012
Getting Started
Start by clicking on (or dragging) blocks from the Turtle palette. Use multiple blocks to create drawings; as the turtle moves under your control, colorful lines are drawn.
You add blocks to your program by clicking on or dragging them from the palette to the main area. You can delete a block by dragging it back onto the palette. Click anywhere on a "stack" of blocks to start executing that stack or by clicking in the Rabbit (fast) , Turtle (slow) or Bug (debug) buttons on the Project Toolbar.
The basics
Basic turtle graphics: 'forward', 'back', 'arc', and 'right' blocks
The 'set color' block affects pen trails, fill and text
Drawing shapes
Use the 'repeat' block to draw shapes
This can be generalised to n sided polygons, n is stored in 'box 1'
Use 'start fill' and 'end fill' to draw filled shapes
Displaying things
Use 'print' to display in the print window
'show' block used to display at the turtle
'show' plays sounds as well
'print' and 'show' can display text or numbers including results of calculations
'print' or 'show' mixed text and numbers, using '+'
Text to speech. Load the Python block with the inbuilt sample code speak.py
Boxes, Stacks and the Heap
(aka variables, subroutines and the stack)
Named variables: store a variable in 'box'
Named 'stacks' of blocks can be reused
When a new named stack is created, a new action block is added to the palette.
Collapse a 'stack' of blocks to save space
Store data in the first in last out heap using 'push' and 'pop'
Box names (and stack names) can be boxes, in this case(taken from the math-dice project), a one-dimensional array of 11 variables has been created.
Mathematics
Math operators including + - * / mod sqrt
Logical operations: flow control blocks accept >, <, =, and, not, or as input
Use Python functions, (accepts any of the time or math library functions)
Cartesian and polar coordinate grids
Centimeter coordinate grid (XO only)
Keyboard, mouse and sensor input
Converting the keyboard output to a string
Entering a multi digit number, exits with the number in 'box 1', [[2]]
Load the Python block with the sample code push_mouse_event.py to read mouse events
Read sensors plugged into the microphone socket [3]