Hi,
I am new to scratch. since many years I am a teacher of computer-science and want to show my 14-year-old pupils this new environment.
I am searching for a possibility to craete a sort of "routine" or "procedure" or "method" with parameters to write i.e. a recursive scipt to paint the koch-snowflake. It may be something like:
snowflake (depth):
if depth > 0
do somthing;
snowflake (depth - 1)
........
Offline
Hi kbovi,
recursion is not a feature of Scratch, in fact declaring your own functions (with or without arguments) aren't a feature of Scratch. To take it even further: The distinction between classes and instances is not a concept supported by Scratch. But I'm sure you'll find a creative way around such minor drawbacks using sprites, variables, loops and messages <grin>.
I'm not a CS guru, but you could, e.g. create a variable called 'depth' and initialize it with some value. Then you could compose your algorithm and put it into a loop.
The closest thing to real recursion would be to let a script send a message triggering itself, something like:
[blocks]<when I receive[ messageName
<set{ variable }to( some algorithm
<broadcast[ messageName[/blocks]
This is - of course - just another way of implementing a forever-loop, but at least it has the 'look of recursiveness'. And it actually works in Scratch despite all the reentrancy problems discussed elsewhere on this board.
You could also check out this project on the koch snowflake: http://scratch.mit.edu/projects/toontownmiser/26060
On your 'stuff' - page it says you're from Germany. Did I mention there are quite a number of excellent German course materials available?
Have a look at:
http://www.funlearning.de/ (a complete introductory course)
http://digitale-schule-bayern.de/dsdaten/348/96.pdf (another introduction)
http://signalbscw.tcs.informatik.uni-muenchen.de/pub/bscw.cgi/d194654/ScratchInf7-Schlager.pdf
Hope that helps
Jens
Offline